@@ -393,45 +393,32 @@ function () use ( $temp ) {
393393 * @param array{network?: bool} $assoc_args Associative arguments.
394394 */
395395 public function is_installed ( $ args , $ assoc_args ) {
396- // Check if WordPress is installed by verifying required tables exist.
397- if ( ! function_exists ( 'is_blog_installed ' ) ) {
398- require_once ABSPATH . 'wp-includes/load.php ' ;
399- }
400-
401396 if ( is_blog_installed () && ( ! Utils \get_flag_value ( $ assoc_args , 'network ' ) || is_multisite () ) ) {
402397 global $ wpdb ;
403- // List of required core tables (prefix will be added automatically)
404- $ required_tables = [
405- 'options ' ,
406- 'users ' ,
407- 'usermeta ' ,
408- 'posts ' ,
409- 'comments ' ,
410- 'commentmeta ' ,
411- 'terms ' ,
412- 'termmeta ' ,
413- 'term_taxonomy ' ,
414- 'term_relationships ' ,
415- 'links ' ,
416- 'postmeta ' ,
417- ];
398+
399+ // Get core tables from $wpdb
400+ $ tables = $ wpdb ->tables ();
418401 $ missing_tables = [];
419- foreach ( $ required_tables as $ table ) {
402+
403+ // Check if all core tables exist
404+ foreach ( $ tables as $ table ) {
420405 $ table_name = $ wpdb ->prefix . $ table ;
421- // Check if table exists
422406 $ result = $ wpdb ->get_var ( $ wpdb ->prepare (
423407 "SHOW TABLES LIKE %s " , $ table_name
424408 ) );
409+
425410 if ( $ result !== $ table_name ) {
426411 $ missing_tables [] = $ table_name ;
427412 }
428413 }
414+
429415 if ( ! empty ( $ missing_tables ) ) {
430- // Output missing tables for debugging
431416 WP_CLI ::error ( "WordPress is not installed. Missing tables: " . implode ( ', ' , $ missing_tables ), 1 );
432417 }
418+
433419 WP_CLI ::halt ( 0 );
434420 }
421+
435422 WP_CLI ::halt ( 1 );
436423 }
437424
0 commit comments