Skip to content

Commit

Permalink
[BUGFIX] Wrap operands in parentheses
Browse files Browse the repository at this point in the history
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: TYPO3com <noreply@typo3.com>
Tested-by: Jörg Bösche <typo3@joergboesche.de>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Jörg Bösche <typo3@joergboesche.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
  • Loading branch information
andreaskienast committed Aug 26, 2020
1 parent f1b8781 commit c97f97f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct()
// 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[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function addData(array $result)
) {
$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
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ public function recordEditAccessInternals($table, $idOrRow, $newRecord = false,
*/
public function mayMakeShortcut()
{
return $this->getTSConfig()['options.']['enableBookmarks'] ?? false
return ($this->getTSConfig()['options.']['enableBookmarks'] ?? false)
&& !($this->getTSConfig()['options.']['mayNotCreateEditBookmarks'] ?? false);
}

Expand Down
10 changes: 5 additions & 5 deletions typo3/sysext/core/Classes/DataHandling/DataHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,7 @@ public function fillInFieldArray($table, $id, $fieldArray, $incomingFieldArray,
$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
);
}
Expand Down Expand Up @@ -2449,9 +2449,9 @@ protected function getUniqueCountStatement(
$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(
Expand Down Expand Up @@ -5310,7 +5310,7 @@ public function versionizeRecord($table, $id, $label, $delete = false)
}

// 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getCapabilities()
*/
public function hasCapability($capability)
{
return $this->capabilities & $capability == $capability;
return ($this->capabilities & $capability) == $capability;
}

/*******************
Expand Down
4 changes: 2 additions & 2 deletions typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ protected function version_swap($table, $id, $swapWith, bool $swapIntoWS, DataHa
$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');
Expand All @@ -832,7 +832,7 @@ protected function version_swap($table, $id, $swapWith, bool $swapIntoWS, DataHa
$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');
Expand Down

0 comments on commit c97f97f

Please sign in to comment.