44459 Commits

Author SHA1 Message Date
Sergey Biryukov
43a8715ded Tests: Rename classes in phpunit/tests/error-protection/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623], [51639], [51646].

See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@51650 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-21 15:32:53 +00:00
Andrew Ozz
a2c0ccd117 Editor: Replace the remaining references to wp.editor with wp.oldEditor.
Props zieladam.
Fixes #53762.

git-svn-id: https://develop.svn.wordpress.org/trunk@51649 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-21 00:18:25 +00:00
Andrew Ozz
fe3d953437 REST API: Remove trailing slashes when preloading requests and add unit tests for it.
Props antonvlasenko.
Fixes #51636.

git-svn-id: https://develop.svn.wordpress.org/trunk@51648 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-20 23:43:21 +00:00
Jonathan Desrosiers
40506e7e64 Build/Test Tools: Include the commit short summary in Slack messages.
This gives more context to GitHub Action related Slack messages without the need to click the workflow URL, or unfurl the links (which shows lots of unnecessary information, such as the repository description and image).

Props earnjam.
See #52644.

git-svn-id: https://develop.svn.wordpress.org/trunk@51647 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-20 18:58:18 +00:00
Sergey Biryukov
ee81f71ac6 Tests: Rename classes in phpunit/tests/editor/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623], [51639].

See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@51646 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-20 16:11:04 +00:00
Kelly Choyce-Dwan
220a6cc805 Privacy: Add space below page selector.
Sometimes the submit button wraps to a new line, either because the button label translation is long, or there are long page names. When it wraps, there should be space between the select dropdown and the button.

Props audrasjb, mukesh27, guillaumeturpin.
Fixes #53782.



git-svn-id: https://develop.svn.wordpress.org/trunk@51645 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-19 20:57:24 +00:00
Kelly Choyce-Dwan
4583801bc6 Toolbar: Limit the icon transition style to color only.
When transition is `all`, it also applies to the icon size, which can cause a bug in Safari where icons get stuck in the wrong size when resizing the browser window. The only expected animation is on the color property, so the transition can be limited to just `color`.

Props johnjamesjacoby, sabernhardt, SergeyBiryukov, audrasjb.
Fixes #43423.



git-svn-id: https://develop.svn.wordpress.org/trunk@51644 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-19 17:23:23 +00:00
Sergey Biryukov
0778740cb4 Tests: Move loading the WP_Community_Events class to set_up_before_class().
This ensures that the class is loaded once before the first test of the test case class is run, and `require_once()` is not unnecessarily called for each test method individually.

Follow-up to [40607], [51628].

See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@51641 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-19 13:59:36 +00:00
Sergey Biryukov
e20beacb6e Tests: Rename classes in phpunit/tests/admin/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623].

See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@51639 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-19 13:08:43 +00:00
Sergey Biryukov
05f28947e7 Media: Check the return type of _get_cron_array() in WP_Media_List_Table::prepare_items().
The following warnings could, in very select circumstances, be shown:
{{{
// PHP 8.0 and higher:
Warning: foreach() argument must be of type array|object, bool given

// PHP 5.6 – 7.4
Warning: Invalid argument supplied for foreach()
}}}

In `WP_Media_List_Table::prepare_items()`, the cron info array is retrieved via a call to `_get_cron_array()`, but as the documentation (correctly) states, the return type of that function is `array|false`, where `false` is returned for a virgin site, with no cron jobs scheduled yet.

However, no type check is done on the return value, and the method just blindly continues by using it in a `foreach`.

Fixed by adding validation for the returned value from `_get_cron_array()` and only running the `foreach` when the returned value is an array.

