Gallery stopped working in frontend

Hi,

I do support a small site from time to time. It is running on some IONOS webhosting. modx 2.8.3.

As I’m not the owner of the site, I don’t know exactly when it started, but now when you go to the website all the pictures that have been generated from the gallery aren’t shown anymore. In the backend you can see the thumbnails but not on the individual pages. There are no visible errors in manager log or on the site itself.
When you try to open the link behind the img tag, you get a JSON with 401

https://www.efflorescos.de//assets/components/gallery/connector.php?action=web/phpthumb&ctx=web&w=800&h=800&zc=0&far=&q=90&src=%2Fassets%2Fgallery%2F2%2F391.jpg

gives you

{"success":false,"message":"Zugriff verweigert.","total":0,"data":[],"object":{"code":401}}

Any help is appreciated. I have no idea where to look…

Cheers

Not that I have any idea what causes the error, but it’s likely that one of these 4 conditions is met.

Maybe you can (temporarily) add some log statements to the code, to find out which one of these conditions is met and why.

//log something
$this->modx->log(modX::LOG_LEVEL_ERROR,"some log message");

//log the relevant values
$this->modx->log(modX::LOG_LEVEL_ERROR,"siteId={$test}|HTTP_MODAUTH-Request={$_REQUEST['HTTP_MODAUTH']}|HTTP_MODAUTH-Server={$_SERVER['HTTP_MODAUTH']}");

Most of these values are explicitly set in the connector that is called.

Hi,

thanks that actually helped to find the place, just not the reason yet…
It fails at this line:

I logged out slightly adjusting your template:

$this->modx->log(modX::LOG_LEVEL_ERROR,"siteId={$siteId}|HTTP_MODAUTH-Request={$_REQUEST['HTTP_MODAUTH']}|HTTP_MODAUTH-Server={$_SERVER['HTTP_MODAUTH']}");

and it gave me:

siteId=|HTTP_MODAUTH-Request=0|HTTP_MODAUTH-Server=0

What now?

Do you use PHP 8?

I believe the comparison if ('' == 0) gives a different result in PHP 8 than before (and that causes the problem).


Try changing the value of $_SERVER['HTTP_MODAUTH'] ($_REQUEST['HTTP_MODAUTH']) in the connector to an empty string instead of 0 and see if that helps.

Yeah, we had to switch from PHP 7.3 to a newer version. So I jumped to PHP 8.1. But going back to 8.0 or 7.4 didn’t seem to make a difference.

I implemented that change and it works perfectly. Thank you very much. I should have come here way earlier…

Cheers

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”.