Bug #99295
closedIf a page has a field with additional itemsProcFunc in TCA, creating a new page may fail with PHP 8.1
100%
Description
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.
Version¶
- PHP 8.1
- TYPO3 11.5.19 | latest 11.5 branch | latest 12 (main branch)
Extension for reproducing the problem:¶
https://github.com/sypets/sypets_typo3_minimal_example_99295
Reproduce¶
1. Make sure that a field in the pages tables has an itemsProcFunc function (the extension can be used)
2. Now, create a new page
Result: error message
Page tree error Got unexpected response from the server. Please check logs for details
See exception trace in log messages.
Analysis¶
The exception occurs in this line:
42: $pageId = $table === 'pages' ? $row['uid'] : $row['pid'];
$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.
Source code¶
Configuration/TCA/Overrides/pages.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'
);
Classes/FormEngine/ItemsProcFuncs/ItemsProcFunc.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.
}
}
etc.
Files
Updated by Gerrit Code Review almost 2 years ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76943
Updated by Sybille Peters almost 2 years ago
- File stacktrace_typo3_v11_issue_99295.log stacktrace_typo3_v11_issue_99295.log added
- Description updated (diff)
Updated by Gerrit Code Review almost 2 years ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76943
Updated by Gerrit Code Review almost 2 years ago
Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/76943
Updated by Christian Kuhn almost 2 years ago
special thanks for the test extension!
Updated by Sybille Peters almost 2 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset e325a298e71cca6fea8b95b178b7b70ae556c9d0.
Updated by Gerrit Code Review almost 2 years ago
- Status changed from Resolved to Under Review
Patch set 1 for branch 11.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/77277
Updated by Sybille Peters almost 2 years ago
- Status changed from Under Review to Resolved
Applied in changeset eb0b4e102fbf639e455e36dfd5aa4fe665b50854.
Updated by Benni Mack almost 2 years ago
- Status changed from Resolved to Closed