[BUGFIX] Fix broken additional fields for garbarge collection task 65/57165/3
authorFrank Naegler <frank.naegler@typo3.org>
Thu, 7 Jun 2018 09:41:17 +0000 (11:41 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 9 Jun 2018 21:28:51 +0000 (23:28 +0200)
The new IpAnonymizationAdditionalFieldProvider introduced the same
JavaScript variable which breaks the garbage collection task.
The JavaScript initialization has been removed and the field provider
simplified.

Resolves: #85068
Releases: master, 8.7, 7.6
Change-Id: Ibb307ee37d6fea33a721373bdc50bbbd3fee1453
Reviewed-on: https://review.typo3.org/57165
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/scheduler/Classes/Task/IpAnonymizationAdditionalFieldProvider.php

index 0d7b373..a7ad36b 100644 (file)
@@ -24,11 +24,6 @@ use TYPO3\CMS\Scheduler\AdditionalFieldProviderInterface;
 class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderInterface
 {
     /**
-     * @var array Default number of days by table
-     */
-    protected $defaultNumberOfDays = [];
-
-    /**
      * Add additional fields
      *
      * @param array $taskInfo Reference to the array containing the info used in the add/edit form
@@ -78,10 +73,6 @@ class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderI
         $fieldHtml = [];
         // Add table drop down html
         $fieldHtml[] = '<select class="form-control" name="' . $fieldName . '" id="' . $fieldId . '">' . implode(LF, $options) . '</select>';
-        // Add js array for default 'number of days' values
-        $fieldHtml[] = '<script type="text/javascript">/*<![CDATA[*/<!--';
-        $fieldHtml[] = 'var defaultNumberOfDays = ' . json_encode($this->defaultNumberOfDays) . ';';
-        $fieldHtml[] = '// -->/*]]>*/</script>';
         $fieldConfiguration = [
             'code' => implode(LF, $fieldHtml),
             'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.ipAnonymization.table',
@@ -102,22 +93,14 @@ class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderI
     protected function getNumberOfDaysAdditionalField(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
     {
         $fieldId = 'scheduler_ipAnonymization_numberOfDays';
-        // Initialize selected fields
-        $disabled = '';
         if (empty($taskInfo[$fieldId])) {
-            if ($parentObject->CMD === 'add') {
-                // In case of new task, set to 180 days
-                $taskInfo[$fieldId] = 180;
-            } elseif ($parentObject->CMD === 'edit') {
-                // In case of editing the task, set to currently selected value
+            $taskInfo[$fieldId] = 180;
+            if (isset($task->numberOfDays)) {
                 $taskInfo[$fieldId] = $task->numberOfDays;
-                if ($task->numberOfDays === 0 && !isset($this->defaultNumberOfDays[$task->table])) {
-                    $disabled = ' disabled="disabled"';
-                }
             }
         }
         $fieldName = 'tx_scheduler[' . $fieldId . ']';
-        $fieldHtml = '<input class="form-control" type="text" ' . 'name="' . $fieldName . '" ' . 'id="' . $fieldId . '" ' . $disabled . 'value="' . (int)$taskInfo['scheduler_ipAnonymization_numberOfDays'] . '" ' . 'size="4">';
+        $fieldHtml = '<input class="form-control" type="text" ' . 'name="' . $fieldName . '" ' . 'id="' . $fieldId . '" ' . 'value="' . (int)$taskInfo[$fieldId] . '" ' . 'size="4">';
         $fieldConfiguration = [
             'code' => $fieldHtml,
             'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.ipAnonymization.numberOfDays',
@@ -138,13 +121,9 @@ class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderI
     protected function getMaskAdditionalField(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
     {
         $fieldId = 'scheduler_ipAnonymization_mask';
-        // Initialize selected fields
         if (empty($taskInfo[$fieldId])) {
-            if ($parentObject->CMD === 'add') {
-                // In case of new task, set to 180 days
-                $taskInfo[$fieldId] = 2;
-            } elseif ($parentObject->CMD === 'edit') {
-                // In case of editing the task, set to currently selected value
+            $taskInfo[$fieldId] = 2;
+            if (isset($task->mask)) {
                 $taskInfo[$fieldId] = $task->mask;
             }
         }