Make WordPress Core


Ignore:
Timestamp:
12/06/2021 09:29:00 PM (2 years ago)
Author:
SergeyBiryukov
Message:

HTTP API: Revert changeset [52244].

Reverting Requests 2.0.0 changes and moving to WordPress 6.0 cycle. Why? The namespace and file case renaming revealed 2 issues in Core's upgrader process.

See https://core.trac.wordpress.org/ticket/54504#comment:22 for more information.

Follow-up to [52327].

See #54562, #54504.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php

    r52244 r52328  
    33 * Case-insensitive dictionary, suitable for HTTP headers
    44 *
    5  * @package Requests\Utilities
     5 * @package Requests
     6 * @subpackage Utilities
    67 */
    7 
    8 namespace WpOrg\Requests\Utility;
    9 
    10 use ArrayAccess;
    11 use ArrayIterator;
    12 use IteratorAggregate;
    13 use ReturnTypeWillChange;
    14 use WpOrg\Requests\Exception;
    158
    169/**
    1710 * Case-insensitive dictionary, suitable for HTTP headers
    1811 *
    19  * @package Requests\Utilities
     12 * @package Requests
     13 * @subpackage Utilities
    2014 */
    21 class CaseInsensitiveDictionary implements ArrayAccess, IteratorAggregate {
     15class Requests_Utility_CaseInsensitiveDictionary implements ArrayAccess, IteratorAggregate {
    2216    /**
    2317     * Actual item data
     
    2519     * @var array
    2620     */
    27     protected $data = [];
     21    protected $data = array();
    2822
    2923    /**
     
    3226     * @param array $data Dictionary/map to convert to case-insensitive
    3327     */
    34     public function __construct(array $data = []) {
    35         foreach ($data as $offset => $value) {
    36             $this->offsetSet($offset, $value);
     28    public function __construct(array $data = array()) {
     29        foreach ($data as $key => $value) {
     30            $this->offsetSet($key, $value);
    3731        }
    3832    }
     
    4135     * Check if the given item exists
    4236     *
    43      * @param string $offset Item key
     37     * @param string $key Item key
    4438     * @return boolean Does the item exist?
    4539     */
    46     #[ReturnTypeWillChange]
    47     public function offsetExists($offset) {
    48         if (is_string($offset)) {
    49             $offset = strtolower($offset);
    50         }
    51 
    52         return isset($this->data[$offset]);
     40    public function offsetExists($key) {
     41        $key = strtolower($key);
     42        return isset($this->data[$key]);
    5343    }
    5444
     
    5646     * Get the value for the item
    5747     *
    58      * @param string $offset Item key
    59      * @return string|null Item value (null if the item key doesn't exist)
     48     * @param string $key Item key
     49     * @return string|null Item value (null if offsetExists is false)
    6050     */
    61     #[ReturnTypeWillChange]
    62     public function offsetGet($offset) {
    63         if (is_string($offset)) {
    64             $offset = strtolower($offset);
    65         }
    66 
    67         if (!isset($this->data[$offset])) {
     51    public function offsetGet($key) {
     52        $key = strtolower($key);
     53        if (!isset($this->data[$key])) {
    6854            return null;
    6955        }
    7056
    71         return $this->data[$offset];
     57        return $this->data[$key];
    7258    }
    7359
     
    7561     * Set the given item
    7662     *
    77      * @param string $offset Item name
     63     * @throws Requests_Exception On attempting to use dictionary as list (`invalidset`)
     64     *
     65     * @param string $key Item name
    7866     * @param string $value Item value
    79      *
    80      * @throws \WpOrg\Requests\Exception On attempting to use dictionary as list (`invalidset`)
    8167     */
    82     #[ReturnTypeWillChange]
    83     public function offsetSet($offset, $value) {
    84         if ($offset === null) {
    85             throw new Exception('Object is a dictionary, not a list', 'invalidset');
     68    public function offsetSet($key, $value) {
     69        if ($key === null) {
     70            throw new Requests_Exception('Object is a dictionary, not a list', 'invalidset');
    8671        }
    8772
    88         if (is_string($offset)) {
    89             $offset = strtolower($offset);
    90         }
    91 
    92         $this->data[$offset] = $value;
     73        $key              = strtolower($key);
     74        $this->data[$key] = $value;
    9375    }
    9476
     
    9678     * Unset the given header
    9779     *
    98      * @param string $offset
     80     * @param string $key
    9981     */
    100     #[ReturnTypeWillChange]
    101     public function offsetUnset($offset) {
    102         if (is_string($offset)) {
    103             $offset = strtolower($offset);
    104         }
    105 
    106         unset($this->data[$offset]);
     82    public function offsetUnset($key) {
     83        unset($this->data[strtolower($key)]);
    10784    }
    10885
     
    11087     * Get an iterator for the data
    11188     *
    112      * @return \ArrayIterator
     89     * @return ArrayIterator
    11390     */
    114     #[ReturnTypeWillChange]
    11591    public function getIterator() {
    11692        return new ArrayIterator($this->data);
Note: See TracChangeset for help on using the changeset viewer.