Project

General

Profile

Actions

Bug #99295

closed

If a page has a field with additional itemsProcFunc in TCA, creating a new page may fail with PHP 8.1

Added by Sybille Peters almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
-
Start date:
2022-12-06
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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:

ItemsProcessingService

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

Actions

Also available in: Atom PDF