Project

General

Profile

Actions

Bug #101525

closed

foreach() argument must be of type array|object, null given in MvcPropertyMappingConfigurationService.php

Added by Ralph Brugger 10 months ago. Updated 10 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2023-08-02
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.1
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:
On Location Sprint

Description

In our log files we see those erros a few times a day:

(1/1) #1476107295 TYPO3\CMS\Core\Error\Exception
PHP Warning: foreach() argument must be of type array|object, null given in 
typo3_src/typo3_src-11.5.30/typo3/sysext/extbase/Classes/Mvc/Controller/MvcPropertyMappingConfigurationService.php 
line 147

This is an extbase / fluid list view.

Here is a sample request.

?tx_rsmpress_list[__referrer][%40extension]=Rsmpress
&tx_rsmpress_list[__referrer][%40vendor]=RSM
&tx_rsmpress_list[__referrer][%40controller]=Message
&tx_rsmpress_list[__referrer][%40action]=list
&tx_rsmpress_list[__referrer][arguments]=YTowOnt9e040d2f4e53a183bc4dd114962f85091fb657230
&tx_rsmpress_list[__referrer][%40request]=a%3A4%3A{s%3A10%3A"%40extension"%3Bs%3A8%3A"Rsmpress"%3Bs%3A11%3A"%40controller"%3Bs%3A7%3A"Message"%3Bs%3A7%3A"%40action"%3Bs%3A4%3A"list"%3Bs%3A7%3A"%40vendor"%3Bs%3A3%3A"RSM"%3B}b25d2b7377de66bbe9b91df012987004255d09cd
&tx_rsmpress_list[__trustedProperties]=a%3A0%3A{}f7ef143576e2a243c81263679b9422dd99b931d0
&tx_rsmpress_list[search][keywords]=impfung
&tx_rsmpress_list[search][from]=
&tx_rsmpress_list[search][to]=
&tx_rsmpress_list[search][ministry]=0

PCP-Code:
MvcPropertyMappingConfigurationService.php : Line 145

$trustedProperties = json_decode($serializedTrustedProperties, true);
foreach ($trustedProperties as $propertyName => $propertyConfiguration) {
    if (!$controllerArguments->hasArgument($propertyName)) {
        continue;
        }
    $propertyMappingConfiguration = $controllerArguments->getArgument($propertyName)->getPropertyMappingConfiguration();
    $this->modifyPropertyMappingConfiguration($propertyConfiguration, $propertyMappingConfiguration);
}

In this case $trustedProperties is null

Maybe this should be checked before?

$trustedProperties = json_decode($serializedTrustedProperties, true);
if ($trustedProperties && is_array($trustedProperties)){
  foreach ($trustedProperties as $propertyName => $propertyConfiguration) {
      if (!$controllerArguments->hasArgument($propertyName)) {
          continue;
          }
      $propertyMappingConfiguration = $controllerArguments->getArgument($propertyName)->getPropertyMappingConfiguration();
      $this->modifyPropertyMappingConfiguration($propertyConfiguration, $propertyMappingConfiguration);
  }
}

Related issues 1 (0 open1 closed)

Is duplicate of TYPO3 Core - Bug #97337: Empty $trustedProperties cause a PHP warningResolvedThomas Hohn2022-04-08

Actions
Actions

Also available in: Atom PDF