wodby / php

Generic PHP docker container images
MIT License
155 stars 103 forks source link

XDebug 3.3.0 in 4.41.0 causing CI failures #188

Closed wimleers closed 10 months ago

wimleers commented 11 months ago

👋 Thanks for the awesome work you do with wodby/php — it really made my CI setup easy peasy 😊 🙏

It's been working great for months. Until today.

CI failures

Crash:

PHP Fatal error:  Uncaught Error: Call to a member function commit() on null in /tmp/test-general-installability/web/core/lib/Drupal/Core/Database/Connection.php:1739
Stack trace:
#0 /tmp/test-general-installability/web/core/lib/Drupal/Core/Database/Connection.php(1725): Drupal\Core\Database\Connection->doCommit()
#1 /tmp/test-general-installability/web/core/lib/Drupal/Core/Database/Connection.php(1678): Drupal\Core\Database\Connection->popCommittableTransactions()
#2 /tmp/test-general-installability/web/core/lib/Drupal/Core/Database/Transaction.php(71): Drupal\Core\Database\Connection->popTransaction()
#3 [internal function]: Drupal\Core\Database\Transaction->__destruct()
#4 {main}
  thrown in /tmp/test-general-installability/web/core/lib/Drupal/Core/Database/Connection.php on line 1739

Analysis

🤔 What could be happening? Nothing has changed overnight. 🤯

Yesterday:

PHP 8.1.26 (cli) (built: Nov 27 2023 23:37:27) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.26, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.26, Copyright (c), by Zend Technologies
    with Xdebug v3.2.2, Copyright (c) 2002-2023, by Derick Rethans

Today:

PHP 8.1.26 (cli) (built: Dec  1 2023 00:24:07) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.26, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.26, Copyright (c), by Zend Technologies
    with Xdebug v3.3.0, Copyright (c) 2002-2023, by Derick Rethans

Hence this most likely caused by https://github.com/wodby/php/releases/tag/4.41.0 updating XDebug to 3.3.0.

wimleers commented 11 months ago

Of course, this seems like an XDebug 3.3.0 regression. But if this a known issue, perhaps it'd be wise to hold off to reduce ecosystem impact?

csandanov commented 11 months ago

Hi, as I understand your main issue is that xdebug was enabled because of PHP_XDEBUG=0 (the env var should be unset) and despite PHP_XDEBUG_MODE=off it still affected your build (maybe should be reported at https://bugs.xdebug.org/)

I recommend using this image with the stability tag, e.g. wodby/php:8.1-dev-4.40.9

wimleers commented 11 months ago

Thank you! I tried that a minute before I saw your message here — and did it wrong 😅

Did what you suggested 👍

In the 30 mins since reporting this, somebody in Drupal pointed me to https://www.drupal.org/project/drupal/issues/3405976, where this is apparently a thing affecting all Drupal versions but only in certain XDebug modes. Derick himself is present in helping getting this sorted out.

Thanks for the incredibly fast response! 🤯 🙏 😊

wimleers commented 11 months ago

Ah, but looks like I can't just do wodby/php:$_TARGET_PHP-dev-4.40.9 because that won't work for PHP 7.4, which I still need to test. Result: Docker failures.

So back to figuring out how to disable XDebug … or perhaps just XDEBUG_MODE=coverage is sufficient per https://www.drupal.org/project/drupal/issues/3405976#comment-15348344.

csandanov commented 11 months ago

Did you try to unset PHP_XDEBUG env var to completely disable xdebug extension? (this is why we introduced this var in addition to the XDEBUG_MODE)

Also, I don't know it it's possible in your pipeline, but you can maybe set different image tags for different PHP versions, like the last tag where we still had PHP 7.4 was 4.33.4 which would be wodby/php:7.4-dev-4.33.4

wimleers commented 11 months ago

I never set PHP_XDEBUG. I'm not sure I can unset it in GitLab CI, as described at https://stackoverflow.com/a/55204041.

wimleers commented 11 months ago

… but I did just figure out a way to dynamically set the -4.40.9 suffix for only some PHP versions: https://git.drupalcode.org/project/acquia_migrate/-/merge_requests/14/diffs. 👍