Skip to content

Commit 6fc1337

Browse files
Copilotswissspidy
andcommitted
Improve error message to clarify WordPress core vs plugin/theme errors
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 0314e92 commit 6fc1337

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

‎features/core-install.feature‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,11 @@ Feature: Install WordPress core
414414
"""
415415
And STDERR should contain:
416416
"""
417-
This often indicates a missing PHP extension or a corrupted WordPress installation
417+
This error is in WordPress core files, not a plugin or theme
418+
"""
419+
And STDERR should contain:
420+
"""
421+
It often indicates a missing PHP extension (like mysqli)
418422
"""
419423
And STDERR should contain:
420424
"""

‎src/Core_Command.php‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,15 +1853,19 @@ private function require_upgrade_file( $context = 'WordPress operation' ) {
18531853
false !== strpos( $error['file'], 'wp-admin/includes/' )
18541854
|| false !== strpos( $error['file'], 'wp-includes/' )
18551855
) {
1856-
WP_CLI::error(
1857-
sprintf(
1858-
"Failed to load WordPress files for %s. This often indicates a missing PHP extension or a corrupted WordPress installation.\n\nError: %s in %s on line %d\n\nPlease check that all required PHP extensions are installed and that your WordPress installation is complete.",
1859-
$context,
1860-
$error['message'],
1861-
$error['file'],
1862-
$error['line']
1863-
)
1856+
// Provide a more specific error message for WordPress core file errors
1857+
// before WP-CLI's generic shutdown handler runs
1858+
$message = sprintf(
1859+
"Failed to load WordPress files for %s.\n\nError: %s in %s on line %d\n\nThis error is in WordPress core files, not a plugin or theme.\nIt often indicates a missing PHP extension (like mysqli) or corrupted WordPress installation.\n\nPlease check that all required PHP extensions are installed and that your WordPress installation is complete.",
1860+
$context,
1861+
$error['message'],
1862+
$error['file'],
1863+
$error['line']
18641864
);
1865+
1866+
// Output directly and exit to avoid WP-CLI's generic plugin/theme suggestion
1867+
fwrite( STDERR, "Error: {$message}\n" );
1868+
exit( 1 );
18651869
}
18661870
}
18671871
};

0 commit comments

Comments
 (0)