Making WordPress.org

Changeset 14361


Ignore:
Timestamp:
01/15/2025 01:17:01 AM (12 months ago)
Author:
dd32
Message:

Plugin Directory: Import: Protect against invalid block.json's causing a PHP8 fatal.

A block.json should only have an array in the parent field, but some plugins incorrectly specify a string, instead of an array of strings.

Our Block Validator doesn't catch this, as we're using the REST API validator, which acceps strings for array types.

See https://core.trac.wordpress.org/ticket/54740

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php

    r14273 r14361  
    983983                $blocks,
    984984                function( $block ) {
    985                     return isset( $block->parent ) && count( $block->parent );
     985                    return isset( $block->parent ) && is_array( $block->parent ) && count( $block->parent );
    986986                }
    987987            );
     
    990990                $blocks,
    991991                function( $block ) {
    992                     return ! isset( $block->parent ) || ! count( $block->parent );
     992                    return ! isset( $block->parent ) || ! is_array( $block->parent ) || ! count( $block->parent );
    993993                }
    994994            );
Note: See TracChangeset for help on using the changeset viewer.