[BUGFIX] Fix incorrect usage of nested ternary 91/42891/4
authorMarkus Klein <markus.klein@typo3.org>
Thu, 27 Aug 2015 16:09:53 +0000 (18:09 +0200)
committerAlexander Opitz <opitz.alexander@googlemail.com>
Fri, 4 Sep 2015 08:12:25 +0000 (10:12 +0200)
Ternaries are left associative in PHP, hence
$a ?: $b ?: $c  ===  ($a ?: $b) ?: $c  !==  $a ?: ($b ?: $c)

Mostly the latter case is used, hence we need parenthesis.

regex used to find occurrences:
^.+?[\s\n]+\?[^\:]*:[\s\n]+.+?[\s\n]+\?.+;$

Resolves: #69368
Releases: master, 6.2
Change-Id: I6235213cd921e7edfe0f4a3e96bde88ebdce3c99
Reviewed-on: http://review.typo3.org/42891
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Stephan Gro├čberndt <stephan@grossberndt.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
typo3/sysext/core/Classes/Controller/FileDumpController.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/Controller/ExtDirectEidController.php
typo3/sysext/frontend/Classes/Http/EidRequestHandler.php

index d93bdcc..e5fc5bb 100644 (file)
@@ -96,7 +96,7 @@ class FileDumpController implements ControllerInterface {
        protected function getGetOrPost(ServerRequestInterface $request, $parameter) {
                return isset($request->getParsedBody()[$parameter])
                        ? $request->getParsedBody()[$parameter]
-                       : isset($request->getQueryParams()[$parameter]) ? $request->getQueryParams()[$parameter] : NULL;
+                       : (isset($request->getQueryParams()[$parameter]) ? $request->getQueryParams()[$parameter] : NULL);
        }
 
 }
index 66296b1..90435e6 100755 (executable)
@@ -5571,7 +5571,7 @@ class ContentObjectRenderer {
                                $processingConfiguration['noScale'] = isset($fileArray['noScale.']) ? $this->stdWrap($fileArray['noScale'], $fileArray['noScale.']) : $fileArray['noScale'];
                                $processingConfiguration['additionalParameters'] = isset($fileArray['params.']) ? $this->stdWrap($fileArray['params'], $fileArray['params.']) : $fileArray['params'];
                                $processingConfiguration['frame'] = isset($fileArray['frame.']) ? (int)$this->stdWrap($fileArray['frame'], $fileArray['frame.']) : (int)$fileArray['frame'];
-                               $processingConfiguration['crop'] = isset($fileArray['crop.']) ? $this->stdWrap($fileArray['crop'], $fileArray['crop.']) : isset($fileArray['crop']) ? $fileArray['crop'] : NULL;
+                               $processingConfiguration['crop'] = isset($fileArray['crop.']) ? $this->stdWrap($fileArray['crop'], $fileArray['crop.']) : (isset($fileArray['crop']) ? $fileArray['crop'] : NULL);
                                // Possibility to cancel/force profile extraction
                                // see $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_stripProfileCommand']
                                if (isset($fileArray['stripProfile'])) {
index eb5c556..a8badb5 100644 (file)
@@ -58,7 +58,7 @@ class ExtDirectEidController implements ControllerInterface {
        public function processRequest(ServerRequestInterface $request) {
                $action = isset($request->getParsedBody()['action'])
                        ? $request->getParsedBody()['action']
-                       : isset($request->getQueryParams()['action']) ? $request->getQueryParams()['action'] : '';
+                       : (isset($request->getQueryParams()['action']) ? $request->getQueryParams()['action'] : '');
                if (!in_array($action, array('route', 'getAPI'), TRUE)) {
                        return NULL;
                }
index 06d7485..eb67627 100644 (file)
@@ -110,7 +110,7 @@ class EidRequestHandler implements RequestHandlerInterface {
        protected function dispatch($request) {
                $eID = isset($request->getParsedBody()['eID'])
                        ? $request->getParsedBody()['eID']
-                       : isset($request->getQueryParams()['eID']) ? $request->getQueryParams()['eID'] : '';
+                       : (isset($request->getQueryParams()['eID']) ? $request->getQueryParams()['eID'] : '');
 
                if (empty($eID) || !isset($GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include'][$eID])) {
                        return GeneralUtility::makeInstance(Response::class)->withStatus(404, 'eID not registered');