gantry / gantry5

:rocket: Next Generation Template / Theme Framework
http://gantry.org
1.04k stars 204 forks source link

Gantry Ajax Administration menu breaks #3018

Open uGE70 opened 2 years ago

uGE70 commented 2 years ago

Platform (Linux Debian, Infomaniak shared and Cloud Web hosting): Joomla 3.10.6 / 4.1.0, Gantry 5.5.11, all Gantry templates, PHP 8.0.17, no cache, no SEO plugin, default Joomla installation without any change.

Steps to reproduce Go to the Gantry manager and try to use the Ajax Gantry Administration menu, for instance switch to another layout using the dropdown menu or click on any menu tab.

Actual result I can't switch to another layout or to any tab like "Page settings" or "Outlines" using the Ajax menu. Error message displayed in the console is /administrator/index.php?option=com_gantry5&view=configurations/default/layout&theme=g5_hydrogen&1f063fc9781ab3c5897745ec0c6=1&format=json net::ERR_CONTENT_DECODING_FAILED 200 (see screenshot). Note: the json link returns a blank page. Copy and paste the URL displayed in the console without the json parameter and it's working. It's happening on all my Joonla 3/4 sites using PHP 8.0.17. It has been working fine on PHP 8 until a few days ago. Wordpress sites are working fine.

How to temporarily solve it

console

uGE70 commented 2 years ago

Hello, After some debugging, I found that the menu is working with PHP 8.0.17 when output_buffering = On (Joomla is recommending output_buffering = Off). Alternatively, it is also working with output_buffering = Off, for testing purposes, if I remove lines 73-78 in /libraries/gantry5/src/classes/Gantry/Component/Response/JsonResponse.php while (($output = ob_get_clean()) !== false) { // In debug mode send also output buffers (debug dumps, PHP notices and warnings). if ($output && (GANTRY5_DEBUG || headers_sent())) { $this->messages['php'][] = $output; } }

mahagr commented 2 years ago

There's a bug in PHP 8.0.17 and PHP 8.1.4, see here https://github.com/php/php-src/issues/8218

uGE70 commented 2 years ago

Thanks, yes it seems the culprit is not output_buffering like I thought but: zlib.output_compression = On

mahagr commented 2 years ago

Yes, it's the output compression that is the issue. I hope they will fix the bug soon, though I may need to find a workaround in the meantime.

If you can, please use the previous version/patch from PHP or disable output compression from Joomla for now.