[TASK] Update UC in recycler only once per action 41/55641/2
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Fri, 9 Feb 2018 23:36:15 +0000 (00:36 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 10 Feb 2018 18:40:51 +0000 (19:40 +0100)
The UC of a backend user is now updated only once per request, if there
are actual changes.

Resolves: #83839
Releases: master, 8.7
Change-Id: I859f8b2cc94b6254251ecf639222201cbf57f1ad
Reviewed-on: https://review.typo3.org/55641
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php

index c898ffd..ea5c061 100644 (file)
@@ -75,16 +75,18 @@ class RecyclerAjaxController
         // Determine the scripts to execute
         switch ($this->conf['action']) {
             case 'getTables':
-                $this->setDataInSession('depthSelection', $this->conf['depth']);
+                $this->setDataInSession(['depthSelection' => $this->conf['depth']]);
 
                 /* @var $model Tables */
                 $model = GeneralUtility::makeInstance(Tables::class);
                 $content = $model->getTables($this->conf['startUid'], $this->conf['depth']);
                 break;
             case 'getDeletedRecords':
-                $this->setDataInSession('tableSelection', $this->conf['table']);
-                $this->setDataInSession('depthSelection', $this->conf['depth']);
-                $this->setDataInSession('resultLimit', $this->conf['limit']);
+                $this->setDataInSession([
+                    'tableSelection' => $this->conf['table'],
+                    'depthSelection' => $this->conf['depth'],
+                    'resultLimit' => $this->conf['limit'],
+                ]);
 
                 /* @var $model DeletedRecords */
                 $model = GeneralUtility::makeInstance(DeletedRecords::class);
@@ -154,14 +156,15 @@ class RecyclerAjaxController
     /**
      * Sets data in the session of the current backend user.
      *
-     * @param string $identifier The identifier to be used to set the data
-     * @param string $data The data to be stored in the session
+     * @param array $data The data to be stored in the session
      */
-    protected function setDataInSession($identifier, $data)
+    protected function setDataInSession(array $data)
     {
         $beUser = $this->getBackendUser();
-        $beUser->uc['tx_recycler'][$identifier] = $data;
-        $beUser->writeUC();
+        if (!empty(array_diff_assoc($data, $beUser->uc['tx_recycler']))) {
+            $beUser->uc['tx_recycler'] = array_merge($beUser->uc['tx_recycler'], $data);
+            $beUser->writeUC();
+        }
     }
 
     /**