Make WordPress Core


Ignore:
Timestamp:
10/12/2023 12:32:43 PM (11 months ago)
Author:
jorbin
Message:

Prevent unintended behavior when certain objects are unserialized.

Props ehtis, xknown.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-type-registry.php

    r54133 r56835  
    169169    }
    170170
     171    public function __wakeup() {
     172        if ( ! $this->registered_block_types ) {
     173            return;
     174        }
     175        if ( ! is_array( $this->registered_block_types ) ) {
     176            throw new UnexpectedValueException();
     177        }
     178        foreach ( $this->registered_block_types as $value ) {
     179            if ( ! $value instanceof WP_Block_Type ) {
     180                throw new UnexpectedValueException();
     181            }
     182        }
     183    }
     184
    171185    /**
    172186     * Utility method to retrieve the main instance of the class.
Note: See TracChangeset for help on using the changeset viewer.