Commit baae0543 authored by Christian Kuhn's avatar Christian Kuhn Committed by Benni Mack
Browse files

[BUGFIX] Remaining PHP 8.0 fixes for acceptance tests

This fixes a bunch of PHP 8.0 warnings found by acceptance
testing. image processing and ext:scheduler are affected
for the main part.
This makes the ac test suite green with PHP 8.0. The
gitlab activation and another testing-framework raise
will follow with dedicated patches.
The patch brings an additional acceptance test for
install tool 'Environment->Image Processing' since
this worked well to nail lots of issues with
GifBuilder and friends.

Change-Id: Id22c7636da76778b75f087d20d7b7260cd2637ee
Resolves: #94333
Related: #94057
Releases: master
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69476


Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 24f9946c
......@@ -134,7 +134,7 @@ class ShortcutRepository
$groups = [];
foreach ($this->shortcuts as $shortcut) {
$groups[$shortcut['group']] = $this->shortcutGroups[$shortcut['group']];
$groups[$shortcut['group']] = $this->shortcutGroups[$shortcut['group']] ?? '';
}
return array_unique($groups);
......
......@@ -183,7 +183,7 @@ class LiveSearch
$queryBuilder->andWhere($this->userPermissions);
}
$orderBy = $GLOBALS['TCA'][$tableName]['ctrl']['sortby'] ?? $GLOBALS['TCA'][$tableName]['ctrl']['default_sortby'];
$orderBy = $GLOBALS['TCA'][$tableName]['ctrl']['sortby'] ?? $GLOBALS['TCA'][$tableName]['ctrl']['default_sortby'] ?? '';
foreach (QueryHelper::parseOrderBy((string)$orderBy) as $orderPair) {
[$fieldName, $order] = $orderPair;
$queryBuilder->addOrderBy($fieldName, $order);
......
......@@ -655,7 +655,7 @@ class BackendUtility
);
}
$foreignRow = self::getRecord($foreignTable, $foreignUid, $foreignTableTypeField);
if ($foreignRow[$foreignTableTypeField]) {
if ($foreignRow[$foreignTableTypeField] ?? false) {
$typeNum = $foreignRow[$foreignTableTypeField];
}
}
......@@ -2750,7 +2750,7 @@ class BackendUtility
$changed = 1;
}
} else {
if ((string)$settings[$key] !== (string)$CHANGED_SETTINGS[$key]) {
if ((string)($settings[$key] ?? '') !== (string)($CHANGED_SETTINGS[$key] ?? '')) {
$settings[$key] = $CHANGED_SETTINGS[$key];
$changed = 1;
}
......
......@@ -583,15 +583,15 @@ class GraphicalFunctions
[$spacing, $wordSpacing] = $this->calcWordSpacing($conf);
// Position
$txtPos = $this->txtPosition($conf, $workArea, $conf['BBOX']);
$theText = $conf['text'];
if ($conf['imgMap'] && is_array($conf['imgMap.'])) {
$theText = $conf['text'] ?? '';
if (($conf['imgMap'] ?? false) && is_array($conf['imgMap.'])) {
$this->addToMap($this->calcTextCordsForMap($conf['BBOX'][2], $txtPos, $conf['imgMap.']), $conf['imgMap.']);
}
if (!$conf['hideButCreateMap']) {
if (!($conf['hideButCreateMap'] ?? false)) {
// Font Color:
$cols = $this->convertColor($conf['fontColor']);
// NiceText is calculated
if (!$conf['niceText']) {
if (!($conf['niceText'] ?? false)) {
$Fcolor = imagecolorallocate($im, $cols[0], $cols[1], $cols[2]);
// antiAliasing is setup:
$Fcolor = $conf['antiAlias'] ? $Fcolor : -$Fcolor;
......@@ -600,7 +600,7 @@ class GraphicalFunctions
if ($spacing || $wordSpacing) {
$this->SpacedImageTTFText($im, $conf['fontSize'], $conf['angle'], $txtPos[0], $txtPos[1], $Fcolor, GeneralUtility::getFileAbsFileName($conf['fontFile']), $theText, $spacing, $wordSpacing, $conf['splitRendering.']);
} else {
$this->renderTTFText($im, $conf['fontSize'], $conf['angle'], $txtPos[0], $txtPos[1], $Fcolor, $conf['fontFile'], $theText, $conf['splitRendering.'], $conf);
$this->renderTTFText($im, $conf['fontSize'], $conf['angle'], $txtPos[0], $txtPos[1], $Fcolor, $conf['fontFile'], $theText, $conf['splitRendering.'] ?? [], $conf);
}
}
} else {
......@@ -613,7 +613,7 @@ class GraphicalFunctions
$fileColor = $tmpStr . '_colorNT.' . $this->gifExtension;
$fileMask = $tmpStr . '_maskNT.' . $this->gifExtension;
// Scalefactor
$sF = MathUtility::forceIntegerInRange($conf['niceText.']['scaleFactor'], 2, 5);
$sF = MathUtility::forceIntegerInRange(($conf['niceText.']['scaleFactor'] ?? 2), 2, 5);
$newW = (int)ceil($sF * imagesx($im));
$newH = (int)ceil($sF * imagesy($im));
// Make mask
......@@ -625,7 +625,7 @@ class GraphicalFunctions
if ($spacing || $wordSpacing) {
$this->SpacedImageTTFText($maskImg, $conf['fontSize'], $conf['angle'], $txtPos[0], $txtPos[1], $Fcolor, GeneralUtility::getFileAbsFileName($conf['fontFile']), $theText, $spacing, $wordSpacing, $conf['splitRendering.'], $sF);
} else {
$this->renderTTFText($maskImg, $conf['fontSize'], $conf['angle'], $txtPos[0], $txtPos[1], $Fcolor, $conf['fontFile'], $theText, $conf['splitRendering.'], $conf, $sF);
$this->renderTTFText($maskImg, $conf['fontSize'], $conf['angle'], $txtPos[0], $txtPos[1], $Fcolor, $conf['fontFile'], $theText, $conf['splitRendering.'] ?? [], $conf, $sF);
}
$this->ImageWrite($maskImg, $fileMask);
imagedestroy($maskImg);
......@@ -687,7 +687,8 @@ class GraphicalFunctions
$result[2] = $BB[0];
$result[3] = $BB[1];
$w = $workArea[2];
switch ($conf['align']) {
$alignment = $conf['align'] ?? '';
switch ($alignment) {
case 'right':
case 'center':
......@@ -703,7 +704,7 @@ class GraphicalFunctions
$result[1] = ceil($len2 * $factor + (1 - $factor) * $len1);
break;
}
switch ($conf['align']) {
switch ($alignment) {
case 'right':
break;
case 'center':
......@@ -733,7 +734,7 @@ class GraphicalFunctions
$sF = $this->getTextScalFactor($conf);
[$spacing, $wordSpacing] = $this->calcWordSpacing($conf, $sF);
$theText = $conf['text'];
$charInf = $this->ImageTTFBBoxWrapper($conf['fontSize'], $conf['angle'], $conf['fontFile'], $theText, $conf['splitRendering.'], $sF);
$charInf = $this->ImageTTFBBoxWrapper($conf['fontSize'], $conf['angle'], $conf['fontFile'], $theText, ($conf['splitRendering.'] ?? []), $sF);
$theBBoxInfo = $charInf;
if ($conf['angle']) {
$xArr = [$charInf[0], $charInf[2], $charInf[4], $charInf[6]];
......@@ -993,7 +994,7 @@ class GraphicalFunctions
// Initialize:
$colorIndex = $color;
// Set custom color if any (only when niceText is off):
if ($strCfg['color'] && $sF == 1) {
if (($strCfg['color'] ?? false) && $sF == 1) {
$cols = $this->convertColor($strCfg['color']);
$colorIndex = imagecolorallocate($im, $cols[0], $cols[1], $cols[2]);
$colorIndex = $color >= 0 ? $colorIndex : -$colorIndex;
......@@ -1009,8 +1010,8 @@ class GraphicalFunctions
imagettftext($im, $this->compensateFontSizeiBasedOnFreetypeDpi($sF * $strCfg['fontSize']), $angle, $x, $y, $colorIndex, $fontFile, $strCfg['str']);
// Calculate offset to apply:
$wordInf = imagettfbbox($this->compensateFontSizeiBasedOnFreetypeDpi($sF * $strCfg['fontSize']), $angle, GeneralUtility::getFileAbsFileName($strCfg['fontFile']), $strCfg['str']);
$x += $wordInf[2] - $wordInf[0] + (int)$splitRendering['compX'] + (int)$strCfg['xSpaceAfter'];
$y += $wordInf[5] - $wordInf[7] - (int)$splitRendering['compY'] - (int)$strCfg['ySpaceAfter'];
$x += $wordInf[2] - $wordInf[0] + (int)($splitRendering['compX'] ?? 0) + (int)($strCfg['xSpaceAfter'] ?? 0);
$y += $wordInf[5] - $wordInf[7] - (int)($splitRendering['compY'] ?? 0) - (int)($strCfg['ySpaceAfter'] ?? 0);
} else {
debug('cannot read file: ' . $fontFile, self::class . '::ImageTTFTextWrapper()');
}
......@@ -1166,8 +1167,8 @@ class GraphicalFunctions
*/
public function calcWordSpacing($conf, $scaleFactor = 1)
{
$spacing = (int)$conf['spacing'];
$wordSpacing = (int)$conf['wordSpacing'];
$spacing = (int)($conf['spacing'] ?? 0);
$wordSpacing = (int)($conf['wordSpacing'] ?? 0);
$wordSpacing = $wordSpacing ?: $spacing * 2;
$spacing *= $scaleFactor;
$wordSpacing *= $scaleFactor;
......@@ -1183,11 +1184,11 @@ class GraphicalFunctions
*/
public function getTextScalFactor($conf)
{
if (!$conf['niceText']) {
if (!($conf['niceText'] ?? false)) {
$sF = 1;
} else {
// NICETEXT::
$sF = MathUtility::forceIntegerInRange($conf['niceText.']['scaleFactor'], 2, 5);
$sF = MathUtility::forceIntegerInRange(($conf['niceText.']['scaleFactor'] ?? 2), 2, 5);
}
return $sF;
}
......@@ -1996,7 +1997,7 @@ class GraphicalFunctions
}
}
// ... and possibly recalculating the value
if (trim($cParts[1])) {
if (trim($cParts[1] ?? '')) {
$cParts[1] = trim($cParts[1]);
if ($cParts[1][0] === '*') {
$val = (float)substr($cParts[1], 1);
......@@ -2033,7 +2034,7 @@ class GraphicalFunctions
$result[3] = $BB[1];
$w = $workArea[2];
$h = $workArea[3];
$align = explode(',', $conf['align']);
$align = explode(',', $conf['align'] ?? ',');
$align[0] = strtolower(substr(trim($align[0]), 0, 1));
$align[1] = strtolower(substr(trim($align[1]), 0, 1));
switch ($align[0]) {
......@@ -2138,7 +2139,7 @@ class GraphicalFunctions
$info[1] = $data[1];
$frame = $this->addFrameSelection ? (int)$frame : 0;
if (!$params) {
$params = $this->cmds[$newExt];
$params = $this->cmds[$newExt] ?? '';
}
// Cropscaling:
if ($data['crs']) {
......
......@@ -68,7 +68,7 @@ class LocalCropScaleMaskHelper
$gifBuilder = GeneralUtility::makeInstance(GifBuilder::class);
$configuration = $targetFile->getProcessingConfiguration();
$configuration['additionalParameters'] = $this->modifyImageMagickStripProfileParameters($configuration['additionalParameters'], $configuration);
$configuration['additionalParameters'] = $this->modifyImageMagickStripProfileParameters((string)($configuration['additionalParameters'] ?? ''), $configuration);
if (empty($configuration['fileExtension'])) {
$configuration['fileExtension'] = $task->getTargetFileExtension();
......@@ -113,21 +113,21 @@ class LocalCropScaleMaskHelper
}
// Normal situation (no masking)
if (!(is_array($configuration['maskImages']) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_enabled'])) {
if (!(is_array($configuration['maskImages'] ?? null) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_enabled'])) {
// the result info is an array with 0=width,1=height,2=extension,3=filename
$result = $gifBuilder->imageMagickConvert(
$originalFileName,
$configuration['fileExtension'],
$configuration['width'],
$configuration['height'],
$configuration['width'] ?? '',
$configuration['height'] ?? '',
$configuration['additionalParameters'],
$configuration['frame'],
$configuration['frame'] ?? '',
$options
);
} else {
$targetFileName = $this->getFilenameForImageCropScaleMask($task);
$temporaryFileName = Environment::getPublicPath() . '/typo3temp/' . $targetFileName;
$maskImage = $configuration['maskImages']['maskImage'];
$maskImage = $configuration['maskImages']['maskImage'] ?? null;
$maskBackgroundImage = $configuration['maskImages']['backgroundImage'];
if ($maskImage instanceof FileInterface && $maskBackgroundImage instanceof FileInterface) {
$temporaryExtension = 'png';
......@@ -138,10 +138,10 @@ class LocalCropScaleMaskHelper
$tempFileInfo = $gifBuilder->imageMagickConvert(
$originalFileName,
$temporaryExtension,
$configuration['width'],
$configuration['height'],
$configuration['width'] ?? '',
$configuration['height'] ?? '',
$configuration['additionalParameters'],
$configuration['frame'],
$configuration['frame'] ?? '',
$options
);
if (is_array($tempFileInfo)) {
......@@ -219,24 +219,24 @@ class LocalCropScaleMaskHelper
{
$configuration = $processedFile->getProcessingConfiguration();
if ($configuration['useSample']) {
if ($configuration['useSample'] ?? false) {
$gifBuilder->scalecmd = '-sample';
}
$options = [];
if ($configuration['maxWidth']) {
if ($configuration['maxWidth'] ?? false) {
$options['maxW'] = $configuration['maxWidth'];
}
if ($configuration['maxHeight']) {
if ($configuration['maxHeight'] ?? false) {
$options['maxH'] = $configuration['maxHeight'];
}
if ($configuration['minWidth']) {
if ($configuration['minWidth'] ?? false) {
$options['minW'] = $configuration['minWidth'];
}
if ($configuration['minHeight']) {
if ($configuration['minHeight'] ?? false) {
$options['minH'] = $configuration['minHeight'];
}
$options['noScale'] = $configuration['noScale'];
$options['noScale'] = $configuration['noScale'] ?? null;
return $options;
}
......@@ -268,7 +268,7 @@ class LocalCropScaleMaskHelper
* @param array $configuration The TypoScript configuration of [IMAGE].file
* @return string
*/
protected function modifyImageMagickStripProfileParameters($parameters, array $configuration)
protected function modifyImageMagickStripProfileParameters(string $parameters, array $configuration)
{
// Strips profile information of image to save some space:
if (isset($configuration['stripProfile'])) {
......
......@@ -15,14 +15,18 @@
namespace TYPO3\CMS\Core\Resource\Processing;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Imaging\GraphicalFunctions;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Processes Local Images files
*/
class LocalImageProcessor implements ProcessorInterface
class LocalImageProcessor implements ProcessorInterface, LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* Returns TRUE if this processor can process the given task.
*
......@@ -72,15 +76,22 @@ class LocalImageProcessor implements ProcessorInterface
$task->setExecuted(true);
$imageDimensions = $this->getGraphicalFunctionsObject()->getImageDimensions($result['filePath']);
$task->getTargetFile()->setName($task->getTargetFileName());
$task->getTargetFile()->updateProperties(
['width' => $imageDimensions[0], 'height' => $imageDimensions[1], 'size' => filesize($result['filePath']), 'checksum' => $task->getConfigurationChecksum()]
);
$task->getTargetFile()->updateProperties([
'width' => $imageDimensions[0] ?? 0,
'height' => $imageDimensions[1] ?? 0,
'size' => filesize($result['filePath']),
'checksum' => $task->getConfigurationChecksum()
]);
$task->getTargetFile()->updateWithLocalFile($result['filePath']);
} else {
// Seems we have no valid processing result
$task->setExecuted(false);
}
} catch (\Exception $e) {
// @todo: Swallowing all exceptions including PHP warnings here is a bad idea.
// @todo: This should be restricted to more specific exceptions - if at all.
// @todo: For now, we at least log the situation.
$this->logger->error(sprintf('Processing task of image file'), ['exception' => $e]);
$task->setExecuted(false);
}
}
......
......@@ -806,7 +806,7 @@ class TypoScriptParser
// load default TypoScript
$defaultTypoScriptKey = implode('/', $filePointerPathParts) . '/';
if (in_array($defaultTypoScriptKey, $GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'], true)) {
$newString .= $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $includeType . '.']['defaultContentRendering'];
$newString .= $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $includeType . '.']['defaultContentRendering'] ?? '';
}
}
}
......
......@@ -1388,13 +1388,13 @@ class GeneralUtility
$tagName = (string)$options['parentTagMap'][$stackData['parentTagName']];
} elseif (MathUtility::canBeInterpretedAsInteger($tagName)) {
// If integer...;
if ($options['useNindex']) {
if ($options['useNindex'] ?? false) {
// If numeric key, prefix "n"
$tagName = 'n' . $tagName;
} else {
// Use special tag for num. keys:
$attr .= ' index="' . $tagName . '"';
$tagName = $options['useIndexTagForNum'] ?: 'numIndex';
$tagName = ($options['useIndexTagForNum'] ?? false) ?: 'numIndex';
}
} elseif (!empty($options['useIndexTagForAssoc'])) {
// Use tag for all associative keys:
......
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\InstallTool;
use TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester;
class EnvironmentCest extends AbstractCest
{
public function _before(BackendTester $I)
{
parent::_before($I);
$this->logIntoInstallTool($I);
$I->click('Environment');
$I->see('Environment', 'h1');
}
/**
* @param BackendTester $I
* @throws \Exception
*/
public function imageProcessingWorks(BackendTester $I)
{
$I->click('Test Images');
$I->waitForElementVisible('.modal-dialog');
// This is odd: The 'close' X upper right does not immediately work, even though waitForElementVisible below
// reports 'is ok' quickly. Worth a look of some JS jockey? We give the system some time to accumulate.
$I->wait(1);
$I->waitForElementVisible('.t3js-modal-close');
$I->click('.t3js-modal-close');
$I->waitForElementNotVisible('.modal-dialog');
}
}
......@@ -355,7 +355,7 @@ class EnvironmentController extends AbstractController
$textColor = imagecolorallocate($image, 233, 14, 91);
@imagettftext(
$image,
20 / 96.0 * 72, // As in compensateFontSizeBasedOnFreetypeDpi
20 / 96.0 * 72, // As in compensateFontSizeBasedOnFreetypeDpi
0,
10,
20,
......@@ -364,16 +364,19 @@ class EnvironmentController extends AbstractController
'Testing true type'
);
$outputFile = Environment::getPublicPath() . '/typo3temp/assets/images/installTool-' . StringUtility::getUniqueId('createTrueTypeFontTestImage') . '.gif';
imagegif($image, $outputFile);
@imagegif($image, $outputFile);
$fileExists = file_exists($outputFile);
if ($fileExists) {
GeneralUtility::fixPermissions($outputFile);
}
return $this->getImageTestResponse([
$result = [
'fileExists' => $fileExists,
'outputFile' => $outputFile,
'referenceFile' => Environment::getFrameworkBasePath() . '/install/Resources/Public/Images/TestReference/Font.gif',
]);
];
if ($fileExists) {
$result['outputFile'] = $outputFile;
}
return $this->getImageTestResponse($result);
}
/**
......@@ -991,7 +994,7 @@ class EnvironmentController extends AbstractController
{
$command = CommandUtility::imageMagickCommand('identify', '-version');
CommandUtility::exec($command, $result);
$string = $result[0];
$string = $result[0] ?? '';
$version = '';
if (!empty($string)) {
[, $version] = explode('Magick', $string);
......
......@@ -2587,7 +2587,7 @@ class DatabaseRecordList
}
$fieldConfig = $GLOBALS['TCA'][$table]['columns'][$fieldName]['config'];
$fieldType = $fieldConfig['type'];
$evalRules = $fieldConfig['eval'] ?: '';
$evalRules = ($fieldConfig['eval'] ?? false) ?: '';
$searchConstraint = $expressionBuilder->andX(
$expressionBuilder->comparison(
'LOWER(' . $queryBuilder->castFieldToTextType($fieldName) . ')',
......
......@@ -63,7 +63,8 @@ class SystemStatusUpdateTaskNotificationEmailField extends AbstractAdditionalFie
// build html for additional email field
$fieldName = $this->getFullFieldName('notificationEmail');
$fieldId = 'task_' . $fieldName;
$fieldHtml = '<textarea class="form-control" rows="5" cols="50" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" >' . htmlspecialchars($taskInfo[$fieldName]) . '</textarea>';
$fieldContent = $taskInfo[$fieldName] ?? '';
$fieldHtml = '<textarea class="form-control" rows="5" cols="50" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" >' . htmlspecialchars($fieldContent) . '</textarea>';
$additionalFields = [];
$additionalFields[$fieldId] = [
......@@ -76,7 +77,8 @@ class SystemStatusUpdateTaskNotificationEmailField extends AbstractAdditionalFie
// build html for additional mail all checkbox field
$fieldName = $this->getFullFieldName('notificationAll');
$fieldId = 'task_' . $fieldName;
$fieldHtml = '<input type="checkbox" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" value="1"' . ($taskInfo[$fieldName] ? ' checked="checked"' : '') . '>';
$fieldChecked = (bool)($taskInfo[$fieldName] ?? false);
$fieldHtml = '<input type="checkbox" name="tx_scheduler[' . $fieldName . ']" id="' . $fieldId . '" value="1"' . ($fieldChecked ? ' checked="checked"' : '') . '>';
$additionalFields[$fieldId] = [
'code' => $fieldHtml,
......
......@@ -631,7 +631,7 @@ class SchedulerModuleController
$table = [];
// Disable checkbox
$this->view->assign('task_disable', ($taskInfo['disable'] ? ' checked="checked"' : ''));
$this->view->assign('task_disable', (($taskInfo['disable'] ?? false) ? ' checked="checked"' : ''));
$this->view->assign('task_disable_label', 'LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:disable');
// Task class selector
......@@ -684,7 +684,7 @@ class SchedulerModuleController
$this->view->assign('multiple', ($taskInfo['multiple'] ? 'checked="checked"' : ''));
// Description
$this->view->assign('description', $taskInfo['description']);
$this->view->assign('description', $taskInfo['description'] ?? '');
// Display additional fields
$additionalFieldList = [];
......@@ -701,9 +701,9 @@ class SchedulerModuleController
$field = [];
$field['htmlClassName'] = $htmlClassName;
$field['code'] = $fieldInfo['code'];
$field['cshKey'] = $fieldInfo['cshKey'];
$field['cshLabel'] = $fieldInfo['cshLabel'];
$field['langLabel'] = $fieldInfo['label'];
$field['cshKey'] = $fieldInfo['cshKey'] ?? '';
$field['cshLabel'] = $fieldInfo['cshLabel'] ?? '';
$field['langLabel'] = $fieldInfo['label'] ?? '';
$field['fieldID'] = $fieldID;
$field['additionalFieldsStyle'] = $additionalFieldsStyle;
$field['browseButton'] = $this->getBrowseButton($fieldID, $fieldInfo);
......
......@@ -62,7 +62,7 @@ class FileStorageIndexingAdditionalFieldProvider implements AdditionalFieldProvi
$selected = '';
if ($task !== null && $task->storageUid === $storage->getUid()) {
$selected = ' selected="selected"';
} elseif ((int)$taskInfo['scheduler_fileStorageIndexing_storage'] === $storage->getUid()) {
} elseif ((int)($taskInfo['scheduler_fileStorageIndexing_storage'] ?? 0) === $storage->getUid()) {
$selected = ' selected="selected"';
}
$options[] = '<option value="' . $storage->getUid() . '" ' . $selected . ' >' . $storage->getName() . '</option>';
......
......@@ -59,14 +59,14 @@ class IpAnonymizationAdditionalFieldProvider extends AbstractAdditionalFieldProv
$options = [];
// Add an empty option on top if an existing task is configured
// with a table that can not be found in configuration anymore
if (!array_key_exists($task->table, $tableConfiguration) && $currentSchedulerModuleAction->equals(Action::EDIT)) {
if ($task && !array_key_exists($task->table, $tableConfiguration) && $currentSchedulerModuleAction->equals(Action::EDIT)) {
$options[] = '<option value="" selected="selected"></option>';
}
foreach ($tableConfiguration as $tableName => $configuration) {
if ($currentSchedulerModuleAction->equals(Action::ADD) && empty($options)) {
// Select first table by default if adding a new task
$options[] = '<option value="' . $tableName . '" selected="selected">' . $tableName . '</option>';
} elseif ($task->table === $tableName) {
} elseif ($task && $task->table === $tableName) {
// Select currently selected table
$options[] = '<option value="' . $tableName . '" selected="selected">' . $tableName . '</option>';
} else {
......
......@@ -109,21 +109,21 @@ class TableGarbageCollectionAdditionalFieldProvider extends AbstractAdditionalFi
$options = [];
// Add an empty option on top if an existing task is configured
// with a table that can not be found in configuration anymore
if (!array_key_exists($task->table, $tableConfiguration) && $currentSchedulerModuleAction->equals(Action::EDIT)) {
if ($task && !array_key_exists($task->table, $tableConfiguration) && $currentSchedulerModuleAction->equals(Action::EDIT)) {
$options[] = '<option value="" selected="selected"></option>';
}
foreach ($tableConfiguration as $tableName => $configuration) {
if ($currentSchedulerModuleAction->equals(Action::ADD) && empty($options)) {
// Select first table by default if adding a new task
$options[] = '<option value="' . $tableName . '" selected="selected">' . $tableName . '</option>';
} elseif ($task->table === $tableName) {
} elseif ($task && $task->table === $tableName) {
// Select currently selected table
$options[] = '<option value="' . $tableName . '" selected="selected">' . $tableName . '</option>';
} else {
$options[] = '<option value="' . $tableName . '">' . $tableName . '</option>';
}
}
$disabled = $task->allTables === true ? ' disabled="disabled"' : '';
$disabled = ($task && $task->allTables === true) ? ' disabled="disabled"' : '';
$fieldName = 'tx_scheduler[scheduler_tableGarbageCollection_table]';
$fieldId = 'task_tableGarbageCollection_table';
$fieldHtml = [];
......@@ -167,7 +167,7 @@ class TableGarbageCollectionAdditionalFieldProvider extends AbstractAdditionalFi
}
}
}