Upgrade from 2.8.6 to 3.0.4 manager ok site gives error 500

Can you check the line 183 of this file?
Is it this line?

If that’s the case, then the variable $items is somehow null.


If you want to debug why $items is null, try adding some code like this

if ($items === null){
    $modx->log(modX::LOG_LEVEL_ERROR, 'Incorrect JSON? ' . $outputvalue);
}

in the snippet before line 183 (and then check the MODX error log).
Maybe the JSON in $outputvalue is wrong (on line 177) or filterItems (line 181) returns null?


To (temporarily) fix the fatal error, add code like this in the snippet “getImageList” before line 183.

if ($items === null){
    $items = [];
}

The line 183 in core/cache/includes/elements/modx/revolution/modsnippet/13.include,cache.php i like you posted

  1. $modx->setPlaceholder($totalVar, count($items));

If I set before line 183

if ($items === null){
$modx->log(modX::LOG_LEVEL_ERROR, 'Incorrect JSON? ’ . $outputvalue);
}

I get this error at server

AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/vhosts/XXXXX/core/cache/includes/elements/modx/revolution/modsnippet/13.include.cache.php:186\nStack trace:\n#0 /var/www/vhosts/XXXXX/core/src/Revolution/modScript.php(88): include()\n#1 /var/www/vhosts/XXXXX/core/src/Revolution/modParser.php(508): MODX\Revolution\modScript->process()\n#2 /var/www/vhosts/XXXXX/core/components/pdotools/src/Parsing/Parser.php(276): MODX\Revolution\modParser->processTag()\n#3 /var/www/vhosts/XXXXX/core/src/Revolution/modParser.php(221): ModxPro\PdoTools\Parsing\Parser->processTag()\n#4 /var/www/vhosts/XXXXX/core/components/pdotools/src/Parsing/Parser.php(73)…’

If I set before line 183

if ($items === null){
$items = ;
}

I get the site (yeahhh!) but without logged in with error 404 and when I logged in with content but without navigation.

I actually checked the logs in MODX.
If I call a site I get this log in MODX

[2024-01-18 20:20:20] (ERROR @ /var/www/vhosts/XXXXX/core/src/Revolution/modParser.php : 512) Could not find snippet with name lingua.getValue.

Why is here still called for LIngua?
I thought I had delete every part of Lingua.
An other error in MODX is

[2024-01-18 20:20:20] (ERROR in resource 30 @ /var/www/vhosts/XXXX/core/src/Revolution/modLinkTag.php : 108) Bad link tag [[~]] encountered

Is this relevant for MODX 3.0 ?

Maybe a permissions issue? Is the page in a resource group that restricts access?


Somewhere on your page, (probably in the content or a chunk) you call the snippet [[lingua.getValue...]]. This error is not fatal. The rest of the site should still show.

Probably a tag like [[~[[+id]]]] or [[~[[*id]]]] (or similar) on your page where [[+id]]/[[*id]] is not defined (and therefore empty). This error won’t break your site.

Maybe a permissions issue? Is the page in a resource group that restricts access?

No, there are no permissions.

Now I checked templates and chunks again and I’ve seen that I use sometimes [[Lingua.getValue … ]] for translating some fields.
At first I found some chunks for one recourse and his template, so deleted them.
But still I get not the site, still error 505 when I clear the cache.
When I set

if ($items === null){
$items = ;
}

before line 183 in core/cache/element/revolution/modsnippet/13.include,cache.php I can get the site but still without navigation.

So I will look further for entries of Lingua, but for me now it seems to be a problem by MIGX?

Change the code in the actual snippet (and not in the cache file). Otherwise the change gets lost everytime the cache is cleared.

When checking chunks for Lingua.getValue entries I get an other problem, Actually I cannot save changes in the chunks. I can delete a chunk but I cannot save a new chunk. So every changing I try will not be saved.
This as a logged in superuser Admin.
Where does this now come from?
Before, I could change and save templates, but actually no chunks.

I also try to change snippet getImagelIst but cannot save.
So I changed at the server in core/components/migx/elements/snippets/getImagelist.snippet.php at line 183 but without result, again getting error 505 when calling the site.

Why can I not saving changes on chunks or snippets?

Now I edit many chunks in the database and slowly I get the site running without lingua.
Sometimes a chunk or template will be saved with changes, sometimes not. This is strange.
A problem is now the output of Migx-TV’s and galleries. They are not displayed.

Change that to

$items = '';

Otherwise, it’s a syntax error that could crash the site.

Did you, by chance, move from PHP 7 to PHP >= 8.1 recently? Newer versions of PHP 8 issue a deprecation error for certain functions called with null as an argument. The errors can cause crashes in some cases.

This is usually a sign, that a firewall on the server is blocking requests it considers suspicious. Maybe check with your hosting provider if the firewall settings can be changed.


This file is only used for the installation of the extra. During installation a snippet is created in the database with the code from this file. Only the snippet in the database is then used.


Using

if ($items === null){
    $items = [];
}

gets rid of the fatal error but probably doesn’t solve the real issue. Namely that $items is null. That why I recommended doing some debugging earlier. There is possibly something wrong with your MIGX-JSON-data.

So what is the status now:
I get my site when I change the getImagelist snippet, but without MIGX-TV’s.
If I use the origin getImagelist snippet I get error 505.
OK the problem now is not lingua, as first suggest, it is MIGX.
I deinstalled MIGX and made a new install, but no change.
What can I do to solve the problem, probably in MIGX-JSON-data?

Change

if ($items === null){
    $items = [];
}

to

if ($items === null){
    $modx->log(modX::LOG_LEVEL_ERROR, '$outputvalue = ' . $outputvalue);
    $items = [];
}

This outputs the JSON data to the MODX error log → $outputvalue = [{"MIGX_id":"1", ...
What is the data in the log?

How do you call getImageList?
If you use the &where property, then please share the getImageList tag.

If I change getImagelist snippet in line 183 with

if ($items === null){
    $modx->log(modX::LOG_LEVEL_ERROR, '$outputvalue = ' . $outputvalue);
    $items = [];
}

Than I get this error logs in Modx

[2024-01-19 20:19:41] (ERROR @ /var/www/vhosts/XXXX/core/cache/includes/elements/modx/revolution/modsnippet/13.include.cache.php : 184) $outputvalue = [[+imagelist-spotlight]]
[2024-01-19 20:19:42] (ERROR in resource 85 @ /var/www/vhosts/XXXX/core/src/Revolution/modLinkTag.php : 108) Bad link tag `[[~]]` encountered
[2024-01-19 20:19:46] (ERROR @ /var/www/vhosts/XXXX/core/cache/includes/elements/modx/revolution/modsnippet/13.include.cache.php : 184) $outputvalue = [[+imagelist-feature1]]
[2024-01-19 20:19:47] (ERROR @ /var/www/vhosts/XXXX/core/cache/includes/elements/modx/revolution/modsnippet/13.include.cache.php : 184) $outputvalue = [[+Instrumente]]
[2024-01-19 20:19:47] (ERROR in resource 30 @ /var/www/vhosts/XXXX/core/src/Revolution/modLinkTag.php : 108) Bad link tag `[[~]]` encountered
[2024-01-19 20:19:47] (ERROR in resource 85 @ /var/www/vhosts/XXXX/core/src/Revolution/modLinkTag.php : 108) Bad link tag `[[~]]` encountered

there is no &where property in the getImageList tag.

Can you post how getImageList is called?
Should the placeholder [[+imagelist-spotlight]] contain the MIGX-JSON data?

When does the placeholder [[+imagelist-spotlight]] get set?
Do you have like a pdoResources call and then in the &tpl chunk, you call getImageList for every resource with a &value property?

seems your [[+imagelist-spotlight]] placeholder isn’t resolved, before getImageList is running.

Maybe an issue with mixed cached/uncached snippet/placeholder tags

I am wondering because now I have seen that the TV imagelist-spotlight is not in use. It is not active with any template. And also I cannot find any chunk which is calling this TV.
But I still find some &value properties with Lingua entries in imagelist-feature1 and others.
If I delete these entries I get the galleries at the site. I am glad.
step by step I get eliminate all lingua entries.
Thank you for your patience.
Now I use the original getImageList snippet and every thing seems to be ok.
I think it is solved.