From 8b593b97cc22e33452f10f5b8edccef7b2d7d628 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Tue, 20 Oct 2026 11:36:02 -0300 Subject: [PATCH 1/2] Backup: remove the four REST routes only the legacy dashboard called Remove backup-capabilities, has-backup-plan, site/current-purchases and site/dismissed-review-request. Bump the Backup namespace V0005 to V0006 so a stale copy loaded by another autoloader cannot register the old set. Co-Authored-By: Claude Sonnet 5.5 --- .../remove-jetpack-2314-backup-legacy-routes | 4 + .../src/class-helper-script-manager-impl.php | 2 +- .../src/class-helper-script-manager.php | 2 +- .../src/class-throw-on-errors.php | 2 +- .../php/Helper_Script_Manager_Impl_Test.php | 2 +- .../tests/php/Throw_On_Errors_Test.php | 2 +- projects/packages/backup/actions.php | 8 +- .../remove-jetpack-2314-backup-legacy-routes | 4 + .../src/abilities/class-backup-abilities.php | 4 +- .../src/class-jetpack-backup-upgrades.php | 2 +- .../backup/src/class-jetpack-backup.php | 146 +----------------- .../backup/src/class-rest-controller.php | 2 +- .../src/rest/class-activity-log-bridge.php | 2 +- .../src/rest/class-backup-sizes-bridge.php | 2 +- .../src/rest/class-capabilities-bridge.php | 5 +- .../backup/src/rest/class-download-bridge.php | 2 +- .../src/rest/class-file-browser-bridge.php | 2 +- .../backup/src/rest/class-rest-controller.php | 4 +- .../backup/src/rest/class-restore-bridge.php | 2 +- .../src/rest/class-retention-bridge.php | 2 +- .../backup/src/rest/class-schedule-bridge.php | 2 +- .../php/Admin_Modernization_Gating_Test.php | 4 +- .../php/Admin_Notices_Suppression_Test.php | 4 +- .../php/Jetpack_Backup_Init_Options_Test.php | 6 +- .../backup/tests/php/Jetpack_Backup_Test.php | 123 +-------------- .../backup/tests/php/REST_Controller_Test.php | 6 +- .../php/Rest_Activity_Log_Bridge_Test.php | 4 +- .../php/Rest_Backup_Sizes_Bridge_Test.php | 4 +- .../tests/php/Rest_Bridge_Dispatch_Test.php | 4 +- .../tests/php/Rest_Bridge_Gating_Test.php | 6 +- .../php/Rest_Capabilities_Bridge_Test.php | 4 +- .../tests/php/Rest_Download_Bridge_Test.php | 4 +- .../php/Rest_File_Browser_Bridge_Test.php | 4 +- .../tests/php/Rest_Restore_Bridge_Test.php | 4 +- .../tests/php/Rest_Retention_Bridge_Test.php | 4 +- .../tests/php/Rest_Schedule_Bridge_Test.php | 4 +- .../tests/php/Storage_Addon_Upsell_Test.php | 2 +- .../php/abilities/Backup_Abilities_Test.php | 4 +- .../tests/php/trait-wpcom-request-mock.php | 2 +- .../packages/transport-helper/actions.php | 2 +- .../remove-jetpack-2314-backup-legacy-routes | 4 + .../src/class-rest-controller.php | 2 +- .../remove-jetpack-2314-backup-legacy-routes | 4 + projects/plugins/backup/jetpack-backup.php | 4 +- .../remove-jetpack-2314-backup-legacy-routes | 4 + projects/plugins/jetpack/class.jetpack.php | 2 +- ...i-delete-backup-helper-script-endpoint.php | 2 +- ...-install-backup-helper-script-endpoint.php | 2 +- .../php/general/Jetpack_Admin_Menu_Test.php | 2 +- .../Jetpack_Eager_Load_Packages_Test.php | 6 +- projects/plugins/jetpack/uninstall.php | 2 +- 51 files changed, 102 insertions(+), 330 deletions(-) create mode 100644 projects/packages/backup-helper-script-manager/changelog/remove-jetpack-2314-backup-legacy-routes create mode 100644 projects/packages/backup/changelog/remove-jetpack-2314-backup-legacy-routes create mode 100644 projects/packages/transport-helper/changelog/remove-jetpack-2314-backup-legacy-routes create mode 100644 projects/plugins/backup/changelog/remove-jetpack-2314-backup-legacy-routes create mode 100644 projects/plugins/jetpack/changelog/remove-jetpack-2314-backup-legacy-routes diff --git a/projects/packages/backup-helper-script-manager/changelog/remove-jetpack-2314-backup-legacy-routes b/projects/packages/backup-helper-script-manager/changelog/remove-jetpack-2314-backup-legacy-routes new file mode 100644 index 000000000000..deb24dcea2dc --- /dev/null +++ b/projects/packages/backup-helper-script-manager/changelog/remove-jetpack-2314-backup-legacy-routes @@ -0,0 +1,4 @@ +Significance: patch +Type: changed +Comment: Follow the Backup namespace version bump from V0005 to V0006; no user-facing change. + diff --git a/projects/packages/backup-helper-script-manager/src/class-helper-script-manager-impl.php b/projects/packages/backup-helper-script-manager/src/class-helper-script-manager-impl.php index 9cd06aa57719..534d088c71f6 100644 --- a/projects/packages/backup-helper-script-manager/src/class-helper-script-manager-impl.php +++ b/projects/packages/backup-helper-script-manager/src/class-helper-script-manager-impl.php @@ -9,7 +9,7 @@ // order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide // to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin // are installed, or in some other cases). -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; use Exception; use WP_Error; diff --git a/projects/packages/backup-helper-script-manager/src/class-helper-script-manager.php b/projects/packages/backup-helper-script-manager/src/class-helper-script-manager.php index 650f2e3c368d..ff4b0bca0299 100644 --- a/projects/packages/backup-helper-script-manager/src/class-helper-script-manager.php +++ b/projects/packages/backup-helper-script-manager/src/class-helper-script-manager.php @@ -9,7 +9,7 @@ // order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide // to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin // are installed, or in some other cases). -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; /** * Manage installation, deletion and cleanup of Helper Scripts to assist with backing up Jetpack Sites. diff --git a/projects/packages/backup-helper-script-manager/src/class-throw-on-errors.php b/projects/packages/backup-helper-script-manager/src/class-throw-on-errors.php index af04898211e7..e8afd4305a82 100644 --- a/projects/packages/backup-helper-script-manager/src/class-throw-on-errors.php +++ b/projects/packages/backup-helper-script-manager/src/class-throw-on-errors.php @@ -8,7 +8,7 @@ // order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide // to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin // are installed, or in some other cases). -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; use Exception; use Throwable; diff --git a/projects/packages/backup-helper-script-manager/tests/php/Helper_Script_Manager_Impl_Test.php b/projects/packages/backup-helper-script-manager/tests/php/Helper_Script_Manager_Impl_Test.php index ff035c88a741..e349627c3564 100644 --- a/projects/packages/backup-helper-script-manager/tests/php/Helper_Script_Manager_Impl_Test.php +++ b/projects/packages/backup-helper-script-manager/tests/php/Helper_Script_Manager_Impl_Test.php @@ -9,7 +9,7 @@ // order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide // to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin // are installed, or in some other cases). -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; use Exception; use WorDBless\BaseTestCase; diff --git a/projects/packages/backup-helper-script-manager/tests/php/Throw_On_Errors_Test.php b/projects/packages/backup-helper-script-manager/tests/php/Throw_On_Errors_Test.php index 5987155e7352..37cd4056b3bb 100644 --- a/projects/packages/backup-helper-script-manager/tests/php/Throw_On_Errors_Test.php +++ b/projects/packages/backup-helper-script-manager/tests/php/Throw_On_Errors_Test.php @@ -9,7 +9,7 @@ // order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide // to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin // are installed, or in some other cases). -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; use Exception; use PHPUnit\Framework\TestCase; diff --git a/projects/packages/backup/actions.php b/projects/packages/backup/actions.php index 09fcc67f575b..438f2c0e10e1 100644 --- a/projects/packages/backup/actions.php +++ b/projects/packages/backup/actions.php @@ -23,10 +23,10 @@ } // Clean up expired Helper Scripts from a scheduled event. -$add_action( 'jetpack_backup_cleanup_helper_scripts', array( 'Automattic\\Jetpack\\Backup\\V0005\\Helper_Script_Manager', 'cleanup_expired_helper_scripts' ) ); +$add_action( 'jetpack_backup_cleanup_helper_scripts', array( 'Automattic\\Jetpack\\Backup\\V0006\\Helper_Script_Manager', 'cleanup_expired_helper_scripts' ) ); // Register REST routes. -$add_action( 'rest_api_init', array( 'Automattic\\Jetpack\\Backup\\V0005\\REST_Controller', 'register_rest_routes' ) ); +$add_action( 'rest_api_init', array( 'Automattic\\Jetpack\\Backup\\V0006\\REST_Controller', 'register_rest_routes' ) ); // Set up package version hook. $add_filter( 'jetpack_package_versions', 'Automattic\\Jetpack\\Backup\\Package_Version::send_package_version_to_tracker' ); @@ -42,10 +42,10 @@ static function () { if ( ! apply_filters( 'jetpack_wp_abilities_enabled', false ) ) { return; } - if ( ! class_exists( \Automattic\Jetpack\Backup\V0005\Abilities\Backup_Abilities::class ) ) { + if ( ! class_exists( \Automattic\Jetpack\Backup\V0006\Abilities\Backup_Abilities::class ) ) { return; } - \Automattic\Jetpack\Backup\V0005\Abilities\Backup_Abilities::init(); + \Automattic\Jetpack\Backup\V0006\Abilities\Backup_Abilities::init(); }, 20 ); diff --git a/projects/packages/backup/changelog/remove-jetpack-2314-backup-legacy-routes b/projects/packages/backup/changelog/remove-jetpack-2314-backup-legacy-routes new file mode 100644 index 000000000000..ef1308e4c0fd --- /dev/null +++ b/projects/packages/backup/changelog/remove-jetpack-2314-backup-legacy-routes @@ -0,0 +1,4 @@ +Significance: patch +Type: removed + +Remove the `backup-capabilities`, `has-backup-plan`, `site/current-purchases` and `site/dismissed-review-request` REST routes. Only the legacy dashboard called them. diff --git a/projects/packages/backup/src/abilities/class-backup-abilities.php b/projects/packages/backup/src/abilities/class-backup-abilities.php index 7c6023a3ca23..b624a52dcc87 100644 --- a/projects/packages/backup/src/abilities/class-backup-abilities.php +++ b/projects/packages/backup/src/abilities/class-backup-abilities.php @@ -9,9 +9,9 @@ * @package automattic/jetpack-backup */ -namespace Automattic\Jetpack\Backup\V0005\Abilities; +namespace Automattic\Jetpack\Backup\V0006\Abilities; -use Automattic\Jetpack\Backup\V0005\Jetpack_Backup; +use Automattic\Jetpack\Backup\V0006\Jetpack_Backup; use Automattic\Jetpack\My_Jetpack\Products\Backup as My_Jetpack_Backup; use Automattic\Jetpack\WP_Abilities\Registrar; use WP_Error; diff --git a/projects/packages/backup/src/class-jetpack-backup-upgrades.php b/projects/packages/backup/src/class-jetpack-backup-upgrades.php index be18aede8284..8af313fb061a 100644 --- a/projects/packages/backup/src/class-jetpack-backup-upgrades.php +++ b/projects/packages/backup/src/class-jetpack-backup-upgrades.php @@ -9,7 +9,7 @@ // order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide // to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin // are installed, or in some other cases). -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; use function get_option; use function update_option; diff --git a/projects/packages/backup/src/class-jetpack-backup.php b/projects/packages/backup/src/class-jetpack-backup.php index aa30af60c6ec..484aa15c4098 100644 --- a/projects/packages/backup/src/class-jetpack-backup.php +++ b/projects/packages/backup/src/class-jetpack-backup.php @@ -9,7 +9,7 @@ // order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide // to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin // are installed, or in some other cases). -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; if ( ! defined( 'ABSPATH' ) ) { exit( 0 ); @@ -173,7 +173,7 @@ public static function initialize( array $options = array() ) { $options = array_merge( self::DEFAULT_INIT_OPTIONS, $options ); add_action( 'rest_api_init', array( __CLASS__, 'register_rest_routes' ) ); - add_action( 'rest_api_init', array( \Automattic\Jetpack\Backup\V0005\REST\Rest_Controller::class, 'register_routes' ) ); + add_action( 'rest_api_init', array( \Automattic\Jetpack\Backup\V0006\REST\Rest_Controller::class, 'register_routes' ) ); add_filter( 'jetpack_activity_log_restore_url_template', array( __CLASS__, 'activity_log_restore_url_template' ) ); add_filter( 'jetpack_activity_log_backup_url_template', array( __CLASS__, 'activity_log_backup_url_template' ) ); @@ -401,28 +401,6 @@ public static function register_rest_routes() { ) ); - // Get site backup/scan/anti-spam capabilities. - register_rest_route( - 'jetpack/v4', - '/backup-capabilities', - array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => __CLASS__ . '::get_backup_capabilities', - 'permission_callback' => __CLASS__ . '::backups_permissions_callback', - ) - ); - - // Get whether the site has a backup plan - register_rest_route( - 'jetpack/v4', - '/has-backup-plan', - array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => __CLASS__ . '::get_backup_plan_state', - 'permission_callback' => __CLASS__ . '::backups_permissions_callback', - ) - ); - // Get site rewind data. register_rest_route( 'jetpack/v4', @@ -434,19 +412,6 @@ public static function register_rest_routes() { ) ); - // Get information on site products. - // Backup plugin version of /site/purchases from JP plugin. - // Revert once this route and MyPlan component are extracted to a common package. - register_rest_route( - 'jetpack/v4', - '/site/current-purchases', - array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => __CLASS__ . '::get_site_current_purchases', - 'permission_callback' => __CLASS__ . '::backups_permissions_callback', - ) - ); - // Get currently promoted product from the product's endpoint. register_rest_route( 'jetpack/v4', @@ -458,34 +423,6 @@ public static function register_rest_routes() { ) ); - // Get and set value of dismissed_backup_review_request option - register_rest_route( - 'jetpack/v4', - '/site/dismissed-review-request', - array( - 'methods' => WP_REST_Server::EDITABLE, - 'callback' => __CLASS__ . '::manage_dismissed_backup_review_request', - 'permission_callback' => __CLASS__ . '::backups_permissions_callback', - 'args' => array( - 'option_name' => array( - 'required' => true, - 'type' => 'string', - // The two names `Jetpack_Options` recognises. Anything else - // falls through its allowlist to a `trigger_error()` and is - // stored nowhere, so an unlisted reason would dismiss - // nothing while answering as though it had — and on a site - // with `display_errors` on, the warning is printed ahead of - // the JSON and the response no longer parses. - 'enum' => array( 'restore', 'backups' ), - ), - 'should_dismiss' => array( - 'required' => true, - 'type' => 'boolean', - ), - ), - ) - ); - // Get site size register_rest_route( 'jetpack/v4', @@ -718,36 +655,6 @@ public static function has_backup_plan() { return ! is_wp_error( $state ) && $state; } - /** - * Get an array of backup/scan/anti-spam site capabilities - * - * @access public - * @static - * - * @return \WP_REST_Response|WP_Error The site capabilities, or a WP_Error if WordPress.com could not be reached. - */ - public static function get_backup_capabilities() { - $blog_id = Jetpack_Options::get_option( 'id' ); - - $response = Client::wpcom_json_api_request_as_user( - '/sites/' . $blog_id . '/rewind/capabilities', - 'v2', - array(), - null, - 'wpcom' - ); - - $response_code = (int) wp_remote_retrieve_response_code( $response ); - - if ( 200 !== $response_code ) { - return self::get_failed_fetch_error( $response ); - } - - return rest_ensure_response( - json_decode( $response['body'], true ) - ); - } - /** * Get information about recent restores * @@ -936,53 +843,6 @@ public static function jetpack_check_user_licenses( $has_license, $licenses, $pl return $license_found && ! static::has_backup_plan(); } - /** - * Returns the result of `/upgrades` endpoint call. - * - * @return \WP_REST_Response|WP_Error The site purchases, or a WP_Error if WordPress.com could not be reached. - */ - public static function get_site_current_purchases() { - - $request = sprintf( '/upgrades?site=%d', Jetpack_Options::get_option( 'id' ) ); - $response = Client::wpcom_json_api_request_as_blog( $request, '1.2' ); - - // Bail if there was an error or malformed response. - if ( is_wp_error( $response ) || ! is_array( $response ) || ! isset( $response['body'] ) ) { - return self::get_failed_fetch_error( $response ); - } - - $response_code = (int) wp_remote_retrieve_response_code( $response ); - - if ( 200 !== $response_code ) { - return self::get_failed_fetch_error( $response ); - } - - return rest_ensure_response( - json_decode( $response['body'], true ) - ); - } - - /** - * Set value of the dismissed_backup_review_request Jetack option. - * Get value if should_dismiss is false - * - * @access public - * @static - * @param array $request arguments should_dismiss and option_name. - * @return bool value of option if value is requested | updated or not if value is updated. - */ - public static function manage_dismissed_backup_review_request( $request ) { - - if ( ! $request['should_dismiss'] ) { - - return rest_ensure_response( - Jetpack_Options::get_option( 'dismissed_backup_review_' . $request['option_name'] ) - ); - } - - return Jetpack_Options::update_option( 'dismissed_backup_review_' . $request['option_name'], true ); - } - /** * Get site storage size * @@ -1222,7 +1082,7 @@ public static function render_connection_initial_state() { . wp_json_encode( array( 'activityLogUrl' => self::get_activity_log_url(), - 'knownThreatsAvailable' => \Automattic\Jetpack\Backup\V0005\REST\Restore_Bridge::known_threats_available(), + 'knownThreatsAvailable' => \Automattic\Jetpack\Backup\V0006\REST\Restore_Bridge::known_threats_available(), ), JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- wp_json_encode() with JSON_HEX_* flags is safe in a script tag. diff --git a/projects/packages/backup/src/class-rest-controller.php b/projects/packages/backup/src/class-rest-controller.php index 13e24dce9d86..8b28abc07b91 100644 --- a/projects/packages/backup/src/class-rest-controller.php +++ b/projects/packages/backup/src/class-rest-controller.php @@ -10,7 +10,7 @@ // order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide // to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin // are installed, or in some other cases). -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\Connection\Rest_Authentication; diff --git a/projects/packages/backup/src/rest/class-activity-log-bridge.php b/projects/packages/backup/src/rest/class-activity-log-bridge.php index 3a4fd36fe4d3..af1c7493a99d 100644 --- a/projects/packages/backup/src/rest/class-activity-log-bridge.php +++ b/projects/packages/backup/src/rest/class-activity-log-bridge.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use Automattic\Jetpack\Connection\Client; use WP_Error; diff --git a/projects/packages/backup/src/rest/class-backup-sizes-bridge.php b/projects/packages/backup/src/rest/class-backup-sizes-bridge.php index 9e7bc671150a..3c08e8118f69 100644 --- a/projects/packages/backup/src/rest/class-backup-sizes-bridge.php +++ b/projects/packages/backup/src/rest/class-backup-sizes-bridge.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use Automattic\Jetpack\Connection\Client; use WP_Error; diff --git a/projects/packages/backup/src/rest/class-capabilities-bridge.php b/projects/packages/backup/src/rest/class-capabilities-bridge.php index b74c5d31ad9c..1874b50ff29c 100644 --- a/projects/packages/backup/src/rest/class-capabilities-bridge.php +++ b/projects/packages/backup/src/rest/class-capabilities-bridge.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use Automattic\Jetpack\Connection\Client; use WP_Error; @@ -41,8 +41,7 @@ public static function register_routes() { * Proxy `/sites/{id}/rewind/capabilities` (v2, as_user) and project * the response into the shape the React layer expects. * - * This is the same endpoint the legacy `/jetpack/v4/backup-capabilities` - * route hits — it returns a flat `{ capabilities: [...] }` envelope. + * This endpoint returns a flat `{ capabilities: [...] }` envelope. * The earlier `/rewind?force=wpcom` variant returns site *state*, not * a capabilities list, and on some plan shapes (e.g. Jetpack Complete) * the `capabilities` key is missing entirely, which produced a false diff --git a/projects/packages/backup/src/rest/class-download-bridge.php b/projects/packages/backup/src/rest/class-download-bridge.php index 5df8176b8bcd..0566eefcc7e8 100644 --- a/projects/packages/backup/src/rest/class-download-bridge.php +++ b/projects/packages/backup/src/rest/class-download-bridge.php @@ -6,7 +6,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use Automattic\Jetpack\Connection\Client; use WP_Error; diff --git a/projects/packages/backup/src/rest/class-file-browser-bridge.php b/projects/packages/backup/src/rest/class-file-browser-bridge.php index 945fafa5dcfb..01214dafdd09 100644 --- a/projects/packages/backup/src/rest/class-file-browser-bridge.php +++ b/projects/packages/backup/src/rest/class-file-browser-bridge.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use Automattic\Jetpack\Connection\Client; use WP_Error; diff --git a/projects/packages/backup/src/rest/class-rest-controller.php b/projects/packages/backup/src/rest/class-rest-controller.php index 4a3746a46ea1..c8aae687ff28 100644 --- a/projects/packages/backup/src/rest/class-rest-controller.php +++ b/projects/packages/backup/src/rest/class-rest-controller.php @@ -5,9 +5,9 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; -use Automattic\Jetpack\Backup\V0005\Jetpack_Backup; +use Automattic\Jetpack\Backup\V0006\Jetpack_Backup; use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Jetpack_Options; use WP_Error; diff --git a/projects/packages/backup/src/rest/class-restore-bridge.php b/projects/packages/backup/src/rest/class-restore-bridge.php index 5c304085ed52..1b198894877a 100644 --- a/projects/packages/backup/src/rest/class-restore-bridge.php +++ b/projects/packages/backup/src/rest/class-restore-bridge.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use Automattic\Jetpack\Connection\Client; use Automattic\Jetpack\Status\Host; diff --git a/projects/packages/backup/src/rest/class-retention-bridge.php b/projects/packages/backup/src/rest/class-retention-bridge.php index b431ba4cd7b5..8baef06b0980 100644 --- a/projects/packages/backup/src/rest/class-retention-bridge.php +++ b/projects/packages/backup/src/rest/class-retention-bridge.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use Automattic\Jetpack\Connection\Client; use WP_Error; diff --git a/projects/packages/backup/src/rest/class-schedule-bridge.php b/projects/packages/backup/src/rest/class-schedule-bridge.php index e4a70a61a134..7e83a022a312 100644 --- a/projects/packages/backup/src/rest/class-schedule-bridge.php +++ b/projects/packages/backup/src/rest/class-schedule-bridge.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use Automattic\Jetpack\Connection\Client; use WP_Error; diff --git a/projects/packages/backup/tests/php/Admin_Modernization_Gating_Test.php b/projects/packages/backup/tests/php/Admin_Modernization_Gating_Test.php index f6f2ba24a397..fbda5f40e909 100644 --- a/projects/packages/backup/tests/php/Admin_Modernization_Gating_Test.php +++ b/projects/packages/backup/tests/php/Admin_Modernization_Gating_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; use Automattic\Jetpack\Admin_UI\Admin_Menu; use Automattic\Jetpack\Constants; @@ -33,7 +33,7 @@ /** * Tests the menu callback -> enqueue chain. * - * @covers \Automattic\Jetpack\Backup\V0005\Jetpack_Backup + * @covers \Automattic\Jetpack\Backup\V0006\Jetpack_Backup */ #[CoversClass( Jetpack_Backup::class )] class Admin_Modernization_Gating_Test extends TestCase { diff --git a/projects/packages/backup/tests/php/Admin_Notices_Suppression_Test.php b/projects/packages/backup/tests/php/Admin_Notices_Suppression_Test.php index fef03e6075c5..4e590220c82c 100644 --- a/projects/packages/backup/tests/php/Admin_Notices_Suppression_Test.php +++ b/projects/packages/backup/tests/php/Admin_Notices_Suppression_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup */ -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; use Automattic\Jetpack\JITMS\JITM; use PHPUnit\Framework\Attributes\CoversClass; @@ -19,7 +19,7 @@ require_once __DIR__ . '/mock-wp-build-render-page.php'; /** - * @covers \Automattic\Jetpack\Backup\V0005\Jetpack_Backup + * @covers \Automattic\Jetpack\Backup\V0006\Jetpack_Backup */ #[CoversClass( Jetpack_Backup::class )] class Admin_Notices_Suppression_Test extends TestCase { diff --git a/projects/packages/backup/tests/php/Jetpack_Backup_Init_Options_Test.php b/projects/packages/backup/tests/php/Jetpack_Backup_Init_Options_Test.php index c72543d54dbf..2d9aed4d2c14 100644 --- a/projects/packages/backup/tests/php/Jetpack_Backup_Init_Options_Test.php +++ b/projects/packages/backup/tests/php/Jetpack_Backup_Init_Options_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup */ -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\PreserveGlobalState; @@ -22,7 +22,7 @@ * * Every test runs in a child process, because `initialize()` runs once per process. * - * @covers \Automattic\Jetpack\Backup\V0005\Jetpack_Backup + * @covers \Automattic\Jetpack\Backup\V0006\Jetpack_Backup */ #[CoversClass( Jetpack_Backup::class )] class Jetpack_Backup_Init_Options_Test extends TestCase { @@ -92,6 +92,6 @@ private function has_backup_route() { $GLOBALS['wp_rest_server'] = new WP_REST_Server(); do_action( 'rest_api_init' ); - return array_key_exists( '/jetpack/v4/has-backup-plan', rest_get_server()->get_routes() ); + return array_key_exists( '/jetpack/v4/backup-promoted-product-info', rest_get_server()->get_routes() ); } } diff --git a/projects/packages/backup/tests/php/Jetpack_Backup_Test.php b/projects/packages/backup/tests/php/Jetpack_Backup_Test.php index 3e8c644bf21b..f1ddb966bcc0 100644 --- a/projects/packages/backup/tests/php/Jetpack_Backup_Test.php +++ b/projects/packages/backup/tests/php/Jetpack_Backup_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup */ -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; use Automattic\Jetpack\Connection\Utils as Connection_Utils; use Automattic\Jetpack\Status\Cache as Status_Cache; @@ -286,7 +286,7 @@ public function test_route_returns_a_response_on_a_string_status_200( $callback } /** - * The seven unconditionally-registered routes that answer out of + * The six unconditionally-registered routes that answer out of * WordPress.com, as route path => array( callback, HTTP method ). * * One list, two providers, so that adding a route here covers it @@ -297,7 +297,6 @@ public function test_route_returns_a_response_on_a_string_status_200( $callback private static function wpcom_backed_routes() { return array( '/jetpack/v4/backups' => array( 'get_recent_backups', 'GET' ), - '/jetpack/v4/backup-capabilities' => array( 'get_backup_capabilities', 'GET' ), '/jetpack/v4/restores' => array( 'get_recent_restores', 'GET' ), '/jetpack/v4/site/backup/size' => array( 'get_site_backup_size', 'GET' ), '/jetpack/v4/site/backup/policies' => array( 'get_site_backup_policies', 'GET' ), @@ -359,7 +358,7 @@ public function test_list_backup_events_returns_null_on_non_200() { /** * A success code reported as a string still lists the events. * - * `list_backup_events()` is not one of the seven routes covered by the + * `list_backup_events()` is not one of the six routes covered by the * providers above — it answers no route of its own and is read by the * `jetpack-backup/list-backup-events` ability, which flattens this * `null` into an empty list through `unwrap_response()`. So an uncast @@ -384,8 +383,8 @@ public function test_list_backup_events_reads_a_string_status_200() { * `get_rewind_state_from_wpcom()` is private; `has_backup_plan()` is the * door, and it answers false for the `WP_Error` an uncast `'200'` * produced — so a site that does have Backup was told it does not. That - * answer is acted on: it backs `GET /jetpack/v4/has-backup-plan` and the - * standalone-license upsell in `jetpack_check_user_licenses()`. + * answer is acted on: it backs the standalone-license upsell in + * `jetpack_check_user_licenses()`. * * The request count is asserted because the helper memoizes a readable * response: without it this would pass on a cached answer left by an @@ -461,9 +460,9 @@ public function test_rewind_state_read_is_bounded_at_five_seconds() { /** * A WordPress.com failure is reported as one, not as "no plan". * - * That answer is acted on: `GET /jetpack/v4/has-backup-plan` backs the - * connect screen's own-it-already check, so a blip sent a paying site's - * owner to checkout to buy Backup again. + * That answer is acted on: `jetpack_check_user_licenses()` uses it for the + * own-it-already check, so a blip sent a paying site's owner to checkout to + * buy Backup again. */ public function test_backup_plan_state_forwards_a_non_200() { $this->sign_in_as_connected_admin(); @@ -495,24 +494,6 @@ public function test_backup_plan_state_reports_a_transport_failure_as_500() { $this->assertSame( 500, $result->get_error_data()['status'] ); } - /** - * The route serves the failure. It used to serve `false` as an HTTP 200, - * which no caller can tell from "this site has no Backup plan". - */ - public function test_has_backup_plan_route_serves_a_failure_as_an_error() { - $this->sign_in_as_connected_admin(); - $this->wpcom_status = 503; - add_filter( 'pre_http_request', array( $this, 'mock_wpcom_response' ) ); - - rest_get_server(); - Jetpack_Backup::register_rest_routes(); - - $response = rest_do_request( new WP_REST_Request( 'GET', '/jetpack/v4/has-backup-plan' ) ); - - $this->assertTrue( $response->is_error() ); - $this->assertSame( 503, $response->get_status() ); - } - /** * A site that genuinely has no plan still answers a plain `false`. The * wrapper must not turn the legitimate negative into a positive. @@ -995,92 +976,4 @@ public function mock_request_as_activity_collection( $preempt, $parsed_args, $ur ), ); } - - /** - * The dismissal route refuses a reason `Jetpack_Options` cannot store. - * - * A reason outside `Jetpack_Options`' allowlist reaches a `trigger_error()` - * and is stored nowhere, so without the enum the route answers 200 for a - * dismissal it did not record — and prints a warning ahead of the JSON. - * - * @param string $option_name The reason to send. - * @dataProvider provide_unstorable_review_reasons - */ - #[DataProvider( 'provide_unstorable_review_reasons' )] - public function test_dismissal_route_refuses_an_unstorable_reason( $option_name ) { - $this->sign_in_as_connected_admin(); - - rest_get_server(); - Jetpack_Backup::register_rest_routes(); - - $request = new WP_REST_Request( 'POST', '/jetpack/v4/site/dismissed-review-request' ); - $request->set_body_params( - array( - 'option_name' => $option_name, - 'should_dismiss' => false, - ) - ); - $response = rest_do_request( $request ); - - $this->assertSame( 400, $response->get_status(), $option_name ); - } - - /** - * Reasons the route must refuse. - * - * @return array - */ - public static function provide_unstorable_review_reasons() { - return array( - // The shape a third prompt would arrive in if someone added one - // without also adding the option name upstream. - 'a reason nobody registered' => array( 'scan' ), - 'empty' => array( '' ), - // Not an injection risk — the value is concatenated into an - // option name that is then allowlisted — but it has no business - // reaching that concatenation at all. - 'a path' => array( '../../etc/passwd' ), - ); - } - - /** - * Both reasons the dashboard actually sends are accepted, and an - * un-dismissed prompt reads as `false`. - * - * The client treats anything but a literal `false` as dismissed. - * - * @param string $option_name The reason to send. - * @dataProvider provide_review_reasons - */ - #[DataProvider( 'provide_review_reasons' )] - public function test_dismissal_route_accepts_the_reasons_the_dashboard_sends( $option_name ) { - $this->sign_in_as_connected_admin(); - - rest_get_server(); - Jetpack_Backup::register_rest_routes(); - - $request = new WP_REST_Request( 'POST', '/jetpack/v4/site/dismissed-review-request' ); - $request->set_body_params( - array( - 'option_name' => $option_name, - 'should_dismiss' => false, - ) - ); - $response = rest_do_request( $request ); - - $this->assertSame( 200, $response->get_status(), $option_name ); - $this->assertFalse( $response->get_data(), $option_name ); - } - - /** - * The two reasons the review prompt can carry. - * - * @return array - */ - public static function provide_review_reasons() { - return array( - 'restore' => array( 'restore' ), - 'backups' => array( 'backups' ), - ); - } } diff --git a/projects/packages/backup/tests/php/REST_Controller_Test.php b/projects/packages/backup/tests/php/REST_Controller_Test.php index 783171feb0f1..1f924613ea9f 100644 --- a/projects/packages/backup/tests/php/REST_Controller_Test.php +++ b/projects/packages/backup/tests/php/REST_Controller_Test.php @@ -9,9 +9,9 @@ // order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide // to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin // are installed, or in some other cases). -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; -use Automattic\Jetpack\Backup\V0005\REST\Wpcom_Request_Mock; +use Automattic\Jetpack\Backup\V0006\REST\Wpcom_Request_Mock; use Automattic\Jetpack\Connection\Rest_Authentication as Connection_Rest_Authentication; use Automattic\Jetpack\Connection\Utils as Connection_Utils; use PHPUnit\Framework\Attributes\DataProvider; @@ -92,7 +92,7 @@ public function setUp(): void { $this->was_using_ext_object_cache = wp_using_ext_object_cache(); // Register REST routes. - add_action( 'rest_api_init', array( 'Automattic\\Jetpack\\Backup\\V0005\\REST_Controller', 'register_rest_routes' ) ); + add_action( 'rest_api_init', array( 'Automattic\\Jetpack\\Backup\\V0006\\REST_Controller', 'register_rest_routes' ) ); do_action( 'rest_api_init' ); } diff --git a/projects/packages/backup/tests/php/Rest_Activity_Log_Bridge_Test.php b/projects/packages/backup/tests/php/Rest_Activity_Log_Bridge_Test.php index 4708d903bcfb..6401b86021ed 100644 --- a/projects/packages/backup/tests/php/Rest_Activity_Log_Bridge_Test.php +++ b/projects/packages/backup/tests/php/Rest_Activity_Log_Bridge_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -27,7 +27,7 @@ /** * Tests for the GET /jetpack/v4/site/rewindable-activity route. * - * @covers \Automattic\Jetpack\Backup\V0005\REST\Activity_Log_Bridge + * @covers \Automattic\Jetpack\Backup\V0006\REST\Activity_Log_Bridge */ #[CoversClass( Activity_Log_Bridge::class )] class Rest_Activity_Log_Bridge_Test extends TestCase { diff --git a/projects/packages/backup/tests/php/Rest_Backup_Sizes_Bridge_Test.php b/projects/packages/backup/tests/php/Rest_Backup_Sizes_Bridge_Test.php index b2c0581c6d74..716b4cbbcd15 100644 --- a/projects/packages/backup/tests/php/Rest_Backup_Sizes_Bridge_Test.php +++ b/projects/packages/backup/tests/php/Rest_Backup_Sizes_Bridge_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; @@ -22,7 +22,7 @@ /** * Tests for the GET /jetpack/v4/backups/sizes route. * - * @covers \Automattic\Jetpack\Backup\V0005\REST\Backup_Sizes_Bridge + * @covers \Automattic\Jetpack\Backup\V0006\REST\Backup_Sizes_Bridge */ #[CoversClass( Backup_Sizes_Bridge::class )] class Rest_Backup_Sizes_Bridge_Test extends TestCase { diff --git a/projects/packages/backup/tests/php/Rest_Bridge_Dispatch_Test.php b/projects/packages/backup/tests/php/Rest_Bridge_Dispatch_Test.php index 5a532218f4b6..b768b169d511 100644 --- a/projects/packages/backup/tests/php/Rest_Bridge_Dispatch_Test.php +++ b/projects/packages/backup/tests/php/Rest_Bridge_Dispatch_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use Automattic\Jetpack\Constants; use Automattic\Jetpack\Status\Cache as Status_Cache; @@ -35,7 +35,7 @@ * So this file dispatches through the REST server once per registered bridge route, and * asserts the route list against the server's own rather than keeping it by hand. * - * @covers \Automattic\Jetpack\Backup\V0005\REST\Rest_Controller + * @covers \Automattic\Jetpack\Backup\V0006\REST\Rest_Controller */ #[CoversClass( Rest_Controller::class )] class Rest_Bridge_Dispatch_Test extends TestCase { diff --git a/projects/packages/backup/tests/php/Rest_Bridge_Gating_Test.php b/projects/packages/backup/tests/php/Rest_Bridge_Gating_Test.php index 4c66fc41c9bb..68bbf8dfa068 100644 --- a/projects/packages/backup/tests/php/Rest_Bridge_Gating_Test.php +++ b/projects/packages/backup/tests/php/Rest_Bridge_Gating_Test.php @@ -4,13 +4,13 @@ * * Named for the bridges rather than the controller: a `Rest_Controller_Test` * here would differ only in case from this package's existing - * `REST_Controller_Test` (the legacy `V0005\REST_Controller`), which breaks + * `REST_Controller_Test` (the legacy `V0006\REST_Controller`), which breaks * checkouts on case-insensitive filesystems. * * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -26,7 +26,7 @@ /** * Tests that `Rest_Controller::register_routes()` registers every bridge route, and only those. * - * @covers \Automattic\Jetpack\Backup\V0005\REST\Rest_Controller + * @covers \Automattic\Jetpack\Backup\V0006\REST\Rest_Controller */ #[CoversClass( Rest_Controller::class )] class Rest_Bridge_Gating_Test extends TestCase { diff --git a/projects/packages/backup/tests/php/Rest_Capabilities_Bridge_Test.php b/projects/packages/backup/tests/php/Rest_Capabilities_Bridge_Test.php index ed3576a1fe21..094eeab30da6 100644 --- a/projects/packages/backup/tests/php/Rest_Capabilities_Bridge_Test.php +++ b/projects/packages/backup/tests/php/Rest_Capabilities_Bridge_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -25,7 +25,7 @@ /** * Tests for the GET /jetpack/v4/site/capabilities route. * - * @covers \Automattic\Jetpack\Backup\V0005\REST\Capabilities_Bridge + * @covers \Automattic\Jetpack\Backup\V0006\REST\Capabilities_Bridge */ #[CoversClass( Capabilities_Bridge::class )] class Rest_Capabilities_Bridge_Test extends TestCase { diff --git a/projects/packages/backup/tests/php/Rest_Download_Bridge_Test.php b/projects/packages/backup/tests/php/Rest_Download_Bridge_Test.php index 7a445ec0e49d..02fe486bb67b 100644 --- a/projects/packages/backup/tests/php/Rest_Download_Bridge_Test.php +++ b/projects/packages/backup/tests/php/Rest_Download_Bridge_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -25,7 +25,7 @@ /** * Tests for the /jetpack/v4/backups/download/* routes. * - * @covers \Automattic\Jetpack\Backup\V0005\REST\Download_Bridge + * @covers \Automattic\Jetpack\Backup\V0006\REST\Download_Bridge */ #[CoversClass( Download_Bridge::class )] class Rest_Download_Bridge_Test extends TestCase { diff --git a/projects/packages/backup/tests/php/Rest_File_Browser_Bridge_Test.php b/projects/packages/backup/tests/php/Rest_File_Browser_Bridge_Test.php index 99bd5d78ecb3..5d621532aea7 100644 --- a/projects/packages/backup/tests/php/Rest_File_Browser_Bridge_Test.php +++ b/projects/packages/backup/tests/php/Rest_File_Browser_Bridge_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; @@ -28,7 +28,7 @@ /** * Tests for the /jetpack/v4/rewind/backup/* routes. * - * @covers \Automattic\Jetpack\Backup\V0005\REST\File_Browser_Bridge + * @covers \Automattic\Jetpack\Backup\V0006\REST\File_Browser_Bridge */ #[CoversClass( File_Browser_Bridge::class )] class Rest_File_Browser_Bridge_Test extends TestCase { diff --git a/projects/packages/backup/tests/php/Rest_Restore_Bridge_Test.php b/projects/packages/backup/tests/php/Rest_Restore_Bridge_Test.php index 0053a630494b..767f5dbfd5cf 100644 --- a/projects/packages/backup/tests/php/Rest_Restore_Bridge_Test.php +++ b/projects/packages/backup/tests/php/Rest_Restore_Bridge_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use Automattic\Jetpack\Constants; use Automattic\Jetpack\Status\Cache as Status_Cache; @@ -28,7 +28,7 @@ /** * Tests for the /jetpack/v4/rewind/* routes. * - * @covers \Automattic\Jetpack\Backup\V0005\REST\Restore_Bridge + * @covers \Automattic\Jetpack\Backup\V0006\REST\Restore_Bridge */ #[CoversClass( Restore_Bridge::class )] class Rest_Restore_Bridge_Test extends TestCase { diff --git a/projects/packages/backup/tests/php/Rest_Retention_Bridge_Test.php b/projects/packages/backup/tests/php/Rest_Retention_Bridge_Test.php index 7c91c02a23cb..a546cea67534 100644 --- a/projects/packages/backup/tests/php/Rest_Retention_Bridge_Test.php +++ b/projects/packages/backup/tests/php/Rest_Retention_Bridge_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; @@ -22,7 +22,7 @@ /** * Tests for the POST /jetpack/v4/site/backup/retention route. * - * @covers \Automattic\Jetpack\Backup\V0005\REST\Retention_Bridge + * @covers \Automattic\Jetpack\Backup\V0006\REST\Retention_Bridge */ #[CoversClass( Retention_Bridge::class )] class Rest_Retention_Bridge_Test extends TestCase { diff --git a/projects/packages/backup/tests/php/Rest_Schedule_Bridge_Test.php b/projects/packages/backup/tests/php/Rest_Schedule_Bridge_Test.php index 4efb65d8e053..86eed5bac11e 100644 --- a/projects/packages/backup/tests/php/Rest_Schedule_Bridge_Test.php +++ b/projects/packages/backup/tests/php/Rest_Schedule_Bridge_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\TestCase; @@ -22,7 +22,7 @@ /** * Tests for the POST /jetpack/v4/site/backup/schedule route. * - * @covers \Automattic\Jetpack\Backup\V0005\REST\Schedule_Bridge + * @covers \Automattic\Jetpack\Backup\V0006\REST\Schedule_Bridge */ #[CoversClass( Schedule_Bridge::class )] class Rest_Schedule_Bridge_Test extends TestCase { diff --git a/projects/packages/backup/tests/php/Storage_Addon_Upsell_Test.php b/projects/packages/backup/tests/php/Storage_Addon_Upsell_Test.php index bbc017cf4f87..68f5027486ac 100644 --- a/projects/packages/backup/tests/php/Storage_Addon_Upsell_Test.php +++ b/projects/packages/backup/tests/php/Storage_Addon_Upsell_Test.php @@ -9,7 +9,7 @@ // order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide // to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin // are installed, or in some other cases). -namespace Automattic\Jetpack\Backup\V0005; +namespace Automattic\Jetpack\Backup\V0006; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; diff --git a/projects/packages/backup/tests/php/abilities/Backup_Abilities_Test.php b/projects/packages/backup/tests/php/abilities/Backup_Abilities_Test.php index f64ce36f659a..3f3554d14662 100644 --- a/projects/packages/backup/tests/php/abilities/Backup_Abilities_Test.php +++ b/projects/packages/backup/tests/php/abilities/Backup_Abilities_Test.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup */ -namespace Automattic\Jetpack\Backup\V0005\Abilities; +namespace Automattic\Jetpack\Backup\V0006\Abilities; use Automattic\Jetpack\Connection\Utils as Connection_Utils; use Automattic\Jetpack\Status\Cache as Status_Cache; @@ -16,7 +16,7 @@ use WP_Error; /** - * @covers \Automattic\Jetpack\Backup\V0005\Abilities\Backup_Abilities + * @covers \Automattic\Jetpack\Backup\V0006\Abilities\Backup_Abilities */ #[CoversClass( Backup_Abilities::class )] class Backup_Abilities_Test extends BaseTestCase { diff --git a/projects/packages/backup/tests/php/trait-wpcom-request-mock.php b/projects/packages/backup/tests/php/trait-wpcom-request-mock.php index f834c720fba9..c560739c0791 100644 --- a/projects/packages/backup/tests/php/trait-wpcom-request-mock.php +++ b/projects/packages/backup/tests/php/trait-wpcom-request-mock.php @@ -5,7 +5,7 @@ * @package automattic/jetpack-backup-plugin */ -namespace Automattic\Jetpack\Backup\V0005\REST; +namespace Automattic\Jetpack\Backup\V0006\REST; use Automattic\Jetpack\Connection\Utils as Connection_Utils; use WP_Error; diff --git a/projects/packages/transport-helper/actions.php b/projects/packages/transport-helper/actions.php index c3d7e01ba266..4fb80367d0b6 100644 --- a/projects/packages/transport-helper/actions.php +++ b/projects/packages/transport-helper/actions.php @@ -23,7 +23,7 @@ } // Clean up expired Jetpack Helper Scripts from a scheduled event. -$add_action( 'jetpack_cleanup_helper_scripts', array( 'Automattic\\Jetpack\\Backup\\V0005\\Helper_Script_Manager', 'cleanup_expired_helper_scripts' ) ); +$add_action( 'jetpack_cleanup_helper_scripts', array( 'Automattic\\Jetpack\\Backup\\V0006\\Helper_Script_Manager', 'cleanup_expired_helper_scripts' ) ); // Register REST routes. $add_action( 'rest_api_init', array( 'Automattic\Jetpack\Transport_Helper\V0005\\REST_Controller', 'register_rest_routes' ) ); diff --git a/projects/packages/transport-helper/changelog/remove-jetpack-2314-backup-legacy-routes b/projects/packages/transport-helper/changelog/remove-jetpack-2314-backup-legacy-routes new file mode 100644 index 000000000000..deb24dcea2dc --- /dev/null +++ b/projects/packages/transport-helper/changelog/remove-jetpack-2314-backup-legacy-routes @@ -0,0 +1,4 @@ +Significance: patch +Type: changed +Comment: Follow the Backup namespace version bump from V0005 to V0006; no user-facing change. + diff --git a/projects/packages/transport-helper/src/class-rest-controller.php b/projects/packages/transport-helper/src/class-rest-controller.php index 48b97263b375..319934b71c44 100644 --- a/projects/packages/transport-helper/src/class-rest-controller.php +++ b/projects/packages/transport-helper/src/class-rest-controller.php @@ -12,7 +12,7 @@ // are installed, or in some other cases). namespace Automattic\Jetpack\Transport_Helper\V0005; -use Automattic\Jetpack\Backup\V0005\Helper_Script_Manager; +use Automattic\Jetpack\Backup\V0006\Helper_Script_Manager; use Automattic\Jetpack\Connection\Rest_Authentication; use WP_Error; use WP_REST_Request; diff --git a/projects/plugins/backup/changelog/remove-jetpack-2314-backup-legacy-routes b/projects/plugins/backup/changelog/remove-jetpack-2314-backup-legacy-routes new file mode 100644 index 000000000000..deb24dcea2dc --- /dev/null +++ b/projects/plugins/backup/changelog/remove-jetpack-2314-backup-legacy-routes @@ -0,0 +1,4 @@ +Significance: patch +Type: changed +Comment: Follow the Backup namespace version bump from V0005 to V0006; no user-facing change. + diff --git a/projects/plugins/backup/jetpack-backup.php b/projects/plugins/backup/jetpack-backup.php index 7a6e166fa60c..ad8326a3b924 100644 --- a/projects/plugins/backup/jetpack-backup.php +++ b/projects/plugins/backup/jetpack-backup.php @@ -29,7 +29,7 @@ */ use Automattic\Jetpack\Activity_Log\Jetpack_Activity_Log; -use Automattic\Jetpack\Backup\V0005\Jetpack_Backup as My_Jetpack_Backup; +use Automattic\Jetpack\Backup\V0006\Jetpack_Backup as My_Jetpack_Backup; use Automattic\Jetpack\My_Jetpack\Initializer as My_Jetpack_Initializer; if ( ! defined( 'ABSPATH' ) ) { @@ -179,7 +179,7 @@ function ( $actions ) { } ); -register_deactivation_hook( __FILE__, array( 'Automattic\\Jetpack\\Backup\\V0005\\Jetpack_Backup', 'plugin_deactivation' ) ); +register_deactivation_hook( __FILE__, array( 'Automattic\\Jetpack\\Backup\\V0006\\Jetpack_Backup', 'plugin_deactivation' ) ); // Main plugin class. My_Jetpack_Backup::initialize(); diff --git a/projects/plugins/jetpack/changelog/remove-jetpack-2314-backup-legacy-routes b/projects/plugins/jetpack/changelog/remove-jetpack-2314-backup-legacy-routes new file mode 100644 index 000000000000..04806613c411 --- /dev/null +++ b/projects/plugins/jetpack/changelog/remove-jetpack-2314-backup-legacy-routes @@ -0,0 +1,4 @@ +Significance: patch +Type: other +Comment: Follow the Backup namespace version bump from V0005 to V0006; no user-facing change. + diff --git a/projects/plugins/jetpack/class.jetpack.php b/projects/plugins/jetpack/class.jetpack.php index 6644f2a08a57..7d1f9be14916 100644 --- a/projects/plugins/jetpack/class.jetpack.php +++ b/projects/plugins/jetpack/class.jetpack.php @@ -899,7 +899,7 @@ public static function configure_backup_package() { return; } - $backup = 'Automattic\\Jetpack\\Backup\\V0005\\Jetpack_Backup'; + $backup = 'Automattic\\Jetpack\\Backup\\V0006\\Jetpack_Backup'; // An older package would take over the connection (see Jetpack_Backup::DEFAULT_INIT_OPTIONS); // only the standalone plugin ships one that old, and it draws its own menu. diff --git a/projects/plugins/jetpack/json-endpoints/jetpack/class-jetpack-json-api-delete-backup-helper-script-endpoint.php b/projects/plugins/jetpack/json-endpoints/jetpack/class-jetpack-json-api-delete-backup-helper-script-endpoint.php index 5684531cfdf3..8ea3c9bc0172 100644 --- a/projects/plugins/jetpack/json-endpoints/jetpack/class-jetpack-json-api-delete-backup-helper-script-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/jetpack/class-jetpack-json-api-delete-backup-helper-script-endpoint.php @@ -6,7 +6,7 @@ * @package automattic/jetpack */ -use Automattic\Jetpack\Backup\V0005\Helper_Script_Manager; +use Automattic\Jetpack\Backup\V0006\Helper_Script_Manager; if ( ! defined( 'ABSPATH' ) ) { exit( 0 ); diff --git a/projects/plugins/jetpack/json-endpoints/jetpack/class-jetpack-json-api-install-backup-helper-script-endpoint.php b/projects/plugins/jetpack/json-endpoints/jetpack/class-jetpack-json-api-install-backup-helper-script-endpoint.php index e728d8121c08..df3e09ad24b0 100644 --- a/projects/plugins/jetpack/json-endpoints/jetpack/class-jetpack-json-api-install-backup-helper-script-endpoint.php +++ b/projects/plugins/jetpack/json-endpoints/jetpack/class-jetpack-json-api-install-backup-helper-script-endpoint.php @@ -6,7 +6,7 @@ * @package automattic/jetpack */ -use Automattic\Jetpack\Backup\V0005\Helper_Script_Manager; +use Automattic\Jetpack\Backup\V0006\Helper_Script_Manager; if ( ! defined( 'ABSPATH' ) ) { exit( 0 ); diff --git a/projects/plugins/jetpack/tests/php/general/Jetpack_Admin_Menu_Test.php b/projects/plugins/jetpack/tests/php/general/Jetpack_Admin_Menu_Test.php index 51d4efa996c9..6f4717099d3b 100644 --- a/projects/plugins/jetpack/tests/php/general/Jetpack_Admin_Menu_Test.php +++ b/projects/plugins/jetpack/tests/php/general/Jetpack_Admin_Menu_Test.php @@ -5,7 +5,7 @@ use Automattic\Jetpack\Activity_Log\Jetpack_Activity_Log; use Automattic\Jetpack\Admin_UI\Admin_Menu; -use Automattic\Jetpack\Backup\V0005\Jetpack_Backup; +use Automattic\Jetpack\Backup\V0006\Jetpack_Backup; use Automattic\Jetpack\Jetpack_Mu_Wpcom\WPCOM_WP_Build_Page; use Automattic\Jetpack\My_Jetpack\Initializer as My_Jetpack_Initializer; use Automattic\Jetpack\Scan\Admin_Bar_Notice; diff --git a/projects/plugins/jetpack/tests/php/general/Jetpack_Eager_Load_Packages_Test.php b/projects/plugins/jetpack/tests/php/general/Jetpack_Eager_Load_Packages_Test.php index 08f1394b7bae..661b02f6a9d2 100644 --- a/projects/plugins/jetpack/tests/php/general/Jetpack_Eager_Load_Packages_Test.php +++ b/projects/plugins/jetpack/tests/php/general/Jetpack_Eager_Load_Packages_Test.php @@ -400,7 +400,7 @@ public function test_deferred_my_jetpack_routes_register_when_rest_api_init_fire } /** - * End-to-end counterpart for Backup, via `/has-backup-plan`, which only `initialize()` registers. + * End-to-end counterpart for Backup, via `/backup-promoted-product-info`, which only `initialize()` registers. */ public function test_deferred_backup_routes_register_when_rest_api_init_fires() { $this->set_up_backup_test(); @@ -409,7 +409,7 @@ public function test_deferred_backup_routes_register_when_rest_api_init_fires() // Clean slate so registration can only happen via the re-add below. $this->force_unfire_action( 'jetpack_backup_initialized' ); - remove_action( 'rest_api_init', array( 'Automattic\\Jetpack\\Backup\\V0005\\Jetpack_Backup', 'register_rest_routes' ) ); + remove_action( 'rest_api_init', array( 'Automattic\\Jetpack\\Backup\\V0006\\Jetpack_Backup', 'register_rest_routes' ) ); // Mirror the gate's deferred front-end-GET wiring. add_action( 'rest_api_init', array( Jetpack::class, 'configure_backup_package' ), 0 ); @@ -418,7 +418,7 @@ public function test_deferred_backup_routes_register_when_rest_api_init_fires() do_action( 'rest_api_init' ); $this->assertTrue( - $this->has_route_under( '/jetpack/v4/has-backup-plan' ), + $this->has_route_under( '/jetpack/v4/backup-promoted-product-info' ), 'Deferred Backup bootstrap did not register its REST routes when rest_api_init fired.' ); } diff --git a/projects/plugins/jetpack/uninstall.php b/projects/plugins/jetpack/uninstall.php index 5cf10f669b56..bc06f5a96095 100644 --- a/projects/plugins/jetpack/uninstall.php +++ b/projects/plugins/jetpack/uninstall.php @@ -5,7 +5,7 @@ * @package automattic/jetpack */ -use Automattic\Jetpack\Backup\V0005\Helper_Script_Manager; +use Automattic\Jetpack\Backup\V0006\Helper_Script_Manager; use Automattic\Jetpack\Connection\Manager as Connection_Manager; use Automattic\Jetpack\Sync\Sender; From 56ee27634c8da32d3ba08d52197f87b47f4708f1 Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Tue, 20 Oct 2026 17:59:39 -0300 Subject: [PATCH 2/2] Backup: refresh the Phan baseline, drop the hard-coded route count Co-Authored-By: Claude Sonnet 5.5 --- projects/packages/backup/.phan/baseline.php | 2 -- projects/packages/backup/tests/php/Jetpack_Backup_Test.php | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/projects/packages/backup/.phan/baseline.php b/projects/packages/backup/.phan/baseline.php index 44110b053173..3687cc0948ba 100644 --- a/projects/packages/backup/.phan/baseline.php +++ b/projects/packages/backup/.phan/baseline.php @@ -10,11 +10,9 @@ return [ // # Issue statistics: // PhanTypeMismatchReturnProbablyReal : 7 occurrences - // PhanTypeMismatchReturn : 1 occurrence // Currently, file_suppressions and directory_suppressions are the only supported suppressions 'file_suppressions' => [ - 'src/class-jetpack-backup.php' => ['PhanTypeMismatchReturn'], 'src/class-rest-controller.php' => ['PhanTypeMismatchReturnProbablyReal'], ], // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. diff --git a/projects/packages/backup/tests/php/Jetpack_Backup_Test.php b/projects/packages/backup/tests/php/Jetpack_Backup_Test.php index f1ddb966bcc0..723fce228bc8 100644 --- a/projects/packages/backup/tests/php/Jetpack_Backup_Test.php +++ b/projects/packages/backup/tests/php/Jetpack_Backup_Test.php @@ -286,7 +286,7 @@ public function test_route_returns_a_response_on_a_string_status_200( $callback } /** - * The six unconditionally-registered routes that answer out of + * The unconditionally-registered routes that answer out of * WordPress.com, as route path => array( callback, HTTP method ). * * One list, two providers, so that adding a route here covers it @@ -358,7 +358,7 @@ public function test_list_backup_events_returns_null_on_non_200() { /** * A success code reported as a string still lists the events. * - * `list_backup_events()` is not one of the six routes covered by the + * `list_backup_events()` is not one of the routes covered by the * providers above — it answers no route of its own and is read by the * `jetpack-backup/list-backup-events` ability, which flattens this * `null` into an empty list through `unwrap_response()`. So an uncast