Reference: [https://developer.wordpress.org/reference/functions/_get_cron_array/ WordPress Developer Resources: _get_cron_array()]

Follow-up to [48417].

Props jrf, hellofromTonya, mukesh27.
Fixes #53949.

git-svn-id: https://develop.svn.wordpress.org/trunk@51638 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-19 12:43:03 +00:00
Peter Wilson
0222625c37 Customize: Hide native control on background position field.
Hide the browser's native radio button on the custom background position selector in the Customizer and the legacy background screen. This fixes an issue causing both to display.

Props mukesh27, ravipatel, sabernhardt, walbo.
Fixes #53803.


git-svn-id: https://develop.svn.wordpress.org/trunk@51637 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-19 02:06:06 +00:00
Sergey Biryukov
66cb5e3689 Code Modernization: Silence the deprecation warning for auto_detect_line_endings.
Since PHP 8.1, the `auto_detect_line_endings` setting is deprecated:

> The `auto_detect_line_endings` ini setting modifies the behavior of `file()` and `fgets()` to support an isolated `\r` (as opposed to `\n` or `\r\n`) as a newline character. These newlines were used by “Classic” Mac OS, a system which has been discontinued in 2001, nearly two decades ago. Interoperability with such systems is no longer relevant.

Reference: [https://wiki.php.net/rfc/deprecations_php_8_1#auto_detect_line_endings_ini_setting PHP RFC: Deprecations for PHP 8.1: auto_detect_line_endings ini setting]

> The `auto_detect_line_endings` ini setting has been deprecated. If necessary, handle `\r` line breaks manually instead.

Reference: [1cf4fb739f/UPGRADING (L456-L457) PHP 8.1 Upgrade Notes].

This commit fixes the warning when running tests for the `PO` class:
{{{
Deprecated: auto_detect_line_endings is deprecated in /var/www/src/wp-includes/pomo/po.php on line 16
}}}

While deprecated, the actual `auto_detect_line_endings` functionality has not been removed from PHP (yet) and will still work until PHP 9.0.

For now, we're silencing the deprecation notice as there may still be translation files around which haven't been updated in a long time and which still use the old MacOS standalone `\r` as a line ending.

This should be revisited when PHP 9.0 is in alpha/beta.

Follow-up to [51633].

Props jrf.
See #53635.

git-svn-id: https://develop.svn.wordpress.org/trunk@51636 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-18 21:57:21 +00:00
Sergey Biryukov
7d88c013f4 External Libraries: Restore the phpcs:ignore statements in PHPMailer.
These are necessary for a passing PHP Compatibility scan.

Follow-up to [48045], [51634].

See #53953.

git-svn-id: https://develop.svn.wordpress.org/trunk@51635 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-18 14:07:17 +00:00
Sergey Biryukov
9aa1589807 External Libraries: Upgrade PHPMailer to version 6.5.1.
The latest release includes preliminary PHP 8.1 support, as well as some small bug fixes.

Release notes: https://github.com/PHPMailer/PHPMailer/releases/tag/v6.5.1

For a full list of changes in this update, see the PHPMailer GitHub:
https://github.com/PHPMailer/PHPMailer/compare/v6.5.0...v6.5.1

Follow-up to [50628], [50799], [51169].

Props jrf.
Fixes #53953.

git-svn-id: https://develop.svn.wordpress.org/trunk@51634 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-18 13:52:16 +00:00
SergeyBiryukov
27a2a804a3 Code Modernization: Only set auto_detect_line_endings in PHP < 8.1.
Since PHP 8.1, the `auto_detect_line_endings` setting is deprecated:

> The `auto_detect_line_endings` ini setting modifies the behavior of `file()` and `fgets()` to support an isolated `\r` (as opposed to `\n` or `\r\n`) as a newline character. These newlines were used by “Classic” Mac OS, a system which has been discontinued in 2001, nearly two decades ago. Interoperability with such systems is no longer relevant.

Reference: [https://wiki.php.net/rfc/deprecations_php_8_1#auto_detect_line_endings_ini_setting PHP RFC: Deprecations for PHP 8.1: auto_detect_line_endings ini setting]

> The `auto_detect_line_endings` ini setting has been deprecated. If necessary, handle `\r` line breaks manually instead.

Reference: [1cf4fb739f/UPGRADING (L456-L457) PHP 8.1 Upgrade Notes].

This commit fixes the warning when running tests for the `PO` class:
{{{
Deprecated: auto_detect_line_endings is deprecated in /var/www/src/wp-includes/pomo/po.php on line 16
}}}

Follow-up to [10584], [51628].

See #53635.

git-svn-id: https://develop.svn.wordpress.org/trunk@51633 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-18 13:22:02 +00:00
Peter Wilson
cd616cf406 Media: Increase number of media items displayed per page.
Increase the number of media items displayed per page from 40 to 80 to improve the experience for users navigating the library on sites with a large quantity of media in the library.

Props AlGala, antpb, hellofromTonya, joedolson, SergeyBiryukov, wb1234.
Fixes #53827.



git-svn-id: https://develop.svn.wordpress.org/trunk@51632 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-18 05:59:28 +00:00
Peter Wilson
acfe40f335 Media: Fix layout of media library modal on narrow screens.
Reduces the right margin of the media library modal on small and medium width screens to remove excess white-space. On very narrow screens this was preventing the media icons from displaying.

Props andraganescu, desrosj, joedolson, moch11, mukesh27, sabernhardt, SergeyBiryukov, zieladam.
Fixes #53679.


git-svn-id: https://develop.svn.wordpress.org/trunk@51631 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-18 05:37:01 +00:00
Sergey Biryukov
6ec2594d74 Code Modernization: Check the return type of parse_url() in ms_cookie_constants().
As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.

Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]

It is entirely possible for the `siteurl` option to not have a "path" component.

In PHP 8.1, this would lead to a `trim(): Passing null to parameter #1 ($string) of type string is deprecated` notice.

Changing the logic around and adding validation for the return type value of `parse_url()` prevents that.

As this function is declaring global constants, adding tests for this change is not really an option without potentially affecting other tests.

Follow-up to [51606], [51622], [51626], [51629].

Props jrf, hellofromTonya, SergeyBiryukov.
See #53635.

git-svn-id: https://develop.svn.wordpress.org/trunk@51630 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-17 22:07:55 +00:00
Sergey Biryukov
0f51a98602 Code Modernization: Check the return type of parse_url() on Plugin/Theme Editor screens.
As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.

Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]

While it is probably unlikely that someone would have a direct link to the plugin/theme editor on their home page or even on someone else's homepage, it is entirely possible for the referrer URL to not have a "path" component.

In PHP 8.1, this would lead to a `basename(): Passing null to parameter #1 ($string) of type string is deprecated` notice.

Changing the logic around and adding validation for the return type value of `parse_url()` prevents that.

Follow-up to [51606], [51622], [51626].

Props jrf, hellofromTonya, SergeyBiryukov.
See #53635.

git-svn-id: https://develop.svn.wordpress.org/trunk@51629 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-17 21:55:22 +00:00
Sergey Biryukov
16b448416b Tests: Move loading the PO class to set_up_before_class().
This ensures that the class is loaded once before the first test of the test case class is run, and `require_once()` is not unnecessarily called for each test method individually.

Follow-up to [1106/tests].

See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@51628 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-17 20:01:15 +00:00
Sergey Biryukov
6d574d7cab Tests: Use a better return type check for parse_url() in do_enclose() tests.
Since the `pathinfo()` function accepts a string, checking for that specifically is more consistent with similar checks elsewhere in core.

Follow-up to [51606], [51622], [51626].

See #53635.

git-svn-id: https://develop.svn.wordpress.org/trunk@51627 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-17 00:27:38 +00:00
Sergey Biryukov
5f5895bf61 Code Modernization: Check the return type of parse_url() in download_url().
As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.

Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]

This commit adds three unit tests for `download_url()`:

* The first test is "girl-scouting" to make sure that the code up to the point where the error is expected is tested.
* The second test exposed a PHP 8.1 `basename(): Passing null to parameter #1 ($path) of type string is deprecated` error due to the call to `parse_url()` returning `null` when the component requested does not exist in the passed URL.
* The output of the call to `parse_url()` stored in the `$url_path` variable is used in more places in the function logic. The third test exposes a second PHP 8.1 deprecation notice, this time for `substr(): Passing null to parameter #1 ($string) of type string is deprecated`.

This commit also removes duplicate `parse_url()` calls. Neither `$url` nor `$url_filename` are changed between when they are first received/defined and when they are re-used, so there is no need to repeat the function calls.

Follow-up to [51606], [51622].

Props jrf, hellofromTonya, SergeyBiryukov.
See #53635.

git-svn-id: https://develop.svn.wordpress.org/trunk@51626 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-17 00:14:20 +00:00
Sergey Biryukov
d7c22d29cf Code Modernization: Check the input type in validate_file().
This fixes a `preg_match_all(): Passing null to parameter #2 ($subject) of type string is deprecated` notice on PHP 8.1.

The behavior for `null` and `string` input is covered by the existing `Tests_Functions::test_validate_file()` test.

