DatabaseState::version( $wpdb ), 'layout' => DatabaseState::layout( $wpdb ), 'maintenance' => ( new OfflineGate( $wpdb ) )->active(), 'server' => \ABeCe\Booking\Support\DatabaseCompatibility::inspect( $wpdb ), ); \WP_CLI::line( wp_json_encode( $result, JSON_PRETTY_PRINT ) ); } catch ( \Throwable $error ) { self::failure( $error ); } } /** * Migrate or resume schema12 after stopping external workers. * * ## OPTIONS * * --backup-dir= * : Existing private0700 directory outside WordPress and Git. * * --verification-db= * : Dedicated empty database named abece_booking_verify_. * * [--yes] * : Confirm that external cron/queues are stopped and site workers can drain. * * @param array $args Positional arguments. * @param array $assoc Named CLI arguments. * @return void */ public function migrate( array $args, array $assoc ): void { global $wpdb; \WP_CLI::confirm( __( 'Stop external cron and queue workers before continuing. A verified SQL backup will be created and the site will remain in maintenance if an error occurs. Continue?', 'abece-booking' ), $assoc ); try { $result = ( new SchemaUpgrade( $wpdb ) )->run( $assoc['backup-dir'] ?? '', $assoc['verification-db'] ?? '' ); \WP_CLI::line( wp_json_encode( $result, JSON_PRETTY_PRINT ) ); } catch ( \Throwable $error ) { self::failure( $error ); } } /** @param \Throwable $error Controlled workflow failure. @return void */ private static function failure( \Throwable $error ): void { $code = preg_match( '/^ABECE_BOOKING_[A-Z0-9_]+$/D', $error->getMessage() ) ? $error->getMessage() : 'ABECE_BOOKING_DATABASE_MAINTENANCE_FAILED'; \WP_CLI::error( $code . ': ' . __( 'Database maintenance did not complete. No success state was fabricated. Keep maintenance enabled and use the documented recovery procedure.', 'abece-booking' ) ); } }