Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
arjen-t opened this issue Sep 21, 2023 · 1 comment
Labels

Comments

@arjen-t
Copy link

arjen-t commented Sep 21, 2023

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

@pixelbyinch
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants