Commit 169eb06e authored by crell's avatar crell Committed by Benni Mack
Browse files

[BUGFIX] Resolve PHP 8 issues in acceptance tests

PHP 8 promotes a lot of notices (previously ignored) to warnings.
That means they can no longer be ignored.

Resolves: #94057
Releases: master
Change-Id: I37de1b7e8e31eb2be78b8e90af015bc88e121791
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69012


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 29ec4f38
......@@ -124,15 +124,19 @@ class Clipboard
{
$userTsConfig = $this->getBackendUser()->getTSConfig();
// Get data
$clipData = $this->getBackendUser()->getModuleData('clipboard', $userTsConfig['options.']['saveClipboard'] ? '' : 'ses');
$clipData = $this->getBackendUser()->getModuleData('clipboard', !empty($userTsConfig['options.']['saveClipboard']) ? '' : 'ses') ?: [];
$clipData += ['normal' => []];
$this->numberTabs = MathUtility::forceIntegerInRange((int)($userTsConfig['options.']['clipboardNumberPads'] ?? 3), 0, 20);
// Resets/reinstates the clipboard pads
$this->clipData['normal'] = is_array($clipData['normal']) ? $clipData['normal'] : [];
$this->clipData['normal'] = is_array($clipData['normal']) ? $clipData['normal']: [];
for ($a = 1; $a <= $this->numberTabs; $a++) {
$this->clipData['tab_' . $a] = is_array($clipData['tab_' . $a]) ? $clipData['tab_' . $a] : [];
$index = 'tab_' . $a;
$this->clipData[$index] = is_iterable($clipData[$index] ?? null) ? $clipData[$index] : [];
}
// Setting the current pad pointer ($this->current))
$this->clipData['current'] = ($this->current = isset($this->clipData[$clipData['current']]) ? $clipData['current'] : 'normal');
$current = $clipData['current'] ?? '';
$this->current = isset($this->clipData[$current]) ? $current : 'normal';
$this->clipData['current'] = $this->current;
}
/**
......@@ -159,35 +163,35 @@ class Clipboard
*/
public function setCmd($cmd)
{
if (is_array($cmd['el'])) {
foreach ($cmd['el'] as $k => $v) {
if ($this->current === 'normal') {
unset($this->clipData['normal']);
}
if ($v) {
$this->clipData[$this->current]['el'][$k] = $v;
} else {
$this->removeElement($k);
}
$this->changed = 1;
$cmd['el'] ??= [];
$cmd['el'] = is_iterable($cmd['el']) ? $cmd['el'] : [];
foreach ($cmd['el'] as $k => $v) {
if ($this->current === 'normal') {
unset($this->clipData['normal']);
}
if ($v) {
$this->clipData[$this->current]['el'][$k] = $v;
} else {
$this->removeElement($k);
}
$this->changed = 1;
}
// Change clipboard pad (if not locked to normal)
if ($cmd['setP']) {
if ($cmd['setP'] ?? false) {
$this->setCurrentPad($cmd['setP']);
}
// Remove element (value = item ident: DB; '[tablename]|[uid]' FILE: '_FILE|[shortmd5 hash of path]'
if ($cmd['remove']) {
if ($cmd['remove'] ?? false) {
$this->removeElement($cmd['remove']);
$this->changed = 1;
}
// Remove all on current pad (value = pad-ident)
if ($cmd['removeAll']) {
if ($cmd['removeAll'] ?? false) {
$this->clipData[$cmd['removeAll']] = [];
$this->changed = 1;
}
// Set copy mode of the tab
if (isset($cmd['setCopyMode'])) {
if ($cmd['setCopyMode'] ?? false) {
$this->clipData[$this->current]['mode'] = $cmd['setCopyMode'] ? 'copy' : '';
$this->changed = 1;
}
......
......@@ -188,8 +188,8 @@ class TranslationConfigurationProvider
return [
'table' => $table,
'uid' => $uid,
'CType' => $row['CType'],
'sys_language_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']],
'CType' => $row['CType'] ?? '',
'sys_language_uid' => $row[$GLOBALS['TCA'][$table]['ctrl']['languageField'] ?? null] ?? null,
'translations' => $translations,
'excessive_translations' => $translationsErrors
];
......
......@@ -452,7 +452,7 @@ class BackendController
$startModule = $beUser->uc['startModuleOnFirstLogin'];
unset($beUser->uc['startModuleOnFirstLogin']);
$beUser->writeUC();
} elseif ($this->moduleLoader->checkMod($beUser->uc['startModule']) !== 'notFound') {
} elseif ($this->moduleLoader->checkMod($beUser->uc['startModule'] ?? '') !== 'notFound') {
$startModule = $beUser->uc['startModule'];
} else {
$startModule = $this->determineFirstAvailableBackendModule();
......
......@@ -376,13 +376,14 @@ class NewContentElementController
foreach ($wizards as $groupKey => $wizardGroup) {
$groupKey = rtrim($groupKey, '.');
$showItems = GeneralUtility::trimExplode(',', $wizardGroup['show'], true);
$showItems = GeneralUtility::trimExplode(',', $wizardGroup['show'] ?? '', true);
$showAll = in_array('*', $showItems, true);
$groupItems = [];
if (is_array($appendWizards[$groupKey . '.']['elements.'])) {
$wizardElements = array_merge((array)$wizardGroup['elements.'], $appendWizards[$groupKey . '.']['elements.']);
$appendWizardElements = $appendWizards[$groupKey . '.']['elements.'] ?? null;
if (is_array($appendWizardElements)) {
$wizardElements = array_merge((array)($wizardGroup['elements.'] ?? []), $appendWizardElements);
} else {
$wizardElements = $wizardGroup['elements.'];
$wizardElements = $wizardGroup['elements.'] ?? [];
}
if (is_array($wizardElements)) {
foreach ($wizardElements as $itemKey => $itemConf) {
......@@ -412,8 +413,9 @@ class NewContentElementController
*/
protected function getAppendWizards(array $wizardElements): array
{
if (is_array($GLOBALS['TBE_MODULES_EXT']['xMOD_db_new_content_el']['addElClasses'])) {
foreach ($GLOBALS['TBE_MODULES_EXT']['xMOD_db_new_content_el']['addElClasses'] as $class => $path) {
$classes = $GLOBALS['TBE_MODULES_EXT']['xMOD_db_new_content_el']['addElClasses'] ?? [];
if (is_array($classes)) {
foreach ($classes as $class => $path) {
if (!class_exists($class) && file_exists($path)) {
require_once $path;
}
......@@ -440,7 +442,7 @@ class NewContentElementController
{
$itemConf['title'] = $this->getLanguageService()->sL($itemConf['title']);
$itemConf['description'] = $this->getLanguageService()->sL($itemConf['description']);
$itemConf['saveAndClose'] = (bool)$itemConf['saveAndClose'];
$itemConf['saveAndClose'] = (bool)($itemConf['saveAndClose'] ?? false);
$itemConf['tt_content_defValues'] = $itemConf['tt_content_defValues.'];
unset($itemConf['tt_content_defValues.']);
return $itemConf;
......
......@@ -467,7 +467,7 @@ class EditDocumentController
$this->compileStoreData();
// Backend user session data of this module
$this->docDat = $this->getBackendUser()->getModuleData('FormEngine', 'ses');
$this->docHandler = $this->docDat[0];
$this->docHandler = $this->docDat[0] ?? [];
// Close document if a request for closing the document has been sent
if ((int)$this->closeDoc > self::DOCUMENT_CLOSE_MODE_DEFAULT) {
......@@ -823,8 +823,8 @@ class EditDocumentController
protected function getPreviewUrlParameters(int $previewPageId): string
{
$linkParameters = [];
$table = $this->previewData['table'] ?: $this->firstEl['table'];
$recordId = $this->previewData['id'] ?: $this->firstEl['uid'];
$table = ($this->previewData['table'] ?? '') ?: ($this->firstEl['table'] ?? '');
$recordId = ($this->previewData['id'] ?? '') ?: ($this->firstEl['uid'] ?? '');
$previewConfiguration = BackendUtility::getPagesTSconfig($previewPageId)['TCEMAIN.']['preview.'][$table . '.'] ?? [];
$recordArray = BackendUtility::getRecord($table, $recordId);
......@@ -898,8 +898,8 @@ class EditDocumentController
*/
protected function getPreviewUrlAnchorSection(): string
{
$table = $this->previewData['table'] ?: $this->firstEl['table'];
$recordId = $this->previewData['id'] ?: $this->firstEl['uid'];
$table = ($this->previewData['table'] ?? '') ?: ($this->firstEl['table'] ?? '');
$recordId = ($this->previewData['id'] ?? '') ?: ($this->firstEl['uid'] ?? '');
return $table === 'tt_content' ? '#c' . (int)$recordId : '';
}
......@@ -912,8 +912,8 @@ class EditDocumentController
protected function getPreviewPageId(): int
{
$previewPageId = 0;
$table = $this->previewData['table'] ?: $this->firstEl['table'];
$recordId = $this->previewData['id'] ?: $this->firstEl['uid'];
$table = ($this->previewData['table'] ?? '') ?: ($this->firstEl['table'] ?? '');
$recordId = ($this->previewData['id'] ?? '') ?: ($this->firstEl['uid'] ?? '');
$pageId = $this->popViewId ?: $this->viewId;
if ($table === 'pages') {
......@@ -1258,7 +1258,7 @@ class EditDocumentController
// Show buttons when table is not read-only
if (
!$this->errorC
&& !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly']
&& !($GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly'] ?? false)
) {
$this->registerSaveButtonToButtonBar($buttonBar, ButtonBar::BUTTON_POSITION_LEFT, 2);
$this->registerViewButtonToButtonBar($buttonBar, ButtonBar::BUTTON_POSITION_LEFT, 3);
......@@ -1310,7 +1310,7 @@ class EditDocumentController
{
$allowInconsistentLanguageHandling = BackendUtility::getPagesTSconfig(
$this->pageinfo['uid']
)['mod']['web_layout']['allowInconsistentLanguageHandling'];
)['mod']['web_layout']['allowInconsistentLanguageHandling'] ?? ['value' => '0'];
return $allowInconsistentLanguageHandling['value'] === '1';
}
......@@ -2170,7 +2170,7 @@ class EditDocumentController
*/
protected function localizationRedirect(ServerRequestInterface $request): ?ResponseInterface
{
$justLocalized = $request->getQueryParams()['justLocalized'];
$justLocalized = $request->getQueryParams()['justLocalized'] ?? null;
if (empty($justLocalized)) {
return null;
......
......@@ -157,11 +157,12 @@ class TreeController
$this->useNavTitle = (bool)($userTsConfig['options.']['pageTree.']['showNavTitle'] ?? false);
$this->showMountPathAboveMounts = (bool)($userTsConfig['options.']['pageTree.']['showPathAboveMounts'] ?? false);
$backendUserConfiguration = GeneralUtility::makeInstance(BackendUserConfiguration::class);
$this->expandedState = $backendUserConfiguration->get('BackendComponents.States.Pagetree');
if (is_object($this->expandedState) && is_object($this->expandedState->stateHash)) {
$this->expandedState = (array)$this->expandedState->stateHash;
$backendUserPageTreeState = $backendUserConfiguration->get('BackendComponents.States.Pagetree');
if (is_object($backendUserPageTreeState) && is_object($backendUserPageTreeState->stateHash)) {
$this->expandedState = (array)$backendUserPageTreeState->stateHash;
} else {
$this->expandedState = $this->expandedState['stateHash'] ?: [];
$stateHash = $backendUserPageTreeState['stateHash'] ?? [];
$this->expandedState = is_array($stateHash) ? $stateHash : [];
}
}
......@@ -403,7 +404,7 @@ class TreeController
'tip' => htmlspecialchars($tooltip),
'icon' => $icon->getIdentifier(),
'name' => $visibleText,
'type' => (int)$page['doktype'],
'type' => (int)($page['doktype'] ?? 0),
'nameSourceField' => $nameSourceField,
'mountPoint' => $entryPoint,
'workspaceId' => !empty($page['t3ver_oid']) ? $page['t3ver_oid'] : $pageId,
......
......@@ -186,15 +186,15 @@ class SimpleDataHandlerController
// Creating DataHandler object
$this->tce = GeneralUtility::makeInstance(DataHandler::class);
// Configuring based on user prefs.
if ($beUser->uc['copyLevels']) {
if ($beUser->uc['copyLevels'] ?? false) {
// Set to number of page-levels to copy.
$this->tce->copyTree = MathUtility::forceIntegerInRange($beUser->uc['copyLevels'], 0, 100);
}
if ($beUser->uc['neverHideAtCopy']) {
if ($beUser->uc['neverHideAtCopy'] ?? false) {
$this->tce->neverHideAtCopy = 1;
}
// Reverse order.
if ($this->flags['reverseOrder']) {
if ($this->flags['reverseOrder'] ?? false) {
$this->tce->reverseOrder = 1;
}
}
......
......@@ -157,7 +157,7 @@ abstract class AbstractNode implements NodeInterface, LoggerAwareInterface
{
$validationRules = [];
if (!empty($config['eval'])) {
$evalList = GeneralUtility::trimExplode(',', $config['eval'], true);
$evalList = GeneralUtility::trimExplode(',', $config['eval'] ?? '', true);
foreach ($evalList as $evalType) {
$validationRules[] = [
'type' => $evalType,
......
......@@ -56,7 +56,7 @@ class FlexFormElementContainer extends AbstractContainer
continue;
}
if ($flexFormFieldArray['type'] === 'array') {
if (($flexFormFieldArray['type'] ?? null) === 'array') {
// Section
if (empty($flexFormFieldArray['section'])) {
$resultArray['html'] = LF . 'Section expected at ' . $flexFormFieldName . ' but not found';
......@@ -76,11 +76,11 @@ class FlexFormElementContainer extends AbstractContainer
'fieldConf' => [
'label' => $languageService->sL(trim($flexFormFieldArray['label'])),
'config' => $flexFormFieldArray['config'],
'children' => $flexFormFieldArray['children'],
'onChange' => $flexFormFieldArray['onChange'],
'children' => $flexFormFieldArray['children'] ?? [],
'onChange' => $flexFormFieldArray['onChange'] ?? '',
],
'fieldChangeFunc' => $parameterArray['fieldChangeFunc'],
'label' => $parameterArray['label'],
'label' => $parameterArray['label'] ?? '',
];
if (isset($flexFormFieldArray['description']) && !empty($flexFormFieldArray['description'])) {
......
......@@ -66,7 +66,7 @@ class FlexFormNoTabsContainer extends AbstractContainer
// Assemble key for loading the correct CSH file
// @todo: what is that good for? That is for the title of single elements ... see FlexFormElementContainer!
$dsPointerFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['ds_pointerField'], true);
$dsPointerFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['ds_pointerField'] ?? '', true);
$parameterArray['_cshKey'] = $table . '.' . $fieldName;
foreach ($dsPointerFields as $key) {
if (is_string($row[$key]) && $row[$key] !== '') {
......
......@@ -72,7 +72,7 @@ class FlexFormTabsContainer extends AbstractContainer
// Assemble key for loading the correct CSH file
// @todo: what is that good for? That is for the title of single elements ... see FlexFormElementContainer!
$dsPointerFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['ds_pointerField'], true);
$dsPointerFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['ds_pointerField'] ?? '', true);
$parameterArray['_cshKey'] = $table . '.' . $fieldName;
foreach ($dsPointerFields as $key) {
if (is_string($row[$key]) && $row[$key] !== '') {
......@@ -101,8 +101,8 @@ class FlexFormTabsContainer extends AbstractContainer
$tabElements[] = [
'label' => !empty(trim($sheetDataStructure['ROOT']['sheetTitle'])) ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetTitle'])) : $sheetName,
'content' => $childReturn['html'],
'description' => trim($sheetDataStructure['ROOT']['sheetDescription']) ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetDescription'])) : '',
'linkTitle' => trim($sheetDataStructure['ROOT']['sheetShortDescr']) ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetShortDescr'])) : '',
'description' => trim($sheetDataStructure['ROOT']['sheetDescription'] ?? '') ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetDescription'])) : '',
'linkTitle' => trim($sheetDataStructure['ROOT']['sheetShortDescr'] ?? '') ? $languageService->sL(trim($sheetDataStructure['ROOT']['sheetShortDescr'])) : '',
];
}
$resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $childReturn, false);
......
......@@ -122,7 +122,7 @@ class InlineControlContainer extends AbstractContainer
$foreign_table = $config['foreign_table'];
$isReadOnly = isset($config['readOnly']) && $config['readOnly'];
$language = 0;
$languageFieldName = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
$languageFieldName = $GLOBALS['TCA'][$table]['ctrl']['languageField'] ?? '';
if (BackendUtility::isTableLocalizable($table)) {
$language = isset($row[$languageFieldName][0]) ? (int)$row[$languageFieldName][0] : (int)$row[$languageFieldName];
}
......@@ -195,10 +195,10 @@ class InlineControlContainer extends AbstractContainer
$uniqueMax = 0;
$uniqueIds = [];
if ($config['foreign_unique']) {
if ($config['foreign_unique'] ?? false) {
// Add inlineData['unique'] with JS unique configuration
// @todo: Improve validation and throw an exception if type is neither select nor group here
$type = $config['selectorOrUniqueConfiguration']['config']['type'] === 'select' ? 'select' : 'groupdb';
$type = ($config['selectorOrUniqueConfiguration']['config']['type'] ?? '') === 'select' ? 'select' : 'groupdb';
foreach ($parameterArray['fieldConf']['children'] as $child) {
// Determine used unique ids, skip not localized records
if (!$child['isInlineDefaultLanguageRecordInLocalizedParentContext']) {
......@@ -225,20 +225,20 @@ class InlineControlContainer extends AbstractContainer
$uniqueIds[$child['databaseRow']['uid']] = $value;
}
}
$possibleRecords = $config['selectorOrUniquePossibleRecords'];
$possibleRecords = $config['selectorOrUniquePossibleRecords'] ?? [];
$possibleRecordsUidToTitle = [];
foreach ($possibleRecords as $possibleRecord) {
$possibleRecordsUidToTitle[$possibleRecord[1]] = $possibleRecord[0];
}
$uniqueMax = $config['appearance']['useCombination'] || empty($possibleRecords) ? -1 : count($possibleRecords);
$uniqueMax = ($config['appearance']['useCombination'] ?? false) || empty($possibleRecords) ? -1 : count($possibleRecords);
$this->inlineData['unique'][$nameObject . '-' . $foreign_table] = [
'max' => $uniqueMax,
'used' => $uniqueIds,
'type' => $type,
'table' => $foreign_table,
'elTable' => $config['selectorOrUniqueConfiguration']['foreignTable'],
'field' => $config['foreign_unique'],
'selector' => $config['selectorOrUniqueConfiguration']['isSelector'] ? $type : false,
'elTable' => $config['selectorOrUniqueConfiguration']['foreignTable'] ?? '',
'field' => $config['foreign_unique'] ?? '',
'selector' => ($config['selectorOrUniqueConfiguration']['isSelector'] ?? false) ? $type : false,
'possible' => $possibleRecordsUidToTitle,
];
}
......@@ -246,7 +246,7 @@ class InlineControlContainer extends AbstractContainer
$resultArray['inlineData'] = $this->inlineData;
// @todo: It might be a good idea to have something like "isLocalizedRecord" or similar set by a data provider
$uidOfDefaultRecord = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
$uidOfDefaultRecord = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] ?? null] ?? 0;
$isLocalizedParent = $language > 0
&& ($uidOfDefaultRecord[0] ?? $uidOfDefaultRecord) > 0
&& MathUtility::canBeInterpretedAsInteger($row['uid']);
......@@ -265,17 +265,17 @@ class InlineControlContainer extends AbstractContainer
$localizationButtons = '';
if ($numberOfNotYetLocalizedChildren) {
// Add the "Localize all records" button before all child records:
if (isset($config['appearance']['showAllLocalizationLink']) && $config['appearance']['showAllLocalizationLink']) {
if (!empty($config['appearance']['showAllLocalizationLink'])) {
$localizationButtons = ' ' . $this->getLevelInteractionButton('localize', $config);
}
// Add the "Synchronize with default language" button before all child records:
if (isset($config['appearance']['showSynchronizationLink']) && $config['appearance']['showSynchronizationLink']) {
if (!empty($config['appearance']['showSynchronizationLink'])) {
$localizationButtons .= ' ' . $this->getLevelInteractionButton('synchronize', $config);
}
}
// Define how to show the "Create new record" button - if there are more than maxitems, hide it
if ($isReadOnly || $numberOfFullLocalizedChildren >= $config['maxitems'] || ($uniqueMax > 0 && $numberOfFullLocalizedChildren >= $uniqueMax)) {
if ($isReadOnly || $numberOfFullLocalizedChildren >= ($config['maxitems'] ?? 0) || ($uniqueMax > 0 && $numberOfFullLocalizedChildren >= $uniqueMax)) {
$config['inline']['inlineNewButtonStyle'] = 'display: none;';
$config['inline']['inlineNewRelationButtonStyle'] = 'display: none;';
$config['inline']['inlineOnlineMediaAddButtonStyle'] = 'display: none;';
......@@ -293,7 +293,7 @@ class InlineControlContainer extends AbstractContainer
'data-foreign-table' => (string)$foreign_table,
'data-object-group' => $nameObject . '-' . $foreign_table,
'data-form-field' => $nameForm,
'data-appearance' => (string)json_encode($config['appearance']),
'data-appearance' => (string)json_encode($config['appearance'] ?? ''),
];
// Wrap all inline fields of a record with a <div> (like a container)
......@@ -304,13 +304,13 @@ class InlineControlContainer extends AbstractContainer
$resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false);
// Add the level buttons before all child records:
if ($config['appearance']['levelLinksPosition'] === 'both' || $config['appearance']['levelLinksPosition'] === 'top') {
if (in_array($config['appearance']['levelLinksPosition'] ?? null, ['both', 'top'], true)) {
$html .= '<div class="form-group t3js-formengine-validation-marker">' . $levelButtons . $localizationButtons . '</div>';
}
// If it's required to select from possible child records (reusable children), add a selector box
if (!$isReadOnly && $config['foreign_selector'] && $config['appearance']['showPossibleRecordsSelector'] !== false) {
if ($config['selectorOrUniqueConfiguration']['config']['type'] === 'select') {
if (!$isReadOnly && ($config['foreign_selector'] ?? false) && ($config['appearance']['showPossibleRecordsSelector'] ?? true) !== false) {
if (($config['selectorOrUniqueConfiguration']['config']['type'] ?? false) === 'select') {
$selectorBox = $this->renderPossibleRecordsSelectorTypeSelect($config, $uniqueIds);
} else {
$selectorBox = $this->renderPossibleRecordsSelectorTypeGroupDB($config);
......@@ -349,10 +349,10 @@ class InlineControlContainer extends AbstractContainer
$html .= $fieldWizardHtml;
// Add the level buttons after all child records:
if (!$isReadOnly && ($config['appearance']['levelLinksPosition'] === 'both' || $config['appearance']['levelLinksPosition'] === 'bottom')) {
if (!$isReadOnly && in_array($config['appearance']['levelLinksPosition'] ?? false, ['both', 'bottom'], true)) {
$html .= $levelButtons . $localizationButtons;
}
if (is_array($config['customControls'])) {
if (is_array($config['customControls'] ?? false)) {
$html .= '<div id="' . $nameObject . '_customControls">';
foreach ($config['customControls'] as $customControlConfig) {
if (!isset($customControlConfig['userFunc'])) {
......@@ -380,7 +380,13 @@ class InlineControlContainer extends AbstractContainer
// Publish the uids of the child records in the given order to the browser
$html .= '<input type="hidden" name="' . $nameForm . '" value="' . implode(',', $sortableRecordUids) . '" '
. ' data-formengine-validation-rules="' . htmlspecialchars($this->getValidationDataAsJsonString(['type' => 'inline', 'minitems' => $config['minitems'], 'maxitems' => $config['maxitems']])) . '"'
. ' data-formengine-validation-rules="'
. htmlspecialchars($this->getValidationDataAsJsonString([
'type' => 'inline',
'minitems' => $config['minitems'] ?? null,
'maxitems' => $config['maxitems'] ?? null,
]))
. '"'
. ' class="inlineRecord" />';
// Close the wrap for all inline fields (container)
$html .= '</div>';
......
......@@ -135,7 +135,7 @@ class PaletteAndSingleContainer extends AbstractContainer
];
}
} else {
if (!is_array($this->data['processedTca']['columns'][$fieldName])) {
if (!is_array($this->data['processedTca']['columns'][$fieldName] ?? null)) {
continue;
}
......
......@@ -56,7 +56,7 @@ class SingleFieldContainer extends AbstractContainer
// This field decides whether the current record is an overlay (as opposed to being a standalone record)
// Based on this decision we need to trigger field exclusion or special rendering (like readOnly)
if (isset($this->data['processedTca']['ctrl']['transOrigPointerField'])
&& is_array($this->data['processedTca']['columns'][$this->data['processedTca']['ctrl']['transOrigPointerField']])
&& is_array($this->data['processedTca']['columns'][$this->data['processedTca']['ctrl']['transOrigPointerField']] ?? null)
) {
$parentValue = $row[$this->data['processedTca']['ctrl']['transOrigPointerField']];
if (MathUtility::canBeInterpretedAsInteger($parentValue)) {
......@@ -74,23 +74,18 @@ class SingleFieldContainer extends AbstractContainer
}
// A couple of early returns in case the field should not be rendered
// Check if this field is configured and editable according to exclude fields and other configuration
if (// Return if BE-user has no access rights to this field, @todo: another user access rights check!
$parameterArray['fieldConf']['exclude'] && !$backendUser->check('non_exclude_fields', $table . ':' . $fieldName)
// Return if field should not be rendered in translated records
|| $isOverlay && empty($parameterArray['fieldConf']['l10n_display']) && $parameterArray['fieldConf']['l10n_mode'] === 'exclude'
|| $this->inlineFieldShouldBeSkipped()
) {
$fieldIsExcluded = $parameterArray['fieldConf']['exclude'] ?? false;
$fieldNotExcludable = $backendUser->check('non_exclude_fields', $table . ':' . $fieldName);
$fieldExcludedFromTranslatedRecords = empty($parameterArray['fieldConf']['l10n_display']) && ($parameterArray['fieldConf']['l10n_mode'] ?? '') === 'exclude';
// Return if BE-user has no access rights to this field, @todo: another user access rights check!
if (($fieldIsExcluded && !$fieldNotExcludable) || ($isOverlay && $fieldExcludedFromTranslatedRecords) || $this->inlineFieldShouldBeSkipped()) {
return $resultArray;
}
$parameterArray['fieldTSConfig'] = [];
if (isset($this->data['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.'])
&& is_array($this->data['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.'])
) {
$parameterArray['fieldTSConfig'] = $this->data['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.'];
}
if ($parameterArray['fieldTSConfig']['disabled']) {
$tsConfig = $this->data['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.'] ?? [];
$parameterArray['fieldTSConfig'] = is_array($tsConfig) ? $tsConfig : [];
if ($parameterArray['fieldTSConfig']['disabled'] ?? false) {
return $resultArray;
}
......@@ -103,7 +98,7 @@ class SingleFieldContainer extends AbstractContainer
// The value to show in the form field.
$parameterArray['itemFormElValue'] = $row[$fieldName];
// Set field to read-only if configured for translated records to show default language content as readonly
if ($parameterArray['fieldConf']['l10n_display']
if (($parameterArray['fieldConf']['l10n_display'] ?? false)
&& GeneralUtility::inList($parameterArray['fieldConf']['l10n_display'], 'defaultAsReadonly')
&& $isOverlay
) {
......@@ -111,11 +106,10 @@ class SingleFieldContainer extends AbstractContainer
$parameterArray['itemFormElValue'] = $this->data['defaultLanguageRow'][$fieldName];
}
if (strpos($this->data['processedTca']['ctrl']['type'], ':') === false) {
$typeField = $this->data['processedTca']['ctrl']['type'];
} else {
$typeField = substr($this->data['processedTca']['ctrl']['type'], 0, strpos($this->data['processedTca']['ctrl']['type'], ':'));
}
$processedTcaType = $this->data['processedTca']['ctrl']['type'] ?? '';
$typeField = strpos($processedTcaType, ':') === false
? $processedTcaType
: substr($processedTcaType, 0, strpos($processedTcaType, ':'));
// JavaScript code for event handlers:
$parameterArray['fieldChangeFunc'] = [];
......
......@@ -334,7 +334,7 @@ abstract class AbstractFormElement extends AbstractNode
): string {
$elementName = 'document.editform[' . GeneralUtility::quoteJSvalue($itemName) . ']';
$checkboxPow = 2 ** $checkbox;
$checked = $formElementValue & $checkboxPow;
$checked = (int)$formElementValue & $checkboxPow;
if ($invert) {
$checked = !$checked;
}
......
......@@ -88,7 +88,7 @@ class CheckboxElement extends AbstractFormElement
$elementHtml = '';
$disabled = false;
if ($this->data['parameterArray']['fieldConf']['config']['readOnly']) {