Skip to content

Commit

Permalink
[BUGFIX] Undefined array key in install tool
Browse files Browse the repository at this point in the history
A click on "Image Processing", "Configure Installation-Wide Options"
or "Configuration Presets" in the install tool returns
an error in PHP8.

Add fallback for unefined array keys to workaround
the array undefined key warnings.

Add acceptance tests for InstallTool -> Settings module
to make sure settings of each card can be loaded and saved.

Resolves: #94425
Releases: master
Change-Id: Icf3b11b0e4c490f8054605cd531f77906dfa7ac6
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69633
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
ochorocho authored and lolli42 committed Jun 29, 2021
1 parent f0d038e commit fb67447
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,13 @@ class ModuleMenu {

deferred.then((): void => {
this.initializeModuleMenuEvents();
Viewport.Topbar.Toolbar.registerEvent(() => this.initializeTopBarEvents());
Viewport.Topbar.Toolbar.registerEvent(() => {
// Only initialize top bar events when top bar exists.
// E.g. install tool has no top bar
if(document.querySelector('.t3js-scaffold-toolbar')) {
this.initializeTopBarEvents()
}
});
});
}

Expand Down

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,8 @@ public function makeText(&$im, $conf, $workArea)
if (!$this->processorEffectsEnabled) {
$command = trim($this->scalecmd . ' ' . $w . 'x' . $h . '! -negate');
} else {
$command = trim($conf['niceText.']['before'] . ' ' . $this->scalecmd . ' ' . $w . 'x' . $h . '! ' . $conf['niceText.']['after'] . ' -negate');
if ($conf['niceText.']['sharpen']) {
$command = trim(($conf['niceText.']['before'] ?? '') . ' ' . $this->scalecmd . ' ' . $w . 'x' . $h . '! ' . ($conf['niceText.']['after'] ?? '') . ' -negate');
if (isset($conf['niceText.']['sharpen'])) {
$command .= $this->v5_sharpen($conf['niceText.']['sharpen']);
}
}
Expand Down Expand Up @@ -1456,7 +1456,7 @@ public function makeShadow(&$im, $conf, $workArea, $txtConf)
imagedestroy($blurTextImg_tmp);
// Adjust the mask
$intensity = 40;
if ($conf['intensity']) {
if ($conf['intensity'] ?? false) {
$intensity = MathUtility::forceIntegerInRange($conf['intensity'], 0, 100);
}
$intensity = (int)ceil(255 - $intensity / 100 * 255);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected function buildConfigurationArray(array $configurationOption): array
}
}
$configurationOption['labels'] = GeneralUtility::trimExplode(':', $configurationOption['label'], false, 2);
$configurationOption['subcat_name'] = $configurationOption['subcat_name'] ?: '__default';
$configurationOption['subcat_name'] = ($configurationOption['subcat_name'] ?? false) ?: '__default';
$hierarchicConfiguration[$configurationOption['cat']][$configurationOption['subcat_name']][$configurationOption['name']] = $configurationOption;
return $hierarchicConfiguration;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?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;
use TYPO3\CMS\Core\Tests\Acceptance\Support\Helper\ModalDialog;

