Make WordPress Core


Ignore:
Timestamp:
12/06/2021 09:29:00 PM (5 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/Auth/Basic.php

    r52244 r52328  
    33 * Basic Authentication provider
    44 *
    5  * @package Requests\Authentication
     5 * @package Requests
     6 * @subpackage Authentication
    67 */
    7 
    8 namespace WpOrg\Requests\Auth;
    9 
    10 use WpOrg\Requests\Auth;
    11 use WpOrg\Requests\Exception\ArgumentCount;
    12 use WpOrg\Requests\Exception\InvalidArgument;
    13 use WpOrg\Requests\Hooks;
    148
    159/**
     
    1913 * header.
    2014 *
    21  * @package Requests\Authentication
     15 * @package Requests
     16 * @subpackage Authentication
    2217 */
    23 class Basic implements Auth {
     18class Requests_Auth_Basic implements Requests_Auth {
    2419        /**
    2520         * Username
     
    3934         * Constructor
    4035         *
    41          * @since 2.0 Throws an `InvalidArgument` exception.
    42          * @since 2.0 Throws an `ArgumentCount` exception instead of the Requests base `Exception.
    43          *
     36         * @throws Requests_Exception On incorrect number of arguments (`authbasicbadargs`)
    4437         * @param array|null $args Array of user and password. Must have exactly two elements
    45          *
    46          * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed argument is not an array or null.
    47          * @throws \WpOrg\Requests\Exception\ArgumentCount   On incorrect number of array elements (`authbasicbadargs`).
    4838         */
    4939        public function __construct($args = null) {
    5040                if (is_array($args)) {
    5141                        if (count($args) !== 2) {
    52                                 throw ArgumentCount::create('an array with exactly two elements', count($args), 'authbasicbadargs');
     42                                throw new Requests_Exception('Invalid number of arguments', 'authbasicbadargs');
    5343                        }
    5444
    5545                        list($this->user, $this->pass) = $args;
    56                         return;
    57                 }
    58 
    59                 if ($args !== null) {
    60                         throw InvalidArgument::create(1, '$args', 'array|null', gettype($args));
    6146                }
    6247        }
     
    6550         * Register the necessary callbacks
    6651         *
    67          * @see \WpOrg\Requests\Auth\Basic::curl_before_send()
    68          * @see \WpOrg\Requests\Auth\Basic::fsockopen_header()
    69          * @param \WpOrg\Requests\Hooks $hooks Hook system
     52         * @see curl_before_send
     53         * @see fsockopen_header
     54         * @param Requests_Hooks $hooks Hook system
    7055         */
    71         public function register(Hooks $hooks) {
    72                 $hooks->register('curl.before_send', [$this, 'curl_before_send']);
    73                 $hooks->register('fsockopen.after_headers', [$this, 'fsockopen_header']);
     56        public function register(Requests_Hooks $hooks) {
     57                $hooks->register('curl.before_send', array($this, 'curl_before_send'));
     58                $hooks->register('fsockopen.after_headers', array($this, 'fsockopen_header'));
    7459        }
    7560
     
    7762         * Set cURL parameters before the data is sent
    7863         *
    79          * @param resource|\CurlHandle $handle cURL handle
     64         * @param resource $handle cURL resource
    8065         */
    8166        public function curl_before_send(&$handle) {
Note: See TracChangeset for help on using the changeset viewer.