Commit c97f97f2 authored by Andreas Fernandez's avatar Andreas Fernandez
Browse files

[BUGFIX] Wrap operands in parentheses

This patch wraps operands in parentheses which could otherwise cause
unwanted side-effects. In most cases null coalesce operators are
affected.

Resolves: #92104
Releases: master, 10.4, 9.5
Change-Id: I95815354090516f09b61655126c61ccc8714a751
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65331


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarJörg Bösche <typo3@joergboesche.de>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: default avatarJörg Bösche <typo3@joergboesche.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent f1b87811
......@@ -66,7 +66,7 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
// Clearing of all caches is only shown if explicitly enabled via TSConfig
// or if BE-User is admin and the TSconfig explicitly disables the possibility for admins.
// This is useful for big production systems where admins accidentally could slow down the system.
if ($userTsConfig['options.']['clearCache.']['all'] ?? false
if (($userTsConfig['options.']['clearCache.']['all'] ?? false)
|| ($isAdmin && (bool)($userTsConfig['options.']['clearCache.']['all'] ?? true))
) {
$this->cacheActions[] = [
......
......@@ -66,7 +66,7 @@ class DatabaseLanguageRows implements FormDataProviderInterface
) {
$defaultLanguageKey = $result['tableName'] . ':' . (int)$result['databaseRow']['uid'];
$result['defaultLanguageDiffRow'][$defaultLanguageKey] = json_decode(
(string)$result['databaseRow'][$result['processedTca']['ctrl']['transOrigDiffSourceField']] ?? '',
(string)($result['databaseRow'][$result['processedTca']['ctrl']['transOrigDiffSourceField']] ?? ''),
true
);
}
......
......@@ -909,7 +909,7 @@ class BackendUserAuthentication extends AbstractUserAuthentication
*/
public function mayMakeShortcut()
{
return $this->getTSConfig()['options.']['enableBookmarks'] ?? false
return ($this->getTSConfig()['options.']['enableBookmarks'] ?? false)
&& !($this->getTSConfig()['options.']['mayNotCreateEditBookmarks'] ?? false);
}
......
......@@ -1382,7 +1382,7 @@ class DataHandler implements LoggerAwareInterface
$originalLanguageRecord = $this->recordInfo($table, $currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']], '*');
BackendUtility::workspaceOL($table, $originalLanguageRecord);
$originalLanguage_diffStorage = json_decode(
(string)$currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']] ?? '',
(string)($currentRecord[$GLOBALS['TCA'][$table]['ctrl']['transOrigDiffSourceField']] ?? ''),
true
);
}
......@@ -2449,9 +2449,9 @@ class DataHandler implements LoggerAwareInterface
$queryBuilder->expr()->neq('uid', $queryBuilder->createPositionalParameter($uid, \PDO::PARAM_INT))
);
// ignore translations of current record if field is configured with l10n_mode = "exclude"
if ($GLOBALS['TCA'][$table]['columns'][$field]['l10n_mode'] ?? '' === 'exclude'
&& $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] ?? '' !== ''
&& $GLOBALS['TCA'][$table]['columns'][$field]['languageField'] ?? '' !== '') {
if (($GLOBALS['TCA'][$table]['columns'][$field]['l10n_mode'] ?? '') === 'exclude'
&& ($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] ?? '') !== ''
&& ($GLOBALS['TCA'][$table]['columns'][$field]['languageField'] ?? '') !== '') {
$queryBuilder
->andWhere(
$queryBuilder->expr()->orX(
......@@ -5310,7 +5310,7 @@ class DataHandler implements LoggerAwareInterface
}
// Record must be online record, otherwise we would create a version of a version
if ($row['t3ver_oid'] ?? 0 > 0) {
if (($row['t3ver_oid'] ?? 0) > 0) {
$this->newlog('Record "' . $table . ':' . $id . '" you wanted to versionize was already a version in archive (record has an online ID)!', SystemLogErrorClassification::USER_ERROR);
return null;
}
......
......@@ -117,7 +117,7 @@ abstract class AbstractDriver implements DriverInterface
*/
public function hasCapability($capability)
{
return $this->capabilities & $capability == $capability;
return ($this->capabilities & $capability) == $capability;
}
/*******************
......
......@@ -821,7 +821,7 @@ class DataHandlerHook
$dataHandler->addRemapStackRefIndex($table, $id);
// Set log entry for live record:
$propArr = $dataHandler->getRecordPropertiesFromRow($table, $swapVersion);
if ($propArr['t3ver_oid'] ?? 0 > 0) {
if (($propArr['t3ver_oid'] ?? 0) > 0) {
$label = $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_tcemain.xlf:version_swap.offline_record_updated');
} else {
$label = $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_tcemain.xlf:version_swap.online_record_updated');
......@@ -832,7 +832,7 @@ class DataHandlerHook
$dataHandler->addRemapStackRefIndex($table, $swapWith);
// Set log entry for offline record:
$propArr = $dataHandler->getRecordPropertiesFromRow($table, $curVersion);
if ($propArr['t3ver_oid'] ?? 0 > 0) {
if (($propArr['t3ver_oid'] ?? 0) > 0) {
$label = $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_tcemain.xlf:version_swap.offline_record_updated');
} else {
$label = $this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang_tcemain.xlf:version_swap.online_record_updated');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment