PHP 7.3 Compatibility: Fix compact related notices.

In PHP 7.3, the `compact()` function has been changed to issue an `E_NOTICE` level error if a passed string refers to an unset variable. In previous versions of PHP, this notice was silently skipped. This fixes a few more instances of unset variables in the WordPress admin.

The full RFC can be viewed here: https://wiki.php.net/rfc/compact.

See #44416.

Merges [44185] into trunk.

Fixes #45483.
Built from https://develop.svn.wordpress.org/trunk@44297


git-svn-id: http://core.svn.wordpress.org/trunk@44127 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2018-12-19 03:17:37 +00:00
parent d6e8d93412
commit 5a30da57c6
4 changed files with 47 additions and 47 deletions

View File

@ -427,6 +427,7 @@ function install_plugin_install_status( $api, $loop = false ) {
$status = 'install'; $status = 'install';
$url = false; $url = false;
$update_file = false; $update_file = false;
$version = '';
/* /*
* Check to see if this plugin is known to be installed, * Check to see if this plugin is known to be installed,

View File

@ -1099,18 +1099,24 @@ function wp_edit_posts_query( $q = false ) {
} }
$avail_post_stati = get_available_post_statuses( $post_type ); $avail_post_stati = get_available_post_statuses( $post_type );
$post_status = '';
$perm = '';
if ( isset( $q['post_status'] ) && in_array( $q['post_status'], $post_stati ) ) { if ( isset( $q['post_status'] ) && in_array( $q['post_status'], $post_stati ) ) {
$post_status = $q['post_status']; $post_status = $q['post_status'];
$perm = 'readable'; $perm = 'readable';
} }
$orderby = '';
if ( isset( $q['orderby'] ) ) { if ( isset( $q['orderby'] ) ) {
$orderby = $q['orderby']; $orderby = $q['orderby'];
} elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ) ) ) { } elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ) ) ) {
$orderby = 'modified'; $orderby = 'modified';
} }
$order = '';
if ( isset( $q['order'] ) ) { if ( isset( $q['order'] ) ) {
$order = $q['order']; $order = $q['order'];
} elseif ( isset( $q['post_status'] ) && 'pending' == $q['post_status'] ) { } elseif ( isset( $q['post_status'] ) && 'pending' == $q['post_status'] ) {

View File

@ -269,13 +269,11 @@ class WP_Block_Parser {
*/ */
if ( 0 === $stack_depth ) { if ( 0 === $stack_depth ) {
if ( isset( $leading_html_start ) ) { if ( isset( $leading_html_start ) ) {
$this->output[] = (array) self::freeform( $this->output[] = (array) self::freeform( substr(
substr(
$this->document, $this->document,
$leading_html_start, $leading_html_start,
$start_offset - $leading_html_start $start_offset - $leading_html_start
) ) );
);
} }
$this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ); $this->output[] = (array) new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() );
@ -294,16 +292,13 @@ class WP_Block_Parser {
case 'block-opener': case 'block-opener':
// track all newly-opened blocks on the stack // track all newly-opened blocks on the stack
array_push( array_push( $this->stack, new WP_Block_Parser_Frame(
$this->stack,
new WP_Block_Parser_Frame(
new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ), new WP_Block_Parser_Block( $block_name, $attrs, array(), '', array() ),
$start_offset, $start_offset,
$token_length, $token_length,
$start_offset + $token_length, $start_offset + $token_length,
$leading_html_start $leading_html_start
) ) );
);
$this->offset = $start_offset + $token_length; $this->offset = $start_offset + $token_length;
return true; return true;
@ -396,22 +391,22 @@ class WP_Block_Parser {
return array( 'no-more-tokens', null, null, null, null ); return array( 'no-more-tokens', null, null, null, null );
} }
list( $match, $started_at ) = $matches[0]; list( $match, $started_at ) = $matches[ 0 ];
$length = strlen( $match ); $length = strlen( $match );
$is_closer = isset( $matches['closer'] ) && -1 !== $matches['closer'][1]; $is_closer = isset( $matches[ 'closer' ] ) && -1 !== $matches[ 'closer' ][ 1 ];
$is_void = isset( $matches['void'] ) && -1 !== $matches['void'][1]; $is_void = isset( $matches[ 'void' ] ) && -1 !== $matches[ 'void' ][ 1 ];
$namespace = $matches['namespace']; $namespace = $matches[ 'namespace' ];
$namespace = ( isset( $namespace ) && -1 !== $namespace[1] ) ? $namespace[0] : 'core/'; $namespace = ( isset( $namespace ) && -1 !== $namespace[ 1 ] ) ? $namespace[ 0 ] : 'core/';
$name = $namespace . $matches['name'][0]; $name = $namespace . $matches[ 'name' ][ 0 ];
$has_attrs = isset( $matches['attrs'] ) && -1 !== $matches['attrs'][1]; $has_attrs = isset( $matches[ 'attrs' ] ) && -1 !== $matches[ 'attrs' ][ 1 ];
/* /*
* Fun fact! It's not trivial in PHP to create "an empty associative array" since all arrays * Fun fact! It's not trivial in PHP to create "an empty associative array" since all arrays
* are associative arrays. If we use `array()` we get a JSON `[]` * are associative arrays. If we use `array()` we get a JSON `[]`
*/ */
$attrs = $has_attrs $attrs = $has_attrs
? json_decode( $matches['attrs'][0], /* as-associative */ true ) ? json_decode( $matches[ 'attrs' ][ 0 ], /* as-associative */ true )
: $this->empty_attrs; : $this->empty_attrs;
/* /*
@ -510,13 +505,11 @@ class WP_Block_Parser {
} }
if ( isset( $stack_top->leading_html_start ) ) { if ( isset( $stack_top->leading_html_start ) ) {
$this->output[] = (array) self::freeform( $this->output[] = (array) self::freeform( substr(
substr(
$this->document, $this->document,
$stack_top->leading_html_start, $stack_top->leading_html_start,
$stack_top->token_start - $stack_top->leading_html_start $stack_top->token_start - $stack_top->leading_html_start
) ) );
);
} }
$this->output[] = (array) $stack_top->block; $this->output[] = (array) $stack_top->block;

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.1-alpha-44296'; $wp_version = '5.1-alpha-44297';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.