@@ -963,34 +963,13 @@ private static function get_clean_basedomain() {
963963 public function version ( $ args = [], $ assoc_args = [] ) {
964964 $ use_actual_db_version = Utils \get_flag_value ( $ assoc_args , 'actual ' );
965965
966- // If --actual flag is used, delegate to a command that runs after WP load
966+ // If --actual flag is used, load WordPress to query the database
967967 if ( $ use_actual_db_version ) {
968968 if ( ! Utils \get_flag_value ( $ assoc_args , 'extra ' ) ) {
969969 WP_CLI ::error ( 'The --actual flag can only be used with --extra. ' );
970970 }
971971
972- // Build the command to run after WP load
973- $ cmd_args = [];
974- foreach ( $ assoc_args as $ key => $ value ) {
975- if ( 'actual ' !== $ key ) {
976- if ( true === $ value ) {
977- $ cmd_args [] = '-- ' . $ key ;
978- } elseif ( is_string ( $ value ) ) {
979- // Escape the value to prevent command injection
980- $ cmd_args [] = '-- ' . $ key . '= ' . escapeshellarg ( $ value );
981- }
982- }
983- }
984- $ cmd = 'core version-db-actual ' . implode ( ' ' , $ cmd_args );
985-
986- WP_CLI ::runcommand (
987- $ cmd ,
988- [
989- 'launch ' => true ,
990- 'exit_error ' => true ,
991- ]
992- );
993- return ;
972+ WP_CLI ::get_runner ()->load_wordpress ();
994973 }
995974
996975 $ details = self ::get_wp_details ();
@@ -1000,45 +979,22 @@ public function version( $args = [], $assoc_args = [] ) {
1000979 return ;
1001980 }
1002981
1003- echo Utils \mustache_render (
1004- self ::get_template_path ( 'versions.mustache ' ),
1005- [
1006- 'wp-version ' => $ details ['wp_version ' ],
1007- 'db-version ' => $ details ['wp_db_version ' ],
1008- 'local-package ' => empty ( $ details ['wp_local_package ' ] )
1009- ? 'en_US '
1010- : $ details ['wp_local_package ' ],
1011- 'mce-version ' => self ::format_tinymce_version ( $ details ['tinymce_version ' ] ),
1012- ]
1013- );
1014- }
1015-
1016- /**
1017- * Helper command to display actual database version (runs after WP load).
1018- *
1019- * This is an internal command called by 'core version --actual'.
1020- *
1021- * @subcommand version-db-actual
1022- * @when after_wp_load
1023- *
1024- * @param string[] $args Positional arguments. Unused.
1025- * @param array{extra?: bool} $assoc_args Associative arguments passed through from version command.
1026- */
1027- public function version_db_actual ( $ args = [], $ assoc_args = [] ) {
1028- $ details = self ::get_wp_details ();
1029-
1030- // Get the actual database version from the options table
1031- /**
1032- * @var string $actual_db_version
1033- */
1034- $ actual_db_version = get_option ( 'db_version ' );
1035- $ actual_db_version = (int ) $ actual_db_version ;
982+ // Determine which database version to show
983+ $ db_version = $ details ['wp_db_version ' ];
984+ if ( $ use_actual_db_version ) {
985+ // Get the actual database version from the options table
986+ /**
987+ * @var string $actual_db_version
988+ */
989+ $ actual_db_version = get_option ( 'db_version ' );
990+ $ db_version = (int ) $ actual_db_version ;
991+ }
1036992
1037993 echo Utils \mustache_render (
1038994 self ::get_template_path ( 'versions.mustache ' ),
1039995 [
1040996 'wp-version ' => $ details ['wp_version ' ],
1041- 'db-version ' => $ actual_db_version ,
997+ 'db-version ' => $ db_version ,
1042998 'local-package ' => empty ( $ details ['wp_local_package ' ] )
1043999 ? 'en_US '
10441000 : $ details ['wp_local_package ' ],
0 commit comments