PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | includes/abilities/class-mainwp-abilities-sites.php +83 -8 6.1 → 6.2.2 View file →
@@ -341,9 +341,10 @@
341 341 'site_ids' => array(
342 342 'type' => 'array',
343 343 'description' => __( 'Site IDs to sync. Empty array means all sites.', 'mainwp' ),
344 344 'items' => array(
345 - 'type' => 'integer',
345 + 'type' => 'integer',
346 + 'minimum' => 1,
346 347 ),
347 348 'default' => array(),
348 349 ),
349 350 'exclude_ids' => array(
@@ -349,9 +350,10 @@
349 350 'exclude_ids' => array(
350 351 'type' => 'array',
351 352 'description' => __( 'Site IDs to exclude from sync.', 'mainwp' ),
352 353 'items' => array(
353 - 'type' => 'integer',
354 + 'type' => 'integer',
355 + 'minimum' => 1,
354 356 ),
355 357 'default' => array(),
356 358 ),
357 359 ),
@@ -858,12 +860,37 @@
858 860 * @param array|null $input Validated input from Abilities API.
859 861 * @return array|\WP_Error
860 862 */
861 863 public static function execute_sync_sites( $input ) { // phpcs:ignore -- NOSONAR - complexity method.
862 - $input = is_array( $input ) ? $input : array();
863 - $site_ids = isset( $input['site_ids'] ) && is_array( $input['site_ids'] )
864 + $input = is_array( $input ) ? $input : array();
865 +
866 + // Core schema validation coerce-accepts scalars for type:array but hands the raw
867 + // value through; a non-array must not fall into the all-sites branch below.
868 + foreach ( array( 'site_ids', 'site_ids_or_domains', 'exclude_ids' ) as $array_key ) {
869 + if ( array_key_exists( $array_key, $input ) && ! is_array( $input[ $array_key ] ) ) {
870 + return new \WP_Error(
871 + 'mainwp_invalid_input',
872 + __( 'The site_ids, site_ids_or_domains, and exclude_ids parameters must be arrays of site IDs or domains.', 'mainwp' ),
873 + array( 'status' => 400 )
874 + );
875 + }
876 + }
877 +
878 + $site_ids = isset( $input['site_ids'] ) && is_array( $input['site_ids'] )
864 879 ? array_values( array_filter( array_map( 'absint', $input['site_ids'] ) ) )
865 880 : array();
881 +
882 + // A provided list whose ids all filter out (e.g. [0]) must not net out to
883 + // the all-sites branch. Schema minimum:1 covers validated paths; this covers
884 + // direct callback invocation.
885 + if ( ! empty( $input['site_ids'] ) && empty( $site_ids ) ) {
886 + return new \WP_Error(
887 + 'mainwp_invalid_input',
888 + __( 'The site_ids parameter contains no valid site IDs.', 'mainwp' ),
889 + array( 'status' => 400 )
890 + );
891 + }
892 +
866 893 $site_ids_or_domains = isset( $input['site_ids_or_domains'] ) && is_array( $input['site_ids_or_domains'] )
867 894 ? $input['site_ids_or_domains']
868 895 : array();
869 896 if ( empty( $site_ids_or_domains ) && ! empty( $site_ids ) ) {
@@ -1568,8 +1595,12 @@
1568 1595 }
1569 1596
1570 1597 if ( ! empty( $update_data ) ) {
1571 1598 MainWP_DB::instance()->update_website_values( $site->id, $update_data );
1599 + if ( isset( $update_data['url'] ) ) {
1600 + // A user-set URL that diverges from the child-reported address locks auto-correction.
1601 + MainWP_Site_Url_Corrector::after_user_set_url( $site, $update_data['url'] );
1602 + }
1572 1603 }
1573 1604
1574 1605 if ( isset( $input['tag_ids'] ) && is_array( $input['tag_ids'] ) ) {
1575 1606 global $wpdb;
@@ -4175,10 +4206,21 @@
4175 4206 */
4176 4207 public static function execute_reconnect_sites( $input ) { // phpcs:ignore -- NOSONAR - complexity.
4177 4208 $input = MainWP_Abilities_Util::normalize_input( $input );
4178 4209
4179 - $identifiers = isset( $input['site_ids_or_domains'] ) && is_array( $input['site_ids_or_domains'] ) ? $input['site_ids_or_domains'] : array();
4210 + // Core schema validation coerce-accepts scalars for type:array but hands the raw
4211 + // value through; a non-array must not fall into the all-sites branch below.
4212 + // array_key_exists, not isset: an explicit null is a present non-array too.
4213 + if ( array_key_exists( 'site_ids_or_domains', $input ) && ! is_array( $input['site_ids_or_domains'] ) ) {
4214 + return new \WP_Error(
4215 + 'mainwp_invalid_input',
4216 + __( 'The site_ids_or_domains parameter must be an array of site IDs or domains.', 'mainwp' ),
4217 + array( 'status' => 400 )
4218 + );
4219 + }
4180 4220
4221 + $identifiers = isset( $input['site_ids_or_domains'] ) ? $input['site_ids_or_domains'] : array();
4222 +
4181 4223 // If empty, get all sites for current user.
4182 4224 if ( empty( $identifiers ) ) {
4183 4225 $all_sites = MainWP_DB::instance()->get_websites_for_current_user( array( 'selectgroups' => false ) );
4184 4226
@@ -4298,10 +4340,21 @@
4298 4340 */
4299 4341 public static function execute_disconnect_sites( $input ) {
4300 4342 $input = MainWP_Abilities_Util::normalize_input( $input );
4301 4343
4302 - $identifiers = isset( $input['site_ids_or_domains'] ) && is_array( $input['site_ids_or_domains'] ) ? $input['site_ids_or_domains'] : array();
4344 + // Core schema validation coerce-accepts scalars for type:array but hands the raw
4345 + // value through; a non-array must not fall into the all-sites branch below.
4346 + // array_key_exists, not isset: an explicit null is a present non-array too.
4347 + if ( array_key_exists( 'site_ids_or_domains', $input ) && ! is_array( $input['site_ids_or_domains'] ) ) {
4348 + return new \WP_Error(
4349 + 'mainwp_invalid_input',
4350 + __( 'The site_ids_or_domains parameter must be an array of site IDs or domains.', 'mainwp' ),
4351 + array( 'status' => 400 )
4352 + );
4353 + }
4303 4354
4355 + $identifiers = isset( $input['site_ids_or_domains'] ) ? $input['site_ids_or_domains'] : array();
4356 +
4304 4357 // If empty, get all sites for current user.
4305 4358 if ( empty( $identifiers ) ) {
4306 4359 $all_sites = MainWP_DB::instance()->get_websites_for_current_user( array( 'selectgroups' => false ) );
4307 4360
@@ -4403,10 +4456,21 @@
4403 4456 */
4404 4457 public static function execute_check_sites( $input ) { // phpcs:ignore -- NOSONAR - complexity.
4405 4458 $input = MainWP_Abilities_Util::normalize_input( $input );
4406 4459
4407 - $identifiers = isset( $input['site_ids_or_domains'] ) && is_array( $input['site_ids_or_domains'] ) ? $input['site_ids_or_domains'] : array();
4460 + // Core schema validation coerce-accepts scalars for type:array but hands the raw
4461 + // value through; a non-array must not fall into the all-sites branch below.
4462 + // array_key_exists, not isset: an explicit null is a present non-array too.
4463 + if ( array_key_exists( 'site_ids_or_domains', $input ) && ! is_array( $input['site_ids_or_domains'] ) ) {
4464 + return new \WP_Error(
4465 + 'mainwp_invalid_input',
4466 + __( 'The site_ids_or_domains parameter must be an array of site IDs or domains.', 'mainwp' ),
4467 + array( 'status' => 400 )
4468 + );
4469 + }
4408 4470
4471 + $identifiers = isset( $input['site_ids_or_domains'] ) ? $input['site_ids_or_domains'] : array();
4472 +
4409 4473 // If empty, get all sites for current user.
4410 4474 if ( empty( $identifiers ) ) {
4411 4475 $all_sites = MainWP_DB::instance()->get_websites_for_current_user( array( 'selectgroups' => false ) );
4412 4476
@@ -4534,9 +4598,20 @@
4534 4598 */
4535 4599 public static function execute_suspend_sites( $input ) {
4536 4600 $input = MainWP_Abilities_Util::normalize_input( $input );
4537 4601
4538 - $identifiers = isset( $input['site_ids_or_domains'] ) && is_array( $input['site_ids_or_domains'] ) ? $input['site_ids_or_domains'] : array();
4602 + // Core schema validation coerce-accepts scalars for type:array but hands the raw
4603 + // value through; a non-array must not fall into the all-sites branch below.
4604 + // array_key_exists, not isset: an explicit null is a present non-array too.
4605 + if ( array_key_exists( 'site_ids_or_domains', $input ) && ! is_array( $input['site_ids_or_domains'] ) ) {
4606 + return new \WP_Error(
4607 + 'mainwp_invalid_input',
4608 + __( 'The site_ids_or_domains parameter must be an array of site IDs or domains.', 'mainwp' ),
4609 + array( 'status' => 400 )
4610 + );
4611 + }
4612 +
4613 + $identifiers = isset( $input['site_ids_or_domains'] ) ? $input['site_ids_or_domains'] : array();
4539 4614
4540 4615 // If empty, get all sites for current user.
4541 4616 if ( empty( $identifiers ) ) {
4542 4617 $all_sites = MainWP_DB::instance()->get_websites_for_current_user( array( 'selectgroups' => false ) );