Skip to content

Commit

Permalink
[BUGFIX] Fix broken additional fields for garbarge collection task
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
NeoBlack authored and maddy2101 committed Jun 9, 2018
1 parent f3229ad commit b76ff91
Showing 1 changed file with 5 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
*/
class IpAnonymizationAdditionalFieldProvider implements AdditionalFieldProviderInterface
{
/**
* @var array Default number of days by table
*/
protected $defaultNumberOfDays = [];

/**
* Add additional fields
*
Expand Down Expand Up @@ -78,10 +73,6 @@ protected function getTableAdditionalField(array &$taskInfo, $task, \TYPO3\CMS\S
$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',
Expand All @@ -102,22 +93,14 @@ protected function getTableAdditionalField(array &$taskInfo, $task, \TYPO3\CMS\S
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',
Expand All @@ -138,13 +121,9 @@ protected function getNumberOfDaysAdditionalField(array &$taskInfo, $task, \TYPO
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;
}
}
Expand Down

0 comments on commit b76ff91

Please sign in to comment.