Skip to content

Bug PHP 8 pdoResources snippet with property 'toSeparatePlaceholders' in combination with pdoPage #372

@arjen-t

Description

@arjen-t

Сообщение об ошибке / Error message

PHP Fatal error: Uncaught TypeError: Cannot access offset of type string

Резюме / Summary

When adding the property &toSeparatePlaceholders on the pdoPage snippet the pdoResources snippet (forward call) causes a PHP Fatal error: Uncaught TypeError: Cannot access offset of type string so far I know from PHP >= 8

Как воспроизвести проблему, включая пользовательский код, если это необходимо. / How to reproduce the problem, including custom code if needed
Call the snippet of pdoPage with the property &toSeparatePlaceholders.

Наблюдаемое поведение / Observed behavior

A nested pdoResources call causes the $output to be a string on line 40. At line 58 the $log is added to the $output assuming it is an array. This line should be refactored in.

if(is_array($log)){
        $output['log'] = $log;
        $modx->setPlaceholders($output, $toSeparatePlaceholders);
 }else {
        $modx->setPlaceholders(['log' => $log], $toSeparatePlaceholders);
    }

Ожидаемое поведение / Expected behavior

Как это должно вести себя после следующих шагов выше. / How it should behave after following the steps above.
No PHP fatal error ;-)

Environment

MODX 2.8.5 with PHP 8.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions