Problem/Motivation
After upgrading to Drupal 10.1 JavaScript is no longer aggregated correctly if xdebug
is installed.
Steps to reproduce
- Create a
docker
Ubuntu container with Apache2, PHP 8.1 - Install
php-xdebug
(apt install -y php-xdebug
) - Drop your favorite Drupal 10.1 site into the container
- Load pages from the site
- Examine the apache error logs
At step 4 I noticed that none of the portions of the site's pages which depend on JavaScript looked or behaved correctly. I examined the aggregated JavaScript and saw that it contained almost none of the site's code. Aggregation had apparently failed after collecting a single line of JavaScript. At step 5 (examine the apache error logs) I found:
PHP Warning: Uncaught Error: Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames in /var/www/vendor/mck89/peast/lib/Peast/Syntax/Utils.php:93
I went into the site's configuration and turned off JS and CSS aggregation and the problems disappeared.
I turned aggregation back on and the site was broken again.
I then found /etc/php/8.1/mods-available/xdebug.ini which had a single line:
zend_extension=xdebug.so
Note that the failures occurred without having configured xdebug
to actually enable remote debugging. It was enough that PHP could find the DLL for the module. I commented out that line, restarted Apache, and aggregation worked again.
Rolling back from 10.1.0 to 10.0.9 also eliminated the failure.
Proposed resolution
Restore the ability to use xdebug
with aggregation enabled.