Make WordPress Core


Ignore:
Timestamp:
10/12/2023 01:20:35 PM (2 years ago)
Author:
audrasjb
Message:

Prevent unintended behavior when certain objects are unserialized.

Props ehtis, xknown.
Merges [56835] to the 6.3 branch.

Location:
branches/6.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.3

  • branches/6.3/src/wp-includes/class-wp-theme.php

    r56180 r56842  
    743743
    744744    /**
     745     * Perform reinitialization tasks.
     746     *
     747     * Prevents a callback from being injected during unserialization of an object.
     748     *
     749     * @return void
     750     */
     751    public function __wakeup() {
     752        if ( $this->parent && ! $this->parent instanceof self ) {
     753            throw new UnexpectedValueException();
     754        }
     755        if ( $this->headers && ! is_array( $this->headers ) ) {
     756            throw new UnexpectedValueException();
     757        }
     758        foreach ( $this->headers as $value ) {
     759            if ( ! is_string( $value ) ) {
     760                throw new UnexpectedValueException();
     761            }
     762        }
     763        $this->headers_sanitized = array();
     764    }
     765
     766    /**
    745767     * Adds theme data to cache.
    746768     *
     
    18131835        return strnatcasecmp( $a->name_translated, $b->name_translated );
    18141836    }
     1837
     1838    private static function _check_headers_property_has_correct_type( $headers ) {
     1839        if ( ! is_array( $headers ) ) {
     1840            return false;
     1841        }
     1842        foreach ( $headers as $key => $value ) {
     1843            if ( ! is_string( $key ) || ! is_string( $value ) ) {
     1844                return false;
     1845            }
     1846        }
     1847        return true;
     1848    }
    18151849}
Note: See TracChangeset for help on using the changeset viewer.