Make WordPress Core


Ignore:
Timestamp:
10/12/2023 12:32:43 PM (8 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-patterns-registry.php

    r56818 r56835  
    231231    }
    232232
     233    public function __wakeup() {
     234        if ( ! $this->registered_patterns ) {
     235            return;
     236        }
     237        if ( ! is_array( $this->registered_patterns ) ) {
     238            throw new UnexpectedValueException();
     239        }
     240        foreach ( $this->registered_patterns as $value ) {
     241            if ( ! is_array( $value ) ) {
     242                throw new UnexpectedValueException();
     243            }
     244        }
     245        $this->registered_patterns_outside_init = array();
     246    }
     247
    233248    /**
    234249     * Utility method to retrieve the main instance of the class.
Note: See TracChangeset for help on using the changeset viewer.