File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -1684,8 +1684,16 @@ private function require_upgrade_file( $context = 'WordPress operation' ) {
16841684 WP_CLI ::error ( "Cannot read WordPress installation file ' {$ upgrade_file }'. Check file permissions. " );
16851685 }
16861686
1687+ // Use a flag to track successful completion and prevent handler from executing after success.
1688+ $ require_completed = false ;
1689+
16871690 // Register a shutdown function to catch fatal errors during require_once.
1688- $ shutdown_handler = function () use ( $ context ) {
1691+ $ shutdown_handler = function () use ( $ context , &$ require_completed ) {
1692+ // Only handle errors if require_once did not complete successfully.
1693+ if ( $ require_completed ) {
1694+ return ;
1695+ }
1696+
16891697 $ error = error_get_last ();
16901698 if (
16911699 null !== $ error
@@ -1731,5 +1739,8 @@ private function require_upgrade_file( $context = 'WordPress operation' ) {
17311739
17321740 // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable -- Path comes from WordPress itself.
17331741 require_once $ upgrade_file ;
1742+
1743+ // Mark as completed to prevent the shutdown handler from executing on unrelated errors.
1744+ $ require_completed = true ;
17341745 }
17351746}
You can’t perform that action at this time.
0 commit comments