getResources breaks on PHP8

Hi all,

I use pdoTools / pdoResources these days but I have a lot of existing older sites that use getResources.

With the release of MODX 2.8.2 I’ve been testing out upgrading MODX and also upgrading PHP to PHP8.

It seems that pages using getResources will break under PHP8.

This seems to be due to its use of the now-removed “each” function on line 416:

while (list($sort, $dir) = each($sorts)) {
            if ($sortbyEscaped) $sort = $modx->escape($sort);
            if (!empty($sortbyAlias)) $sort = $modx->escape($sortbyAlias) . ".{$sort}";
            $criteria->sortby($sort, $dir);

I guess my question is, is getResources still maintained by the author? Will it be updated?

If it was just one site I’d maybe look at fixing the code myself but if the extra is abandoned I’d likely rewrite the sites to use pdoResources.

Many thanks in advance for any thoughts / wisdom!


Sounds like this should be fixed in the next update

getResources 1.7.0 has been released and should indeed correct this issue. :slight_smile:

1 Like

Fab work @markh … Tested and :+1:

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.