class SettingsCest extends AbstractCest
{
public static string $alertContainerSelector = '#alert-container';

public function _before(BackendTester $I)
{
parent::_before($I);
$this->logIntoInstallTool($I);
$I->click('Settings');
$I->see('Settings', 'h1');
}

/**
* @param BackendTester $I
* @param ModalDialog $modalDialog
* @throws \Exception
*/
public function seeExtensionConfiguration(BackendTester $I, ModalDialog $modalDialog)
{
$I->click('Configure extensions');
$modalDialog->canSeeDialog();

$I->amGoingTo('open the backend panel');
$I->click('backend', '.panel-heading');
$I->waitForElement('#em-backend-loginLogoAlt');

$I->amGoingTo('fill in an alt text for the logo');
$I->fillField('#em-backend-loginLogoAlt', 'TYPO3 logo alt text');
$I->click('Save "backend" configuration', ModalDialog::$openedModalSelector);
$I->waitForText('Configuration saved', 5, self::$alertContainerSelector);
$this->closeModalAndHideFlashMessage($I);
}

/**
* @param BackendTester $I
* @param ModalDialog $modalDialog
* @throws \Exception
*/
public function seeChangeInstallToolPassword(BackendTester $I, ModalDialog $modalDialog)
{
$I->click('Change Install Tool Password');
$modalDialog->canSeeDialog();

$I->amGoingTo('change the install tool password');
$I->fillField('#t3-install-tool-password', 'password');
$I->fillField('#t3-install-tool-password-repeat', 'password');

$I->click('Set new password', ModalDialog::$openedModalButtonContainerSelector);
$I->waitForText('Install tool password changed', 5, self::$alertContainerSelector);
$this->closeModalAndHideFlashMessage($I);
}

/**
* @param BackendTester $I
* @param ModalDialog $modalDialog
* @throws \Exception
*/
public function seeManageSystemMaintainers(BackendTester $I, ModalDialog $modalDialog)
{
$I->click('Manage System Maintainers');
$modalDialog->canSeeDialog();

$I->amGoingTo('add a system maintainer to the list');
$I->click('.chosen-search-input', ModalDialog::$openedModalSelector);
$I->click('.active-result[data-option-array-index="0"]', '.chosen-results');

$I->click('Save system maintainer list', ModalDialog::$openedModalButtonContainerSelector);
$I->waitForText('Updated system maintainers', 5, self::$alertContainerSelector);
$this->closeModalAndHideFlashMessage($I);
}

/**
* @param BackendTester $I
* @param ModalDialog $modalDialog
* @throws \Exception
*/
public function seeConfigurationPresets(BackendTester $I, ModalDialog $modalDialog)
{
$I->click('Choose Preset');
$modalDialog->canSeeDialog();

$I->amGoingTo('open the cache settings panel');
$I->click('Cache settings', '.panel-heading');
$I->waitForElement('#t3-install-tool-configuration-cache-file');

$I->amGoingTo('change cache configuration and save configuration');
$I->click('#t3-install-tool-configuration-cache-file');
$I->click('Activate preset', ModalDialog::$openedModalButtonContainerSelector);
$I->waitForText('Configuration written', 5, self::$alertContainerSelector);
$this->closeModalAndHideFlashMessage($I);
}

public function seeFeatureToggles(BackendTester $I, ModalDialog $modalDialog)
{
$I->click('Configure Features');
$modalDialog->canSeeDialog();

$I->amGoingTo('change a feature toggle and save it');
$I->click('#t3-install-tool-features-redirects.hitCount');
$I->click('Save', ModalDialog::$openedModalButtonContainerSelector);
$I->waitForText('Features updated', 5, self::$alertContainerSelector);
$this->closeModalAndHideFlashMessage($I);
}

/**
* @param BackendTester $I
* @param ModalDialog $modalDialog
* @throws \Exception
*/
public function seeConfigureInstallationWideOptions(BackendTester $I, ModalDialog $modalDialog)
{
$I->click('Configure options');
$modalDialog->canSeeDialog();

$I->amGoingTo('open the backend panel');
$I->click('Backend', '.panel-heading');
$I->waitForElement('#BE_languageDebug');

$I->amGoingTo('tick of checkbox the [BE][languageDebug] option');
$I->click('#BE_languageDebug');
$I->click('Write configuration', ModalDialog::$openedModalButtonContainerSelector);
$I->waitForText('BE/languageDebug', 5, self::$alertContainerSelector);
$this->closeModalAndHideFlashMessage($I);
}

/**
* @param BackendTester $I
*/
private function closeModalAndHideFlashMessage(BackendTester $I)
{
// We need to close the flash message here to be able to close the modal
$I->click('.close', self::$alertContainerSelector);
$I->click('.t3js-modal-close');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function getConfigurationValues()
{
$configurationValues = $this->configurationValues;
$configurationValues['MAIL/transport_sendmail_command'] = $this->getSendmailPath();
if ($this->postValues['Mail']['enable'] === 'Sendmail') {
if (($this->postValues['Mail']['enable'] ?? false) === 'Sendmail') {
$configurationValues['MAIL/transport'] = 'sendmail';
}
return $configurationValues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public function extensionConfigurationGetContentAction(ServerRequestInterface $r
public function extensionConfigurationWriteAction(ServerRequestInterface $request): ResponseInterface
{
$extensionKey = $request->getParsedBody()['install']['extensionKey'];
$configuration = $request->getParsedBody()['install']['extensionConfiguration'];
$configuration = $request->getParsedBody()['install']['extensionConfiguration'] ?? [];
$nestedConfiguration = [];
foreach ($configuration as $configKey => $value) {
$nestedConfiguration = ArrayUtility::setValueByPath($nestedConfiguration, $configKey, $value, '.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ protected function recursiveConfigurationFetching(array $sections, array $sectio
if ($descriptionType === 'container') {
$valueFromCurrentConfiguration = $sectionsFromCurrentConfiguration[$key] ?? null;
$data = array_merge($data, $this->recursiveConfigurationFetching($value, $valueFromCurrentConfiguration, $descriptionInfo, $newPath));
} elseif (!preg_match('/[' . LF . CR . ']/', (string)$value) || $descriptionType === 'multiline') {
} elseif (!preg_match('/[' . LF . CR . ']/', (string)(is_array($value) ? '' : $value)) || $descriptionType === 'multiline') {
$itemData = [];
$itemData['key'] = implode('/', $newPath);
$itemData['path'] = '[' . implode('][', $newPath) . ']';
$itemData['fieldType'] = $descriptionInfo['type'];
$itemData['description'] = $descriptionInfo['description'];
$itemData['allowedValues'] = $descriptionInfo['allowedValues'];
$itemData['description'] = $descriptionInfo['description'] ?? '';
$itemData['allowedValues'] = $descriptionInfo['allowedValues'] ?? [];
$itemData['differentValueInCurrentConfiguration'] = (!isset($descriptionInfo['compareValuesWithCurrentConfiguration']) ||
$descriptionInfo['compareValuesWithCurrentConfiguration']) &&
isset($sectionsFromCurrentConfiguration[$key]) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function getBlockingDatabaseAdds(): array
}
foreach ($changedTable->addedIndexes as $addedIndex) {
/** $var Index $addedIndex */
if (!is_array($adds['indexes'])) {
if (!is_array($adds['indexes'] ?? false)) {
$adds['indexes'] = [];
}
$adds['indexes'][] = [
Expand Down

0 comments on commit fb67447

Please sign in to comment.