Skip to content

fix(site): keep the fatal-error rollback working on PHP 8.5 - #507

Merged
mrrobot47 merged 1 commit into
EasyEngine:developfrom
mrrobot47:fix/shutdown-handler-php85
Sep 29, 2026
Merged

mrrobot47 merged 1 commit into
EasyEngine:developfrom
mrrobot47:fix/shutdown-handler-php85

Conversation

@mrrobot47

Copy link
Copy Markdown
Member

On PHP 8.5, ReflectionMethod::setAccessible() is deprecated. Shutdown_Handler::cleanup() called it before shut_down_function() read error_get_last(), so its deprecation notice (recorded even though error_reporting masks it) replaced the fatal error. The shutdown handler therefore never saw the fatal error, and a failed site create left its containers, volumes, network, database, DB user, files and hosts entry behind.

The fix calls setAccessible() only below PHP 8.1, where it still does something (it has been a no-op since 8.1), and reads error_get_last() first in cleanup() and passes it to shut_down_function(), so no notice raised later in the shutdown path can replace the fatal error.

Testing: the fatal-error rollback was verified on PHP 7.4 and 8.0 through 8.5, plus live on a PHP 8.5 host.

On PHP 8.5 ReflectionMethod::setAccessible() is deprecated. Shutdown_Handler::cleanup() called it before shut_down_function() read error_get_last(), so the E_DEPRECATED (recorded even though error_reporting masks it) replaced the fatal error, the E_ERROR check never matched, and a site create that died with a fatal error left its webroot, containers, volumes, network, database, user and hosts entry behind.

Call setAccessible() only before PHP 8.1, where it is still needed (it has no effect since 8.1), and read error_get_last() first in cleanup() and pass it to shut_down_function(), so no notice emitted later in the shutdown path can replace the fatal error.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused compatibility fix correctly preserves existing behavior across supported PHP versions.

Review effort: Balanced
Findings: None

What changed in this PR

Preserves fatal-error rollback across supported PHP versions, including PHP 8.5.

Changes:

  • Captures the fatal error before reflection operations.
  • Avoids deprecated setAccessible() calls on PHP 8.1+.
  • Passes the captured error into rollback handling.
File Description
src/​helper/​Shutdown_Handler.php Captures and forwards the original error safely.
src/​helper/​class-ee-site.php Accepts the captured error for rollback processing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mrrobot47
mrrobot47 merged commit b9820fc into EasyEngine:develop Sep 29, 2026
0 of 4 checks passed
@mrrobot47
mrrobot47 deleted the fix/shutdown-handler-php85 branch September 30, 2026 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants