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 #1

Updated by Sybille Peters almost 2 years ago

  • Description updated (diff)
Actions #2

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

Actions #4

Updated by Sybille Peters almost 2 years ago

  • Description updated (diff)
Actions #5

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

Actions #6

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

Actions #7

Updated by Christian Kuhn almost 2 years ago

special thanks for the test extension!

Actions #8

Updated by Sybille Peters almost 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #9

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

Actions #10

Updated by Sybille Peters almost 2 years ago

  • Status changed from Under Review to Resolved
Actions #11

Updated by Benni Mack almost 2 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF