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

Trash restore processor causes uninitialised/null exception #16297

Closed
wuuti opened this issue Nov 8, 2022 · 0 comments · Fixed by #16303
Closed

Trash restore processor causes uninitialised/null exception #16297

wuuti opened this issue Nov 8, 2022 · 0 comments · Fixed by #16303
Labels
bug The issue in the code or project, which should be addressed.

Comments

@wuuti
Copy link
Contributor

wuuti commented Nov 8, 2022

Bug report

Summary

When you try to "Restore all" in the trash manager (tested on a PHP8.1 instance), this will fail.

Step to reproduce

See above.

Observed behavior

Nothing is restored, strange error dialog pops up in the trash manager:
image

Logfile shows:

ERROR:  Uncaught Exception TypeError: "count(): Argument #1 ($value) must be of type Countable|array, null given" at /home/www/core/src/Revolution/Processors/Resource/Trash/Restore.php line 132

Expected behavior

The resource(s) should be restored. If that failed due to whatever, at least a better error message should be shown.

Root cause

One line of code is missing in the restore processor, which must initialize the $failures array (around line 79):

   public function process()
    {
        $this->success = [];
        $this->failures = [];    // <------- that's missing
        $contexts = [];

        foreach ($this->resources as $resource) {

Environment

MODX version: 3.0.1-pl advanced,
PHP 8.1.11

@wuuti wuuti added the bug The issue in the code or project, which should be addressed. label Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue in the code or project, which should be addressed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant