Commit Graph

239 Commits

Author SHA1 Message Date
Sergey Biryukov
856e1a27b8 Coding Standards: Use strict type check for in_array() and array_search().
This addresses all the remaining `WordPress.PHP.StrictInArray.MissingTrueStrict` issues in core.

Includes minor code layout fixes for better readability.

Follow-up to [47550].

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47557


git-svn-id: http://core.svn.wordpress.org/trunk@47332 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-04-09 15:43:10 +00:00
Sergey Biryukov
38676936ba Coding Standards: Use strict type check for in_array() and array_search() where strings are involved.
This reduces the number of `WordPress.PHP.StrictInArray.MissingTrueStrict` issues from 486 to 50.

Includes minor code layout fixes for better readability.

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47550


git-svn-id: http://core.svn.wordpress.org/trunk@47325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-04-05 03:02:11 +00:00
Sergey Biryukov
30572ef8ed Docs: Add a @staticvar entry for $transports in WP_Http::_dispatch_request().
Props utsav72640.
Fixes #48774.
Built from https://develop.svn.wordpress.org/trunk@47346


git-svn-id: http://core.svn.wordpress.org/trunk@47133 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-22 19:12:06 +00:00
Sergey Biryukov
641c632b0c Coding Standards: Use Yoda conditions where appropriate.
See #49222.
Built from https://develop.svn.wordpress.org/trunk@47219


git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-09 16:55:09 +00:00
Sergey Biryukov
47ed56f38f Code Modernization: Replace dirname( __FILE__ ) calls with __DIR__ magic constant.
This avoids the performance overhead of the function call every time `dirname( __FILE__ )` was used instead of `__DIR__`.

This commit also includes:

* Removing unnecessary parentheses from `include`/`require` statements. These are language constructs, not function calls.
* Replacing `include` statements for several files with `require_once`, for consistency:
 * `wp-admin/admin-header.php`
 * `wp-admin/admin-footer.php`
 * `wp-includes/version.php`

Props ayeshrajans, desrosj, valentinbora, jrf, joostdevalk, netweb.
Fixes #48082.
Built from https://develop.svn.wordpress.org/trunk@47198


git-svn-id: http://core.svn.wordpress.org/trunk@46998 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-06 06:33:11 +00:00
Sergey Biryukov
2f58dc5ce9 Docs: Add more specific description for WP_Http::processResponse() return value.
Props marekdedic, takeshifurusato.
Fixes #48351.
Built from https://develop.svn.wordpress.org/trunk@47161


git-svn-id: http://core.svn.wordpress.org/trunk@46961 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-02 03:27:05 +00:00
Sergey Biryukov
001ffe81fb Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47122


git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-29 00:45:18 +00:00
Sergey Biryukov
dd79e6e107 Docs: Correct DocBlock formatting for filters accepting the $parsed_args parameter.
Follow-up to [45667].

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47096


git-svn-id: http://core.svn.wordpress.org/trunk@46896 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-21 15:41:04 +00:00
Sergey Biryukov
dd4d98a368 Docs: In various @return tags, list the expected type first, instead of false.
Follow-up to [46696].

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47060


git-svn-id: http://core.svn.wordpress.org/trunk@46860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-11 18:32:05 +00:00
Sergey Biryukov
a79636f82a Docs: Correct @type for timeout argument in WP_Http::request().
Props georgestephanis, benedictsinger.
Fixes #49005.
Built from https://develop.svn.wordpress.org/trunk@46970


git-svn-id: http://core.svn.wordpress.org/trunk@46770 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-12-17 15:25:01 +00:00
Sergey Biryukov
adf35e9217 Coding Standards: Fix WPCS issue in [46690].
See #41880.
Built from https://develop.svn.wordpress.org/trunk@46692


git-svn-id: http://core.svn.wordpress.org/trunk@46492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-10 01:45:02 +00:00
Sergey Biryukov
5fb34a0a1c Docs: Improve documentation for WP_Http per the documentation standards.
Props hareesh-pillai, adnan.limdi, isabel_brison.
Fixes #41880.
Built from https://develop.svn.wordpress.org/trunk@46690


git-svn-id: http://core.svn.wordpress.org/trunk@46490 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-10 01:18:02 +00:00
John Blackbourn
3caaa40fc6 Docs: Switch more docs over to typed array notation, plus some fixes.
See #48303, #41756

Built from https://develop.svn.wordpress.org/trunk@46596


git-svn-id: http://core.svn.wordpress.org/trunk@46393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-26 21:09:04 +00:00
John Blackbourn
41d6b80d03 Docs: Fix and improve inline documentation for the HTTP API.
See #47110

Built from https://develop.svn.wordpress.org/trunk@46468


git-svn-id: http://core.svn.wordpress.org/trunk@46266 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-12 18:05:04 +00:00
John Blackbourn
2f46afbc53 Docs: Miscellaneous inline docs corrections and improvements.
See #47110 

Built from https://develop.svn.wordpress.org/trunk@46424


git-svn-id: http://core.svn.wordpress.org/trunk@46222 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-10-07 19:08:06 +00:00
John Blackbourn
e36d1bcbd8 Docs: Docblock corrections and improvements, mostly related to various pre_* filters.
See #47110

Built from https://develop.svn.wordpress.org/trunk@46232


git-svn-id: http://core.svn.wordpress.org/trunk@46044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-21 17:41:57 +00:00
Sergey Biryukov
18bd01985b Coding Standards: Rename $r variable used with wp_parse_args() to $parsed_args for clarity.
Props freewebmentor.
Fixes #45059.
Built from https://develop.svn.wordpress.org/trunk@45667


git-svn-id: http://core.svn.wordpress.org/trunk@45478 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-25 00:48:58 +00:00
Gary Pendergast
4803fc405e Coding Standards: Fix the Squiz.PHP.DisallowMultipleAssignments violations in wp-includes.
See #47632.


Built from https://develop.svn.wordpress.org/trunk@45590


git-svn-id: http://core.svn.wordpress.org/trunk@45401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-02 23:42:58 +00:00
Gary Pendergast
55af0f0d0a Coding Standards: Fix/ignore the WordPress.NamingConventions.ValidFunctionName violations.
See #47632


Built from https://develop.svn.wordpress.org/trunk@45580


git-svn-id: http://core.svn.wordpress.org/trunk@45391 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-01 08:01:57 +00:00
John Blackbourn
eeba1c1244 HTTP API: Ensure the http_api_debug hook is fired for all responses.
This means that logging and debugging functionality can access the error code and error message for erroneous responses under all conditions. The hook is not fired when a request is short-circuited with the `pre_http_request` filter, because this filter itself can be used in that situation.

Fixes #25747

Built from https://develop.svn.wordpress.org/trunk@45504


git-svn-id: http://core.svn.wordpress.org/trunk@45315 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-06-08 17:10:52 +00:00
Gary Pendergast
cbdffc4a1e HTTP: Add support for the host-only flag to Wp_Http_Cookie.
Props soulseekah.
Fixes #43231.

Built from https://develop.svn.wordpress.org/trunk@45135


git-svn-id: http://core.svn.wordpress.org/trunk@44944 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-04-08 05:32:51 +00:00
desrosj
4e3e9ca9cf Docs: Update since annotation for new $url parameter for several HTTP related filters.
Introduced in [42682].

Fixes #42186.
Built from https://develop.svn.wordpress.org/trunk@44397


git-svn-id: http://core.svn.wordpress.org/trunk@44227 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-04 21:58:51 +00:00
Sergey Biryukov
f64a2674db Docs: Update @deprecated tag for WP_Http::_dispatch_request(). See [42766].
Fixes #43414.
Built from https://develop.svn.wordpress.org/trunk@44346


git-svn-id: http://core.svn.wordpress.org/trunk@44176 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-20 01:59:48 +00:00
John Blackbourn
810cbb537b Docs: Add missing HTTP methods to the list of those supported.
See #42505

Built from https://develop.svn.wordpress.org/trunk@43258


git-svn-id: http://core.svn.wordpress.org/trunk@43087 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-05-14 15:23:21 +00:00
John Blackbourn
bbcb4300a3 Docs: Correct and improve various inline documentation.
See #42505

Built from https://develop.svn.wordpress.org/trunk@42877


git-svn-id: http://core.svn.wordpress.org/trunk@42707 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-25 19:35:29 +00:00
Sergey Biryukov
e786f9eb91 Docs: Mark WP_Http::_dispatch_request() as deprecated. It's no longer used since [37428].
Fixes #43414.
Built from https://develop.svn.wordpress.org/trunk@42766


git-svn-id: http://core.svn.wordpress.org/trunk@42596 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-28 03:48:30 +00:00
Sergey Biryukov
0b45a1e5fa Docs: Remove erroneous @static notation from WP_Http::_dispatch_request(), added in [32650].
The method was never user as static.

Props birgire.
See #42803.
Built from https://develop.svn.wordpress.org/trunk@42751


git-svn-id: http://core.svn.wordpress.org/trunk@42581 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-25 21:35:30 +00:00
Sergey Biryukov
bd9cdde1eb Docs: Remove duplicated DocBlock for http_response hook in WP_Http::_dispatch_request().
The filter is already documented in `WP_Http::request()`.

See #42505.
Built from https://develop.svn.wordpress.org/trunk@42750


git-svn-id: http://core.svn.wordpress.org/trunk@42580 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-25 21:32:30 +00:00
Sergey Biryukov
08227812a0 Docs: Remove @static notations from method DocBlocks in wp-includes/* classes.
This tag has been used in the past, but should no longer be used. Just using the `static` keyword in code is enough for PhpDocumentor on PHP5+ to recognize static variables and methods, and PhpDocumentor will mark them as static.

Props birgire.
See #42803.
Built from https://develop.svn.wordpress.org/trunk@42746


git-svn-id: http://core.svn.wordpress.org/trunk@42576 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-25 20:22:30 +00:00
John Blackbourn
b1ed10ab9a HTTP API: Add the URL as a paramter to various HTTP related filters.
Props paulschreiber, purnendu

Fixes #42186

Built from https://develop.svn.wordpress.org/trunk@42682


git-svn-id: http://core.svn.wordpress.org/trunk@42510 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-09 18:11:30 +00:00
Gary Pendergast
aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


Built from https://develop.svn.wordpress.org/trunk@42343


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
John Blackbourn
aed08a0f25 HTTP API: Add a WP_Http class constant for the HTTP status code 301.
Fixes #42490

Built from https://develop.svn.wordpress.org/trunk@42208


git-svn-id: http://core.svn.wordpress.org/trunk@42037 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-20 20:54:49 +00:00
Sergey Biryukov
fb8d73a0f7 Docs: Correct type and description for the $data parameter in WP_Http::browser_redirect_compatibility().
Fixes #41380.
Built from https://develop.svn.wordpress.org/trunk@41907


git-svn-id: http://core.svn.wordpress.org/trunk@41741 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-18 16:38:48 +00:00
Sergey Biryukov
fff6cc8fc8 Docs: Change $args to $r in the DocBlock for http_api_debug filter to match the variable name.
Props bor0, ronakganatra.
Fixes #41379.
Built from https://develop.svn.wordpress.org/trunk@41562


git-svn-id: http://core.svn.wordpress.org/trunk@41395 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-22 09:33:47 +00:00
Drew Jaynes
8e71c49a12 Docs: Add missing documentation for the $data parameter for WP_Http::browser_redirect_compatibility().
Props ronakganatra for the initial patch.
Fixes #41380.

Built from https://develop.svn.wordpress.org/trunk@41218


git-svn-id: http://core.svn.wordpress.org/trunk@41058 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-03 15:24:44 +00:00
Drew Jaynes
0860bb2771 Docs: Remove @access notations from method DocBlocks in wp-includes/* classes.
Prior to about 2013, many class methods lacked even access modifiers which made the `@access` notations that much more useful. Now that we've gotten to a point where the codebase is more mature from a maintenance perspective and we can finally remove these notations. Notable exceptions to this change include standalone functions notated as private as well as some classes still considered to represent "private" APIs.

See #41452.

Built from https://develop.svn.wordpress.org/trunk@41162


git-svn-id: http://core.svn.wordpress.org/trunk@41002 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-27 00:41:44 +00:00
Sergey Biryukov
54b8dafd62 Docs: Change @version entry for WP_Http::buildCookieHeader() to @since.
See #41381.
Built from https://develop.svn.wordpress.org/trunk@41105


git-svn-id: http://core.svn.wordpress.org/trunk@40945 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-20 13:15:43 +00:00
Sergey Biryukov
2026da9512 Docs: Add @access entries for WP_Http::block_request(), ::handle_redirects(), and ::is_ip_address().
Props ronakganatra.
Fixes #41381.
Built from https://develop.svn.wordpress.org/trunk@41104


git-svn-id: http://core.svn.wordpress.org/trunk@40944 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-20 13:14:44 +00:00
Sergey Biryukov
332884f8dc Docs: Add a missing quote in user-agent argument description in WP_Http::request().
Props ixkaito.
Fixes #41154.
Built from https://develop.svn.wordpress.org/trunk@40934


git-svn-id: http://core.svn.wordpress.org/trunk@40784 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-06-25 07:00:42 +00:00
Pascal Birchler
76d77e927b Improve redirect handling
Built from https://develop.svn.wordpress.org/trunk@40689


git-svn-id: http://core.svn.wordpress.org/trunk@40552 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-05-16 08:38:42 +00:00
Dion Hulse
35a0240fb2 WP_HTTP: Map internal Requests hooks to WordPress actions.
This change introduces a `requests-{$hook}` action which can be used to hook into Requests hooks, and restores the `http_api_curl` action.

Props rmccue.
Fixes #37843.

Built from https://develop.svn.wordpress.org/trunk@39212


git-svn-id: http://core.svn.wordpress.org/trunk@39152 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-13 10:36:29 +00:00
Dion Hulse
7ac6b18d89 HTTP: Call mbstring_binary_safe_encoding() before making a request with Requests to avoid issues with mbstring.func_overload.
Props SergeyBiryukov.
Fixes #38226.

Built from https://develop.svn.wordpress.org/trunk@38894


git-svn-id: http://core.svn.wordpress.org/trunk@38837 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-25 00:45:29 +00:00
Dion Hulse
d317fa487f HTTP: Update Requests to master (0048f3c) which fixes a number of outstanding issues.
Fixes #38070, #37733 by reverting part of [38429] and using the fix in Requests.
Fixes #37992 allowing for connecting to SSL resources on ports other than 443.
Fixes #37991 by not sending default ports in the `Host:` header.
Fixes #37839 to match and decode Chunked responses correctly.
Fixes #38232 allowing a SSL connection to ignore the hostname of the certificate when verification is disabled.

Built from https://develop.svn.wordpress.org/trunk@38727


git-svn-id: http://core.svn.wordpress.org/trunk@38670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-05 03:24:37 +00:00
Scott Taylor
a3ffebce30 Bootstrap: do not go gentle into that good night r38411, r38412, and parts of r38389.
See #36335.

Built from https://develop.svn.wordpress.org/trunk@38470


git-svn-id: http://core.svn.wordpress.org/trunk@38411 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-31 16:31:29 +00:00
Scott Taylor
9383bf8f74 General: use get_bloginfo( 'version' ) instead of global $wp_version in several locations - excluding those locations which reload version.php mid-flight.
See #37699.

Built from https://develop.svn.wordpress.org/trunk@38459


git-svn-id: http://core.svn.wordpress.org/trunk@38400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-31 05:49:37 +00:00
Dion Hulse
30270d851f HTTP: Accept non-string values in cookies, fixing a regression since 4.5.
Props swissspidy.
Fixes #37768 for trunk.

Built from https://develop.svn.wordpress.org/trunk@38430


git-svn-id: http://core.svn.wordpress.org/trunk@38371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-29 02:42:45 +00:00
Dion Hulse
e45ebb28f2 HTTP: Handle an edgecase within the URI parsing library included in Requests, where if a double slash exists at the start of the path the URL is passed to cURL malformed.
Props flixos90 for initial patch.
Fixes #37733 for trunk.

Built from https://develop.svn.wordpress.org/trunk@38429


git-svn-id: http://core.svn.wordpress.org/trunk@38370 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-29 02:33:34 +00:00
Scott Taylor
390ceba6c7 Bootstrap: after r38409 and r38410, revert r38402 which reverted r38399.
This fixes the paths in `wp-vendor/` that were including `src`. I want to drop this in so we can find out what else will break.

See #36335.

Built from https://develop.svn.wordpress.org/trunk@38411


git-svn-id: http://core.svn.wordpress.org/trunk@38352 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-27 22:32:37 +00:00
Dion Hulse
0e31a46161 Bootstrap: Revert [38399] as it's broken /build/ and subsequently core.svn.wordpress.org.
The generated classmaps reference `/src/` files and operates in the assumption that the base directory is one level above `wp-settings.php`, which it isn't after our build processes are run.

See #36335

Built from https://develop.svn.wordpress.org/trunk@38402


git-svn-id: http://core.svn.wordpress.org/trunk@38343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-27 14:37:32 +00:00
Scott Taylor
6a529648cf Bootstrap: Autoload classes using a Composer-generated PHP 5.2-compatible Autoloader.
* `wp-admin` and `wp-includes` are scanned for classes to autoload
* Several 3rd-party and Ryan McCue-shaped libraries are excluded when the classmap is generated, see `composer.json`: `autoload.exclude-from-classmap`
* `wp-vendor/autoload_52.php` is included at the top of `wp-settings.php` - no changes need to be made to unit tests to include the autoloader
* An avalanche of `require()` and `require_once()` calls that loaded class files have been removed from the codebase.

The following files have been added to `svn:ignore` - they are not 5.2-compatible and fail during pre-commit:
* src/wp-vendor/autoload.php
* src/wp-vendor/composer/autoload_real.php
* src/wp-vendor/composer/autoload_static.php
* src/wp-vendor/composer/ClassLoader.php

We favor these files instead:
* src/wp-vendor/autoload_52.php
* src/wp-vendor/composer/autoload_real_52.php
* src/wp-vendor/composer/ClassLoader52.php

When new PHP classes are added to the codebase, simply run `composer install` or `composer update` from the project root to update the autoloader.

The future is now.

See #36335.

Built from https://develop.svn.wordpress.org/trunk@38399


git-svn-id: http://core.svn.wordpress.org/trunk@38340 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-27 09:15:29 +00:00