pdoTools icon indicating copy to clipboard operation
pdoTools copied to clipboard

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

Open arjen-t opened this issue 2 years ago • 1 comments

Сообщение об ошибке / 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

arjen-t avatar Sep 21 '23 14:09 arjen-t

Confirmed BUG with php 8.1 and using &toSeparatePlaceholders. Was upgrading a site from php 7.4 to 8.1 and had to revert to using getResources. Hopefully this gets resolved really enjoy using pdoTools

pixelbyinch avatar May 06 '24 16:05 pixelbyinch