[TASK] Solved compatibility issues with 4.6, 4.7 12/24112/2
authorHelge Funk <helge.funk@gmail.com>
Fri, 27 Sep 2013 14:10:46 +0000 (16:10 +0200)
committerHelge Funk <helge.funk@gmail.com>
Fri, 27 Sep 2013 14:17:06 +0000 (16:17 +0200)
Fixes: #49447
Change-Id: Ic991b6e546e985006a4d557153a836e0dec020de
Reviewed-on: https://review.typo3.org/24112
Reviewed-by: Helge Funk
Tested-by: Helge Funk
Classes/MVC/Controller/AbstractController.php
Classes/MVC/Web/BackendRequestHandler.php
Classes/MVC/Web/FrontendRequestHandler.php
Classes/MVC/Web/Request.php [new file with mode: 0644]
Classes/Service/ActionSequence.php
Configuration/TypoScript/setup.txt

index 8377602..db724df 100644 (file)
@@ -306,7 +306,7 @@ abstract class Tx_LwEnetMultipleActionForms_MVC_Controller_AbstractController ex
         * @return void
         */
        public function persistArgumentsWithReferrerCheck(array $arguments) {
-               if (!$this->request->hasArgument('__referrer')) {
+               if (!$this->request->hasReferrerArgument()) {
                        return;
                }
 
@@ -512,8 +512,8 @@ abstract class Tx_LwEnetMultipleActionForms_MVC_Controller_AbstractController ex
                        }
                }
 
-               if ($this->request->hasArgument('__referrer')) {
-                       $referrer = $this->request->getArgument('__referrer');
+               if ($this->request->hasReferrerArgument()) {
+                       $referrer = $this->request->getReferrerArgument();
                        $this->forward($referrer['actionName'], $referrer['controllerName'], $referrer['extensionName'], $this->request->getArguments());
                }
 
index 602b918..eb28329 100644 (file)
@@ -66,7 +66,7 @@ class Tx_LwEnetMultipleActionForms_MVC_Web_BackendRequestHandler extends Tx_Extb
                        /** @var $response Tx_Extbase_MVC_Web_Response */
                $response = $this->objectManager->create('Tx_Extbase_MVC_Web_Response');
 
-               if ($this->request->hasArgument('__referrer')) {
+               if ($this->request->hasReferrerArgument()) {
                        $persistedControllerData = $this->sessionAdapter->load($this->request->getControllerObjectName());
                        if (count($persistedControllerData) > 0) {
                                foreach ($persistedControllerData['Arguments'] as $argumentName => $argumentValue) {
index 49d4434..8db204d 100644 (file)
@@ -73,16 +73,22 @@ class Tx_LwEnetMultipleActionForms_MVC_Web_FrontendRequestHandler extends Tx_Ext
                $requestHashService = $this->objectManager->get('Tx_Extbase_Security_Channel_RequestHashService'); // singleton
                $requestHashService->verifyRequest($this->request);
 
-               if ($this->isCacheable($this->request->getControllerName(), $this->request->getControllerActionName())) {
-                       $this->request->setIsCached(TRUE);
+               if (t3lib_utility_VersionNumber::convertVersionNumberToInteger(t3lib_extMgm::getExtensionVersion('extbase')) < t3lib_utility_VersionNumber::convertVersionNumberToInteger('4.7.0')) {
+                       $this->request->setIsCached(
+                               $this->isCacheable($this->request->getControllerName(), $this->request->getControllerActionName())
+                       );
                } else {
+                       $this->request->setIsCached(
+                               $this->extensionService->isActionCacheable(NULL, NULL, $this->request->getControllerName(), $this->request->getControllerActionName())
+                       );
+               }
+               if (!$this->request->isCached()) {
                        $contentObject = $this->configurationManager->getContentObject();
                        if ($contentObject->getUserObjectType() === tslib_cObj::OBJECTTYPE_USER) {
                                $contentObject->convertToUserIntObject();
                                // tslib_cObj::convertToUserIntObject() will recreate the object, so we have to stop the request here
                                return;
                        }
-                       $this->request->setIsCached(FALSE);
                }
                $response = $this->objectManager->create('Tx_Extbase_MVC_Web_Response');
 
@@ -90,7 +96,7 @@ class Tx_LwEnetMultipleActionForms_MVC_Web_FrontendRequestHandler extends Tx_Ext
                        // This commented debug is committed by purpose, please do net remove
                //debug($this->request->getArguments(), 'Incoming arguments', __FILE__, __LINE__);
 
-               if ($this->request->hasArgument('__referrer')) {
+               if ($this->request->hasReferrerArgument()) {
                        $persistedControllerData = $this->sessionAdapter->load($this->request->getControllerObjectName());
 
                                // Debug data coming from session
diff --git a/Classes/MVC/Web/Request.php b/Classes/MVC/Web/Request.php
new file mode 100644 (file)
index 0000000..998c49a
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Lars Trebing <lars.trebing@e-net.info>
+ *
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+
+/**
+ *
+ *
+ * @package lw_enet_multiple_action_forms
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ *
+ */
+class Tx_LwEnetMultipleActionForms_MVC_Web_Request extends Tx_Extbase_MVC_Web_Request {
+
+       /**
+        * Checks if the __referrer argument exists (is set) and of type array
+        *
+        * @return boolean TRUE if the referrer is set and of type array, otherwise FALSE
+        */
+       public function hasReferrerArgument() {
+               if (t3lib_utility_VersionNumber::convertVersionNumberToInteger(t3lib_extMgm::getExtensionVersion('extbase')) < t3lib_utility_VersionNumber::convertVersionNumberToInteger('1.4.0')) {
+                       return $this->hasArgument('__referrer') && is_array($this->getArgument('__referrer'));
+               } else {
+                       return is_array($this->getInternalArgument('__referrer'));
+               }
+       }
+
+       /**
+        * Returns the value of the __referrer argument
+        *
+        * @return mixed Value of the argument, or NULL if not set or not an array
+        */
+       public function getReferrerArgument() {
+               if (t3lib_utility_VersionNumber::convertVersionNumberToInteger(t3lib_extMgm::getExtensionVersion('extbase')) < t3lib_utility_VersionNumber::convertVersionNumberToInteger('1.4.0')) {
+                       $referrer = $this->hasArgument('__referrer') ? $this->getArgument('__referrer') : NULL;
+               } else {
+                       $referrer = $this->getInternalArgument('__referrer');
+               }
+               if (is_array($referrer)) {
+                       return $referrer;
+               } else {
+                       return NULL;
+               }
+       }
+
+}
+?>
\ No newline at end of file
index c7bc98a..fe94919 100644 (file)
@@ -241,8 +241,8 @@ class Tx_LwEnetMultipleActionForms_Service_ActionSequence implements t3lib_Singl
         */
        public function getReferrerAction() {
                $referrer = NULL;
-               if ($this->request->hasArgument('__referrer')) {
-                       $referrer = $this->request->getArgument('__referrer');
+               if ($this->request->hasReferrerArgument()) {
+                       $referrer = $this->request->getReferrerArgument();
                }
                return $this->getActionByActionName($referrer['actionName']);
        }
index 244621d..2abb527 100644 (file)
@@ -3,6 +3,9 @@ config.tx_extbase {
                Tx_LwEnetMultipleActionForms_Session_AdapterInterface {
                        className = Tx_LwEnetMultipleActionForms_Session_Typo3SessionAdapter
                }
+               Tx_Extbase_MVC_Web_Request {
+                       className = Tx_LwEnetMultipleActionForms_MVC_Web_Request
+               }
                Tx_Extbase_Validation_ValidatorResolver {
                        className = Tx_LwEnetMultipleActionForms_Validation_ValidatorResolver
                }