Prevent unintended behavior when certain objects are unserialized.

Props ehtis, xknown.


git-svn-id: https://develop.svn.wordpress.org/trunk@56835 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Aaron Jorbin
2023-10-12 12:32:43 +00:00
parent 60c3fe8534
commit ed821528ee
6 changed files with 85 additions and 0 deletions

View File

@@ -230,6 +230,21 @@ final class WP_Block_Patterns_Registry {
return isset( $this->registered_patterns[ $pattern_name ] );
}
public function __wakeup() {
if ( ! $this->registered_patterns ) {
return;
}
if ( ! is_array( $this->registered_patterns ) ) {
throw new UnexpectedValueException();
}
foreach ( $this->registered_patterns as $value ) {
if ( ! is_array( $value ) ) {
throw new UnexpectedValueException();
}
}
$this->registered_patterns_outside_init = array();
}
/**
* Utility method to retrieve the main instance of the class.
*