[BUGFIX] EXT:Scheduler: Update storage index saves correct storage 36/51036/4
authorMichael Oehlhof <typo3@oehlhof.de>
Fri, 23 Dec 2016 08:46:38 +0000 (09:46 +0100)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 18 Aug 2017 14:24:28 +0000 (16:24 +0200)
When creating an "update storage index" task, now the selected storage
is saved correct.

Resolves: #67241
Releases: master
Change-Id: I371c5aa882ff78095536f1e413d58850ccb46c2b
Reviewed-on: https://review.typo3.org/51036
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/scheduler/Classes/Task/FileStorageIndexingAdditionalFieldProvider.php

index 2e2242b..3f870fb 100644 (file)
@@ -33,7 +33,7 @@ class FileStorageIndexingAdditionalFieldProvider implements \TYPO3\CMS\Scheduler
         if ($task !== null && !$task instanceof FileStorageIndexingTask) {
             throw new \InvalidArgumentException('Task not of type FileStorageExtractionTask', 1384275696);
         }
-        $additionalFields['scheduler_fileStorageIndexing_storage'] = $this->getAllStoragesField($task);
+        $additionalFields['scheduler_fileStorageIndexing_storage'] = $this->getAllStoragesField($task, $taskInfo);
         return $additionalFields;
     }
 
@@ -41,19 +41,22 @@ class FileStorageIndexingAdditionalFieldProvider implements \TYPO3\CMS\Scheduler
      * Add a select field of available storages.
      *
      * @param FileStorageIndexingTask $task When editing, reference to the current task object. NULL when adding.
+     * @param array $taskInfo
      * @return array Array containing all the information pertaining to the additional fields
      */
-    protected function getAllStoragesField(FileStorageIndexingTask $task = null)
+    protected function getAllStoragesField(FileStorageIndexingTask $task = null, $taskInfo)
     {
         /** @var \TYPO3\CMS\Core\Resource\ResourceStorage[] $storages */
         $storages = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\StorageRepository::class)->findAll();
         $options = [];
         foreach ($storages as $storage) {
-            if ($task != null && $task->storageUid === $storage->getUid()) {
-                $options[] = '<option value="' . $storage->getUid() . '" selected="selected">' . $storage->getName() . '</option>';
-            } else {
-                $options[] = '<option value="' . $storage->getUid() . '">' . $storage->getName() . '</option>';
+            $selected = '';
+            if ($task !== null && $task->storageUid === $storage->getUid()) {
+                $selected =' selected="selected"';
+            } elseif ((int)$taskInfo['scheduler_fileStorageIndexing_storage'] === $storage->getUid()) {
+                $selected =' selected="selected"';
             }
+            $options[] = '<option value="' . $storage->getUid() . '" ' . $selected . ' >' . $storage->getName() . '</option>';
         }
 
         $fieldName = 'tx_scheduler[scheduler_fileStorageIndexing_storage]';