Effect: Errors down by 238, assertions up by 1920, failures down by 1.

Props jrf, hellofromTonya, SergeyBiryukov.
See #53635.

git-svn-id: https://develop.svn.wordpress.org/trunk@51625 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-16 22:51:47 +00:00
Sergey Biryukov
d93f76dca8 Code Modernization: Correct handling of null in wp_parse_str().
This fixes `parse_str(): Passing null to parameter #1 ($string) of type string is deprecated` notices on PHP 8.1, without change in behaviour.

Impact: 311 of the pre-existing tests are affected by this issue.

The PHP native `parse_str()` function expects a string, however, based on the failing tests, it is clear there are functions in WordPress which passes a non-string – including `null` – value to the `wp_parse_str()` function, which would subsequently pass it onto the PHP native function without further input validation.

Most notable offender is the `wp_parse_args()` function which special cases arrays and objects, but passes everything else off to `wp_parse_str()`.

Several ways to fix this issue have been explored, including checking the received value with `is_string()` or `is_scalar()` before passing it off to the PHP native `parse_str()` function.

In the end it was decided against these in favor of a string cast as:
* `is_string()` would significantly change the behavior for anything non-string.
* `is_scalar()` up to a point as well, as it does not take objects with a `__toString()` method into account.

Executing a string cast on the received value before passing it on maintains the pre-existing behavior while still preventing the deprecation notice coming from PHP 8.1.

Reference: [https://www.php.net/manual/en/function.parse-str.php PHP Manual: parse_str()]

Follow-up to [5709].

Props jrf, hellofromTonya, lucatume, SergeyBiryukov.
See #53635.

git-svn-id: https://develop.svn.wordpress.org/trunk@51624 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-16 22:16:32 +00:00
Sergey Biryukov
4d2762ed93 Tests: Rename classes in phpunit/tests/formatting/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493].

See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@51623 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-16 21:33:54 +00:00
Sergey Biryukov
18bda14e1e Code Modernization: Check the return type of parse_url() in WP::parse_request().
As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.

Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]

In this case, `parse_url()` is called with the `PHP_URL_PATH` as `$component`. This will return `null` in the majority of cases, as – exсept for subdirectory-based sites – `home_url()` returns a URL without the trailing slash, like `http://example.org`.

The return value of `parse_url()` was subsequently passed to `trim()`, leading to a `trim(): Passing null to parameter #1 ($string) of type string is deprecated` notice on PHP 8.1.

Fixed by adjusting the logic flow to:
* Only pass the return value of `parse_url()` to follow-on functions if it makes sense, i.e. if it isn't `null`, nor an empty string.
* Preventing calls to `preg_replace()` and `trim()` further down in the function logic flow, when `preg_replace()`/`trim()` would have nothing to do anyhow.

Follow-up to [25617].

Props jrf, hellofromTonya, SergeyBiryukov.
See #53635.

git-svn-id: https://develop.svn.wordpress.org/trunk@51622 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-16 20:16:13 +00:00
Sergey Biryukov
c9df4f75a2 Code Modernization: Check the return type of _get_cron_array() in wp_schedule_event().
This fixes a "Deprecated: Automatic conversion of false to array is deprecated" warning on PHP 8.1.

In `wp_schedule_event()`, the cron info array is retrieved via a call to `_get_cron_array()`, but as the documentation (correctly) states, the return type of that function is `array|false`, where `false` is returned for a virgin site, with no cron jobs scheduled yet.

However, no type check is done on the return value, and the `wp_schedule_event()` function just blindly continues by assigning a value to a subkey of the `$crons` "array".

Fixed by adding validation for the returned value from `_get_cron_array()` and initializing an empty array if `false` was returned.

Reference: [https://developer.wordpress.org/reference/functions/_get_cron_array/ WordPress Developer Resources: _get_cron_array()]

Props jrf, hellofromTonya, lucatume, pbearne, iluy, pedromendonca, SergeyBiryukov.
See #53635.

git-svn-id: https://develop.svn.wordpress.org/trunk@51619 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-16 15:22:38 +00:00
Sergey Biryukov
8905ffc319 Twenty Twenty: Add support for wa.me links in Social menu.
This ensures that `wa.me` links, currently preferred by WhatsApp, have the same icon as `whatsapp.com` links.

Follow-up to [47243], [51617].

Props sabernhardt, macmanx.
Fixes #50542.

git-svn-id: https://develop.svn.wordpress.org/trunk@51618 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-16 12:53:53 +00:00
Sergey Biryukov
a2e76e2574 Twenty Seventeen: Add support for wa.me links in Social Links menu.
This ensures that `wa.me` links, currently preferred by WhatsApp, have the same icon as `whatsapp.com` links.

Follow-up to [48027].

Props sabernhardt, carepsules, dkarfa.
Fixes #51946.

git-svn-id: https://develop.svn.wordpress.org/trunk@51617 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-16 12:49:32 +00:00
Sergey Biryukov
710f30eb96 Docs: Fix typo in the get_block_editor_settings() description.
Follow-up to [50776].

Props tmatsuur, pbearne.
Fixes #53922.

git-svn-id: https://develop.svn.wordpress.org/trunk@51611 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-15 12:44:26 +00:00
Sergey Biryukov
fadb6b076e Upgrade/Install: Use consistent capitalization for "web host" in setup messages.
Follow-up to [8887], [13163].

Props bradparbs, sabernhardt, mukesh27.
Fixes #53926.

git-svn-id: https://develop.svn.wordpress.org/trunk@51610 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-14 12:05:25 +00:00
Sergey Biryukov
d16e03f2fe Docs: Correct @since version for the wp_parse_str filter.
The filter was introduced along with the `wp_parse_str()` function in WordPress 2.2.1.

Follow-up to [5709], [8662], [26485].

See #53399.

git-svn-id: https://develop.svn.wordpress.org/trunk@51609 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-13 15:49:10 +00:00
Sergey Biryukov
74edebac97 Tests: Add unit tests for the wp_nonce_ays() function.
Update the `wp_die_handler()` method to pass the response into `WPDieException` so that `expectExceptionCode()` calls work as expected.

Follow-up to [1221/tests], [3934], [4009], [12309].

Props pbearne, jrf, mukesh27.
Fixes #53882.

git-svn-id: https://develop.svn.wordpress.org/trunk@51608 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-13 14:00:05 +00:00
Sergey Biryukov
eb6b517aec Docs: Synchronize documentation for wp_get_attachment_image_attributes filter callbacks in bundled themes:
* Twenty Sixteen: Correct the `$attachment` parameter type, use typed array notation.
* Twenty Seventeen: Correct the `$attachment` parameter type, use typed array notation.
* Twenty Nineteen: Correct the `@return` value type, use typed array notation.
* Twenty Twenty-One: Add missing `@return` value description, use typed array notation.

Follow-up to [29836], [47249], [49021], [49597].

Props ankitmaru, mukesh27, SergeyBiryukov.
Fixes #53878.

git-svn-id: https://develop.svn.wordpress.org/trunk@51607 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-12 19:29:43 +00:00
Sergey Biryukov
6406dbaca8 Tests: Use correct comparison in do_enclose() tests.
As per the PHP manual:
> If the `component` parameter is omitted, an associative array is returned.
> If the `component` parameter is specified, `parse_url()` returns a string (or an int, in the case of `PHP_URL_PORT`) instead of an array. If the requested component doesn't exist within the given URL, `null` will be returned.

Reference: [https://www.php.net/manual/en/function.parse-url.php#refsect1-function.parse-url-returnvalues PHP Manual: parse_url(): Return Values]

In this case, `parse_url()` is called with the `PHP_URL_PATH` as `$component`, but the returned value is subsequently checked against `false`.

In other words, this condition would previously always result in `true` and would lead to `null` potentially being passed to the PHP native `pathinfo()` function which expects a string.

On PHP 8.1, this would result in a test failure with a `pathinfo(): Passing null to parameter #1 ($path) of type string is deprecated` error.

Reference: [https://www.php.net/manual/en/function.pathinfo.php PHP Manual: pathinfo()]

Follow-up to [46175].

Props jrf.
See #53635.

git-svn-id: https://develop.svn.wordpress.org/trunk@51606 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-12 17:48:55 +00:00
Sergey Biryukov
2985e902d4 Build/Test Tools: Hard deprecate WP_UnitTestCase_Base::checkRequirements().
The `WP_UnitTestCase_Base::checkRequirements()` method calls the `parent::checkRequirements()` method, but this method became `private` in PHPUnit 7.0 via commit  [932238a6a3 sebastianbergmann/phpunit@932238a].

Aside from that, the `TestCase::getAnnotations()` method which is called next is now also removed in PHPUnit 9.5.

WP core does not use the method anymore, and the method only remains to prevent potentially breaking external integration tests relying on the method. However, in effect, the method is not functional anymore in PHPUnit 7.0+.

Follow-up to [893/tests], [894/tests], [896/tests], [918/tests], [30526], [40520], [40564], [43005], [44701], [51559-51577].

Props jrf.
See #46149.

git-svn-id: https://develop.svn.wordpress.org/trunk@51605 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-12 10:32:24 +00:00
Sergey Biryukov
8df58341a5 Build/Test Tools: Simplify the PHPUnit test workflow.
This removes the previously duplicated set of test runs specifically for PHP 8.1 in favor of combining `if` conditions for individual test runs with the `continue-on-error` option.

Follow-up to [51588].

Props desrosj, swissspidy, jrf.
Fixes #53891.

git-svn-id: https://develop.svn.wordpress.org/trunk@51604 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-11 15:42:06 +00:00
Sergey Biryukov
f7a7025899 Build/Test Tools: Revert [51602] for now to investigate test failures on PHPUnit < 7.0.
See #46149.

git-svn-id: https://develop.svn.wordpress.org/trunk@51603 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-11 15:01:16 +00:00
Sergey Biryukov
7a6dbf5056 Build/Test Tools: Hard deprecate WP_UnitTestCase_Base::checkRequirements().
The `WP_UnitTestCase_Base::checkRequirements()` method calls the `parent::checkRequirements()` method, but this method became `private` in PHPUnit 7.0 via commit  [932238a6a3 sebastianbergmann/phpunit@932238a].

Aside from that, the `TestCase::getAnnotations()` method which is called next is now also removed in PHPUnit 9.5.

WP core does not use the method anymore, and the method only remains to prevent potentially breaking external integration tests relying on the method. However, in effect, the method is not functional anymore in PHPUnit 7.0+.

Follow-up to [893/tests], [894/tests], [896/tests], [918/tests], [30526], [40520], [40564], [43005], [44701], [51559-51577].

Props jrf.
See #46149.

git-svn-id: https://develop.svn.wordpress.org/trunk@51602 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-11 14:30:29 +00:00
Sergey Biryukov
27098883f9 Themes: Make sure the theme API response is not an error before operating on it in themes_api().
This fixes a potential bug and avoids PHP warnings when `themes_api( 'query_themes' )` is called and a successful API response is not received.

Follow-up to [42632].

Props pierlo.
Fixes #53913.

git-svn-id: https://develop.svn.wordpress.org/trunk@51601 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-11 13:00:46 +00:00
Greg Ziółkowski
18024e62d7 Tests: Fix failing i18n unit tests for block metadata
Follow up for #53238.

Changes to the translation file weren't included in [51599].



git-svn-id: https://develop.svn.wordpress.org/trunk@51600 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-11 10:37:17 +00:00
Greg Ziółkowski
d9599addd1 Blocks: Add support for variations in block.json` file
We integrated variations with block types and the corresponding REST API endpoint in #52688. It's a follow-up patch to add missing support to the `block.json` metadata file when using `register_block_type`.

Some fields for variations are translatable.Therefore, i18n schema was copied over from Gutenberg: https://github.com/WordPress/gutenberg/blob/trunk/packages/blocks/src/api/i18n-block.json. The accompanying implementation was adapted as `translate_settings_using_i18n_schema`.

Props: gwwar, swissspidy, schlessera, jorgefilipecosta.
Fixes #53238.



git-svn-id: https://develop.svn.wordpress.org/trunk@51599 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-11 09:06:31 +00:00
Sergey Biryukov
9b565f7907 Build/Test Tools: Make the polyfills loading more flexible.
The PHPUnit Polyfills are, since [51559], a required dependency for the WP test suite and, by extension, for plugin/theme integration test suites which are based on and use (parts of) the WP core test suite.

However, plugin/theme integration test suites may not use a full WordPress installation.

This commit:
* Removes the presumption that a full WP install, including `vendor` directory, will be available when the test `bootstrap.php` file is run.
* Makes the loading of the PHPUnit Polyfills autoload file more flexible by:
  * Checking if the autoload class contained within the autoload file is already available before attempting to load the file.[[BR]]
    This allows for plugin/theme integration test suites to load the `phpunitpolyfills-autoload.php` file from any location, as long as it is loaded before the WP core test `bootstrap.php` file is run.
  * Allowing for the path to an arbitrary installation location for the PHPUnit Polyfills to be passed as a constant.[[BR]]
    As long as the provided location is a valid file path and the `phpunitpolyfills-autoload.php` file exists in the provided location, that file will be loaded.[[BR]]
    The constant can be declared in a plugin/theme integration test suite native test bootstrap file, or in the `wp-tests-config.php` file, or even in a `phpunit.xml[.dist]` file via `<php><const name="WP_TESTS_PHPUNIT_POLYFILLS_PATH" value="path/to/yoast/phpunit-polyfills"/></php>`.
* Adds a version check for the PHPUnit Polyfills to prevent a mismatch between the version of the package expected by WordPress and the version used by plugins/themes.[[BR]]
  The version this checks for should be in line with the minimum version requirement for the PHPUnit Polyfills as declared in the `composer.json` file.[[BR]]
  This version number should only be updated when new features added in later PHPUnit Polyfills releases are actually used in the WP core test suite.
* Adds appropriate error messages for every possible error condition.
* Upgrades the PHPUnit Polyfills to version 1.0.1, which now includes a version constant.

Follow-up to [51559-51577].

Props jrf, hellofromTonya, swissspidy, jeherve, thomasplevy, SergeyBiryukov.
See #46149.

git-svn-id: https://develop.svn.wordpress.org/trunk@51598 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-10 21:13:38 +00:00
Sergey Biryukov
43b55b4509 General: Restore (un-deprecate) the sanitize_url() function.
A general security rule is "Sanitize when you save, escape when you echo", and for the most part WordPress has well-named functions like `sanitize_email()` and others, with `esc_url_raw()` being a single exception that does not follow the naming.

This commit restores the previously deprecated `sanitize_url()` function as a valid alias of `esc_url_raw()`.

This better aligns with the naming with other `sanitize_*()` functions:

* `sanitize_bookmark()`
* `sanitize_bookmark_field()`
* `sanitize_category()`
* `sanitize_category_field()`
* `sanitize_comment_cookies()`
* `sanitize_email()`
* `sanitize_file_name()`
* `sanitize_hex_color()`
* `sanitize_hex_color_no_hash()`
* `sanitize_html_class()`
* `sanitize_key()`
* `sanitize_meta()`
* `sanitize_mime_type()`
* `sanitize_option()`
* `sanitize_post()`
* `sanitize_post_field()`
* `sanitize_sql_orderby()`
* `sanitize_term()`
* `sanitize_term_field()`
* `sanitize_text_field()`
* `sanitize_textarea_field()`
* `sanitize_title()`
* `sanitize_title_for_query()`
* `sanitize_title_with_dashes()`
* `sanitize_trackback_urls()`
* `sanitize_user()`
* `sanitize_user_field()`

Follow-up to [11383], [13096].

Props Ipstenu, aadilali.
Fixes #53876.

git-svn-id: https://develop.svn.wordpress.org/trunk@51597 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-10 19:43:33 +00:00
Sergey Biryukov
c550a592b9 Editor: Preserve the original template keys when preparing a list of page templates.
Previously, the original "404" template key was lost when "Default template" is merged into the available templates array, as the `array_merge()` function renumbers numeric keys. Later, when we merge templates on the client side, this caused duplicate "404" templates to appear in the dropdown.

By replacing the `array_merge()` call with `array_replace()`, we make sure to keep the original numeric keys.

Props Mamaduka, Toro_Unit, youknowriad.
Fixes #53898.

git-svn-id: https://develop.svn.wordpress.org/trunk@51595 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-10 17:55:37 +00:00
Sergey Biryukov
2af80e6cbe Code Modernization: Silence the deprecation warning for missing return type in phpunit/tests/compat.php.
This fixes the "Deprecated: Return type of `CountableFake::count()` should be compatible with `Countable::count(): int`" warning on PHP 8.1.

PHP native interfaces now have declared return types and methods in classes implementing these interfaces need to either have the return type declared (in a covariant compatible manner with the PHP native interface method declaration), or need to silence the deprecation warning using the `#[ReturnTypeWillChange]` attribute.

Follow-up to [51517], [51529], [51530], [51531], [51532].

Props jrf.
See #53635.

git-svn-id: https://develop.svn.wordpress.org/trunk@51594 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-10 17:34:30 +00:00
Sergey Biryukov
016cce0695 Docs: Improve documentation for a few functions per the documentation standards.
This affects:
* `checked()`
* `selected()`
* `disabled()`
* `wp_readonly()`
* `readonly()`
* `__checked_selected_helper()`

Follow-up to [143], [560], [9053], [10662], [13658], [41728], [51586].

See #53399.

git-svn-id: https://develop.svn.wordpress.org/trunk@51592 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-10 13:44:34 +00:00
Sergey Biryukov
88fb0bc5e0 Upgrade/Install: Update sodium_compat to v1.17.0.
The latest version of sodium_compat includes fixes for PHP 8.1 compatibility and a fix for PHP 5.6 compatibility.

A full list of changes in this update can be found on GitHub:
https://github.com/paragonie/sodium_compat/compare/v1.16.1...v1.17.0

Follow-up to [49741], [51002].

Props jrf.
Fixes #53907.

git-svn-id: https://develop.svn.wordpress.org/trunk@51591 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-10 13:03:41 +00:00
Sergey Biryukov
26302004ba Docs: Add a @see reference to the xmlrpc_enabled filter in wp_xmlrpc_server::set_is_enabled().
Follow-up to [28065].

See #53399.

git-svn-id: https://develop.svn.wordpress.org/trunk@51590 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-10 12:52:48 +00:00
Sergey Biryukov
1c76a1652d Docs: Add a @see reference to the wp_mail_content_type filter in wp_staticize_emoji_for_email().
Follow-up to [31860].

See #53399.

git-svn-id: https://develop.svn.wordpress.org/trunk@51589 602fd350-edb4-49c9-b593-d223f7449a82
2021-08-10 12:52:15 +00:00