[php-src] PR #18541: Fix error handling during opcache compilation

From: Date: Mon, 12 May 2025 12:18:22 +0000
Subject: [php-src] PR #18541: Fix error handling during opcache compilation
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-31669@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/18541 Author: arnaud-lb Possible fix for GH-17422 Based on https://github.com/php/php-src/pull/17627 Currently, Opcache disables the user-defined error handler during compilation. When opcache.record_errors is enabled, errors are replayed when loading the script from cache later, this time without disabling the user-defined error handler. This PR makes the following changes: Errors emitted during compilation are delayed and handled after compilation, when it's safe to execute user-defined error handlers. As before, when opcache.record_errors is enabled, errors are also replayed when loading the script from cache and user-defined error handler are called, if any. This is done by changing the EG(record_errors) mechanism so that errors are not only recorded, but also delayed. Class linking: Since class linking uses the same mechanism, errors emitted during class linking are also delayed (with or without Opcache), and replayed after linking. Exceptions thrown by user-defined error handlers are not promoted to fatal errors anymore. Fatal errors: Fatal errors are not safe to delay, so they are always processed immediately. Any delayed errors are also processed, but unfortunately it's not safe to execute user-defined error handlers at this point, so these errors still bypass them. This targets master because of the behavior changes. UPGRADING draft: ``` * Errors emitted during compilation are now handled after compilation when Opcache is enabled, and user-defined error handlers are called, if any. Before, user-defined error handlers were not called for error emitted during compilation. * Errors emitted during class linking are now handled after linking. Exception thrown by user-defined error handler while handling these errors are not promoted to fatal errors anymore and do not prevent linking. * Fatal errors emitted during compilation or class linking cause any delayed error to be handled immediately, without calling user-defined error handlers. ```

« previous php.git-pulls (#31669) next »