Commit d4c698c6 authored by Jan Delius's avatar Jan Delius Committed by Susanne Moog
Browse files

[BUGFIX] Use finder instance correctly

Within SiteTcaConfiguration, the $finder is now reused as much as
possible. A new clean instance is used for the individual actions.

Resolves: #87832
Releases: master, 9.5
Change-Id: I34f2d08c51042f2cfe6b4a09ac6152e0b552ab14
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/59839


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Rico Drexler's avatarRico Drexler <rico.drexler@gmx.de>
Tested-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
Reviewed-by: default avatarJörg Bösche <typo3@joergboesche.de>
Reviewed-by: Susanne Moog's avatarSusanne Moog <look@susi.dev>
parent bc76058e
......@@ -45,26 +45,35 @@ class SiteTcaConfiguration
$GLOBALS['SiteConfiguration'] = [];
$activePackages = GeneralUtility::makeInstance(PackageManager::class)->getActivePackages();
// First load "full table" files from Configuration/SiteConfiguration
$finder = new Finder();
$finder = (new Finder())->files()->depth(0)->name('*.php');
$hasDirectoryEntries = false;
foreach ($activePackages as $package) {
try {
$finder->files()->depth(0)->name('*.php')->in($package->getPackagePath() . 'Configuration/SiteConfiguration');
$finder->in($package->getPackagePath() . 'Configuration/SiteConfiguration');
} catch (\InvalidArgumentException $e) {
// No such directory in this package
continue;
}
$hasDirectoryEntries = true;
}
if ($hasDirectoryEntries) {
foreach ($finder as $fileInfo) {
$GLOBALS['SiteConfiguration'][substr($fileInfo->getBasename(), 0, -4)] = require $fileInfo->getPathname();
}
}
// Execute override files from Configuration/SiteConfiguration/Overrides
$finder = (new Finder())->files()->depth(0)->name('*.php');
$hasDirectoryEntries = false;
foreach ($activePackages as $package) {
try {
$finder->files()->depth(0)->name('*.php')->in($package->getPackagePath() . 'Configuration/SiteConfiguration/Overrides');
$finder->in($package->getPackagePath() . 'Configuration/SiteConfiguration/Overrides');
} catch (\InvalidArgumentException $e) {
// No such directory in this package
continue;
}
$hasDirectoryEntries = true;
}
if ($hasDirectoryEntries) {
foreach ($finder as $fileInfo) {
require $fileInfo->getPathname();
}
......
<?php
declare(strict_types = 1);
defined('TYPO3_MODE') or die();
$GLOBALS['SiteConfiguration']['site']['columns']['tx_a_a'] = [
'label' => 'a',
'description' => '',
'config' => [
'type' => 'input',
'size' => 25,
'max' => 255,
]
];
$GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] .= ',tx_a_a';
<?php
$EM_CONF[$_EXTKEY] = [
'title' => '',
'description' => '',
'category' => 'example',
'author' => '',
'author_company' => '',
'author_email' => '',
'state' => 'stable',
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 1,
'version' => '10.0.0',
'constraints' => [
'depends' => [
'typo3' => '10.0.0',
],
'conflicts' => [],
'suggests' => [],
],
];
<?php
declare(strict_types = 1);
defined('TYPO3_MODE') or die();
$GLOBALS['SiteConfiguration']['site']['columns']['tx_b_a'] = [
'label' => 'a',
'config' => [
'type' => 'input',
'size' => 25,
'max' => 255,
]
];
$GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] .= ',tx_b_a';
$GLOBALS['SiteConfiguration']['site']['columns']['tx_a_a']['description'] = 'Awesome description by extension b';
<?php
$EM_CONF[$_EXTKEY] = [
'title' => '',
'description' => '',
'category' => 'example',
'author' => '',
'author_company' => '',
'author_email' => '',
'state' => 'stable',
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 1,
'version' => '10.0.0',
'constraints' => [
'depends' => [
'typo3' => '10.0.0',
'a' => '10.0.0',
],
'conflicts' => [],
'suggests' => [],
],
];
<?php
declare(strict_types = 1);
namespace TYPO3\CMS\Backend\Tests\Functional\Configuration\SiteConfiguration;
/*
* 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!
*/
use TYPO3\CMS\Backend\Configuration\SiteTcaConfiguration;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
/**
* Test case for TYPO3\CMS\Backend\Tests\Functional\Configuration\SiteConfiguration\SiteConfigurationOverridesTest
*/
class SiteConfigurationOverridesTest extends FunctionalTestCase
{
/** @var array */
protected $subject;
/**
* @var string[]
*/
protected $testExtensionsToLoad = [
'typo3/sysext/backend/Tests/Functional/Configuration/SiteConfiguration/Fixtures/Extensions/conf_overriding/a',
'typo3/sysext/backend/Tests/Functional/Configuration/SiteConfiguration/Fixtures/Extensions/conf_overriding/b',
];
/**
* Sets up this test case.
*/
protected function setUp(): void
{
parent::setUp();
$this->subject = (new SiteTcaConfiguration())->getTca();
}
/**
* @test
*/
public function allOverridesLoaded(): void
{
$columnsConfiguration = $this->subject['site']['columns'];
$this->assertArrayHasKey('tx_a_a', $columnsConfiguration);
$this->assertArrayHasKey('tx_b_a', $columnsConfiguration);
}
/**
* @test
*/
public function overrideOnlyLoadedOnce(): void
{
$showitemConfiguration = $this->subject['site']['types']['0']['showitem'];
$this->assertSame(1, mb_substr_count($showitemConfiguration, 'tx_a_a'));
$this->assertSame(1, mb_substr_count($showitemConfiguration, 'tx_b_a'));
}
/**
* @test
*/
public function finderUsesCorrectOrder(): void
{
$columnsConfiguration = $this->subject['site']['columns'];
$this->assertSame('Awesome description by extension b', $columnsConfiguration['tx_a_a']['description']);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment