Bug #99295
Updated by Sybille Peters almost 2 years ago
After switching to PHP 8.1, I got an exception when creating a new page.
This could be reproduced in a minimal TYPO3 installation with a minimal extension, which adds a field with itemsProcFunc in TCA.
h2. Version
* PHP 8.1
* TYPO3 11.5.19 or latest 11.5 branch
Did not test this with v12
h2. Extension for reproducing the problem:
https://github.com/sypets/sypets_typo3_minimal_example_99295
h2. Analysis
The exception occurs in this line:
"ItemsProcessingService":https://github.com/TYPO3/typo3/blob/11.5/typo3/sysext/core/Classes/DataHandling/ItemProcessingService.php::getProcessingItems
<pre>
42: $pageId = $table === 'pages' ? $row['uid'] : $row['pid'];
</pre>
$row['uid'] is not set here (as is new page which has no uid yet).
It is also weird that the $pageId is passed, but is not used. It would be the uid of the parent page which I assume would be more correct.
h2. Source code
Configuration/TCA/Overrides/pages.php
<pre><code class="php">
<?php
defined('TYPO3') or die();
$columns = [
'hide_subnavigation' => [
'label' => 'Subnavigation',
'l10n_mode' => 'exclude',
'config' => [
'type' => 'check',
'default' => 0,
'itemsProcFunc' => Sypets\SypetsExample\FormEngine\ItemsProcFuncs\ItemsProcFunc::class . '->getItemsForPagesHideSubnavigation',
'items' => [
[
'Option 1',
''
],
[
'Option 2',
''
],
],
],
],
];
// Add new fields to pages:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('pages', $columns);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
// table
'pages',
// field
'hide_subnavigation',
'',
'after:title'
);
</code></pre>
Classes/FormEngine/ItemsProcFuncs/ItemsProcFunc.php:
<pre><code class="php">
<?php
declare(strict_types=1);
namespace Sypets\SypetsExample\FormEngine\ItemsProcFuncs;
class ItemsProcFunc
{
/**
*
* @param array $configuration Current field configuration
* @internal
*/
public function getItemsForPagesHideSubnavigation(array &$configuration): void
{
// not relevant what happens here for the sake of but report.
}
}
</code></pre>
etc.