Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/helper/Shutdown_Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ class Shutdown_Handler {
* @param array $site_command having Site_Command object.
*/
public function cleanup( $site_command ) {
// Read it first: any later notice, even a masked one, replaces the fatal in error_get_last().
$error = error_get_last();
$reflector = new \ReflectionObject( $site_command[0] );
$method = $reflector->getMethod( 'shut_down_function' );
$method->setAccessible( true );
$method->invoke( $site_command[0] );
// A no-op since PHP 8.1 and deprecated in 8.5.
if ( PHP_VERSION_ID < 80100 ) {
$method->setAccessible( true );
}
$method->invoke( $site_command[0], $error );
}
}
8 changes: 6 additions & 2 deletions src/helper/class-ee-site.php
Original file line number Diff line number Diff line change
Expand Up @@ -2395,11 +2395,15 @@ private function ngrok_curl( $get_url = true, $refresh = false ) {

/**
* Shutdown function to catch and rollback from fatal errors.
*
* @param array|null $error The error_get_last() result, read before anything else in the shutdown path.
*/
protected function shut_down_function() {
protected function shut_down_function( $error = null ) {

if ( null === $error ) {
$error = error_get_last();
}
$logger = \EE::get_file_logger()->withName( 'site-command' );
$error = error_get_last();

// Check if the $this->site_data is set and it is array and $this->site_data['site_url'] is set.
if ( isset( $this->site_data ) && is_array( $this->site_data ) && isset( $this->site_data['site_url'] ) ) {
Expand Down
Loading