Make WordPress Core

Ticket #46351: 46351.diff

File 46351.diff, 2.5 KB (added by david.binda, 6 years ago)
  • src/wp-includes/ms-site.php

     
    9595                $user_id = ! empty( $args['user_id'] ) ? $args['user_id'] : 0;
    9696                $meta    = ! empty( $args['options'] ) ? $args['options'] : array();
    9797
     98                // Restore WPLANG which used to be part of the meta prior 5.1.0.
     99                if ( ! array_key_exists( 'WPLANG', $meta ) ) {
     100                        $meta['WPLANG'] = get_network_option( $new_site->network_id, 'WPLANG' );
     101                }
     102
     103                // Restore site status which used to be part of the meta prior 5.1.0.
     104                // The `$site_data_whitelist` matches the one used in `wpmu_create_blog`.
     105                $site_data_whitelist = array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' );
     106                $meta = array_merge( array_intersect_key( $data, array_flip( $site_data_whitelist ) ), $meta );
     107
    98108                /**
    99109                 * Fires immediately after a new site is created.
    100110                 *
  • tests/phpunit/tests/multisite/site.php

     
    23482348                        // Set siteurl
    23492349                        update_option( 'siteurl', 'http://testsite1.example.org/test' );
    23502350                }
     2351
     2352                /**
     2353                 * @ticket 46351
     2354                 */
     2355                public function test_wpmu_new_blog_action_backward_compatible() {
     2356                        // We are testing deprecated hook. Register it to expected deprecated notices.
     2357                        $this->setExpectedDeprecated( 'wpmu_new_blog' );
     2358                        add_action( 'wpmu_new_blog', array( $this, 'wpmu_new_blog_callback' ), 10, 6 );
     2359
     2360                        $meta = array(
     2361                                'public'  => -1, // `public` is one of the defaults metas in `wpmu_create_blog' function prior WordPress 5.1.0.
     2362                                'lang_id' => 11,
     2363                                'mature'  => 0,
     2364                        );
     2365                        $blog_id = wpmu_create_blog( 'testsite1.example.org', '/new-blog/', 'New Blog', get_current_user_id(), $meta, 1 );
     2366
     2367                        remove_action( 'populate_options', array( $this, 'wpmu_new_blog_callback' ), 10 );
     2368                }
     2369
     2370                /**
     2371                 * Capture the $meta value passed to the wpmu_new_blog action and compare it.
     2372                 */
     2373                public function wpmu_new_blog_callback( $blog_id, $user_id, $domain, $path, $network_id, $meta ) {
     2374                        $expected_meta = array(
     2375                                'public'   => -1,
     2376                                'WPLANG'   => 'en_US', // WPLANG is another default meta in `wpmu_create_blog` function prior WordPress 5.1.0.
     2377                                'lang_id'  => 11,
     2378                                'mature'   => 0,
     2379                        );
     2380                        $this->assertArraySubset( $expected_meta, $meta );
     2381                }
    23512382        }
    23522383
    23532384endif;