Due to some changes on the WP.com side to compress the requested images on the fly, the exact image size in the response could be different between platforms.
This commit aims to make the affected tests more reliable.
Follow-up to [139/tests], [31258], [34568], [47142], [57903], [57904], [57924].
Merges [57931] to the 5.6 branch.
Props peterwilsoncc, jorbin.
See #60865.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@57995 602fd350-edb4-49c9-b593-d223f7449a82
Remove wordpress.org as an external dependency testing `WP_HTTP::handle_redirects()`.
This refactors and reenables an existing test to call the `WP_HTTP::handle_redirects()` method directly with a mocked array of HTTP headers containing multiple location headers.
The test is moved from the external-http group to the http test group as it no longer makes an HTTP request.
Follow up to [54955].
Props SergeyBiryukov, dd32, peterwilsoncc.
Merges [54968] to the 5.6 branch.
Fixes#57306.
See #56793.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@54979 602fd350-edb4-49c9-b593-d223f7449a82
The `Europe/Kiev` timezone has been deprecated in PHP 8.2 and replaced with `Europe/Kyiv`.
The tests updated in this commit are testing the WordPress date/time functionality. They are **not** testing whether WP or PHP can handle deprecated timezone names correctly.
To ensure the tests follow the original purpose, the use of `Europe/Kiev` within these tests is now replaced with the `Europe/Helsinki` timezone, which is within the same timezone as `Europe/Kyiv`. This should ensure that these tests run without issue and test what they are supposed to be testing on every supported PHP version (unless at some point in the future `Europe/Helsinki` would be renamed, but that's a bridge to cross if and when).
Note: Separate tests should/will be added to ensure that relevant date/time related functions handle a deprecated timezone correctly, but that is not something ''these'' tests are supposed to be testing.
Follow-up to [45853], [45856], [45876], [45882], [45887], [45908], [45914], [46577], [46154], [46580], [46864], [46974], [54207].
Props jrf, costdev, SergeyBiryukov.
Merges [54217] to the 5.6 branch.
See #56468.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@54516 602fd350-edb4-49c9-b593-d223f7449a82
In [51840], the test wrapper methods were not being called due to the names not being recognized as supported PHPUnit "hook" names for fixtures.
This commit:
- Fixes the problem by adding extra camelCase wrappers to the `WP_UnitTestCase` to call the methods in the right order.
- Adds wrappers for the `assertPreConditions()` and `assertPostConditions()` fixture methods to make the backport feature complete for the fixture wrappers.
Test wrapper methods call fix:
By adding method overloads for the PHPUnit native camelCase fixture methods and letting those call the (camelCase) parent method first and only calling the snake_case fixture methods after, the snake_case methods can be supported and the typical run order safeguarded.
As not all test classes will have declared snake_case fixture methods, the snake_case fixture methods are also declared in the `WP_UnitTestCase`. Why? This prevents having to wrap these method calls in `method_exists()` conditions checking for the existence of the snake_case methods in an unknown Test child class. And with the normal inheritance rules in combination with calling the method using `static`, the right method will be called anyway without fatal "calling undeclared method" errors.
Note: While it will be rare, there ''may'' be cases where a test class does not adhere to the normal execution order for fixtures, i.e. for the setup methods, parent first, own code second; and for the teardown methods, own code first, parent second. For example a test class which has "some code - `parent::setUp()` call - some more code" in their `setUp()` method. In those (rare) cases, the execution order of the code will now be changed, which may have side-effects. This rare case will be identified in the dev note.
Follow-up to [51840].
Props bjorsch, swissspidy, jrf, hellofromTonya.
See #53911.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@51863 602fd350-edb4-49c9-b593-d223f7449a82
This backports the PHPUnit Polyfills package and related test infrastructure changes to make it easier for developers to continue testing on multiple versions WordPress while adding tests for newer versions of PHP, which require more modern PHPUnit practices.
One of the changes included is the addition of wrappers for the new snake_case fixture methods in PHPUnit. This allows the native camelCase standard in PHPUnit to be used, but allows for developers to transition to the new naming conventions.
Props hellofromTonya, jrf, SergeyBiryukov, johnbillion, netweb, schlessera, jeherve, lucatume, desrosj.
Merges [51559,51560,51810-51813,51828] to the 5.6 branch.
See #53911.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@51840 602fd350-edb4-49c9-b593-d223f7449a82
* REST API: Allow authors to read their own password protected posts.
* About page update.
Merges [50717] to the 5.6 branch.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@50726 602fd350-edb4-49c9-b593-d223f7449a82
This backports several build and test tool improvements to the 5.6 branch. Most notably, this includes:
- The changes required to allow each workflow to be triggered by the `workflow_dispatch` event so that tests can be run on a schedule [50590].
- The ability to run PHPUnit tests from `src` instead of `build` [50441-50443].
- Splitting single site and multisite tests into parallel jobs [50379].
- Split slow tests into separate, parallel jobs for PHP 5.6 [50444].
- Better branch and path scoping for GitHub Action workflows when running on `pull_request` [50432,50479].
- Several `devDependency` updates.
Merges [50267,50299,50379,50387,50413,50416,50432,50435-50436,50441-50444,50446,50473-50474,50476,50479,50485-50487,50545,50579,50590,50592,50598] to the 5.6 branch.
See #50401, #51734, #51801, #51802, #52548, #52608, #52612, #52623, #52624, #52625, #52645, #52653, #52658, #52660, #52667, #52786.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@50602 602fd350-edb4-49c9-b593-d223f7449a82
This removes a test assertion defending against version ranges in the `node` value in `package.json` files. This is now supported.
Props peterwilsoncc.
Merges [50192] to the 5.6 branch.
See #52341.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@50193 602fd350-edb4-49c9-b593-d223f7449a82
This brings consistency between single site and multisite in REST API plugin installation tests.
Previously, multisite tests were unnecessarily downloading the plugin from WordPress.org on each test run, causing external HTTP requests and leading to failures in case of a timeout.
Follow-up to [48242], [49491], [49913].
Merges [49951] to the 5.6 branch.
See #51669.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@50085 602fd350-edb4-49c9-b593-d223f7449a82
This prevents external HTTP requests that are not required for the tests in question and may interfere with the results in case of a timeout.
Follow-up to [48242], [49491].
Merges [49913] to the 5.6 branch.
See #51669.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@50083 602fd350-edb4-49c9-b593-d223f7449a82
Previously, all taxonomies were incorrectly exposed as possible values.
This commit brings the changes from [49922] to the 5.6 branch.
Props johnbillion, TimothyBlynJacobs.
Fixes#51940.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@50047 602fd350-edb4-49c9-b593-d223f7449a82
Previously, only the username was checked which caused a PHP warning in some server setups, for instance Shibboleth SSO, where the server only populates the PHP_AUTH_USER field.
This brings the changes from [49919] to the 5.6 branch.
Props MadtownLems, johnbillion, richard.tape, engahmeds3ed, TimothyBlynJacobs.
Fixes#52003.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@50045 602fd350-edb4-49c9-b593-d223f7449a82
By moving from .html to .php files, we can prevent directory listings, and ensure that WordPress can load.
This brings the changes from [50037] to the 5.6 branch.
Fixes#52299.
Props lucasbustamante, xkon, freewebmentor, SergeyBiryukov, whyisjake.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@50038 602fd350-edb4-49c9-b593-d223f7449a82
When SimplePie parses HTTP headers, it combines multiple values for the same header into a comma-separated string. `WP_SimplePie_File` overrides the parsing, but was leaving them as an array instead.
That lead to a fatal error in PHP 8, because other parts of the codebase ended up passing an array to a function that expected a string.
Props david.binda, litemotiv, inc2734, NicolasKulka, hellofromTonya, mbabker, skithund, SergeyBiryukov, desrosj, timothyblynjacobs.
Reviewed by SergeyBiryukov, iandunn.
Merges [49803] and [49805] to the 5.6 branch.
Fixes#51056. See #51956.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@49806 602fd350-edb4-49c9-b593-d223f7449a82
Application Passwords uses Basic Authentication to transfer authentication details. If the site is already using Basic Auth, for instance to implement a private staging environment, then the REST API will treat this as an authentication attempt and would end up generating an error for any REST API request.
Now, Application Password authentication will only be attempted if Application Passwords is in use by a site. This is flagged by setting an option whenever an Application Password is created. An upgrade routine is added to set this option if any App Passwords already exist.
Lastly, creating an Application Password will be prevented if the site appears to already be using Basic Authentication.
Props chexwarrior, georgestephanis, adamsilverstein, helen, Clorith, marybaum, TimothyBlynJacobs.
Reviewed by TimothyBlynJacobs, helen.
Merges [49752] to the 5.6 branch.
Fixes#51939.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@49754 602fd350-edb4-49c9-b593-d223f7449a82
This avoids an error on PHP 8 caused by calling `wp_imagecreatetruecolor()` with inputs that aren't numeric, or are less than 0.
Props hellofromtonya, Boniu91, metalandcoffee, SergeyBiryukov.
Reviewed by SergeyBiryukov, iandunn.
Merges [49751] to the 5.6 branch.
Fixes#51937.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@49753 602fd350-edb4-49c9-b593-d223f7449a82
r49212 greatly improved the performance of `get_dirsize()`, but also changed the structure of the data stored in the `dirsize_cache` transient. It stored relative paths instead of absolute ones, and also removed the unnecessary `size` array.
That difference in data structures led to a fatal error in the following environment:
* PHP 8
* Multisite
* A custom `WP_CONTENT_DIR` which is not a child of WP's `ABSPATH` folder (e.g., [https://roots.io/bedrock/ Bedrock])
* The `upload_space_check_disabled` option set to `0`
After upgrading to WP 5.6, the `dirsize_cache` transient still had data in the old format. When `wp-admin.php/index.php` was visited, `get_space_used()` received an `array` instead of an `int`, and tried to divide it by another `int`. PHP 7 would silently cast the arguments to match data types, but [https://wiki.php.net/rfc/arithmetic_operator_type_checks PHP 8 throws a fatal error]:
`Uncaught TypeError: Unsupported operand types: array / int`
`recurse_dirsize()` was using `ABSPATH` to convert the absolute paths to relative ones, but some upload locations are not located under `ABSPATH`. In those cases, `$directory` and `$cache_path` were identical, and that triggered the early return of the old `array`, instead of the expected `int`.
In order to avoid that, this commit restores the absolute paths, but without the `size` array. It also adds a type check when returning cached values. Using absolute paths without `size` has the result of overwriting the old data, so that it matches the new format. The type check and upgrade routine are additional safety measures.
Props peterwilsoncc, janthiel, helen, hellofromtonya, francina, pbiron.
Reviewed by SergeyBiryukov, iandunn.
Merges [49744] to the 5.6 branch.
Fixes#51913. See #19879.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@49745 602fd350-edb4-49c9-b593-d223f7449a82
This enables, for example, the previous post status to be used by this hook without the need to first capture it on an earlier hook.
This also fixes the value of the `$fire_after_hooks` parameter in `get_default_post_to_edit()` so the `wp_after_insert_post` action correctly fires just once on the new post screen.
This merges [45114] into the 5.6 branch
See #45114
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@49732 602fd350-edb4-49c9-b593-d223f7449a82
This avoids a misleading failure due to Unix vs. Windows EOL style mismatches and allows the test to pass on Windows.
Follow-up to [46612], [49190].
Reviewed by desrosj, SergeyBiryukov.
Merges [49691] to the 5.6 branch.
Fixes#19278.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@49730 602fd350-edb4-49c9-b593-d223f7449a82
The REST API requests in Site Health and App Passwords now include `_locale=user` in the request URL to ensure the user's locale is used instead of the site locale. Additionally, the `apiRequest` library now sends a JSON `Accept` header which is required by `determine_locale()` to respect the `_locale` query parameter.
The Site Health REST API controllers now manually load the default admin textdomain if not `is_admin()`. This allows for the Site Health tests to be translated even though the translations are part of the administration project and the REST API is not.
Props oglekler, kebbet, Clorith, TimothyBlynJacobs, ocean90, SergeyBiryukov, adamsilverstein.
Reviewed by TimothyBlynJacobs, SergeyBiryukov.
Merges [49716] to the 5.6 branch.
Fixes#51871.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@49724 602fd350-edb4-49c9-b593-d223f7449a82
Reverts the move of pre_render_block, render_block_data, and
render_block_context to WP_Block.
This change has more implications than first thought so will be revisted later
in 5.7.
Reverts [49609,49608].
See #51612.
git-svn-id: https://develop.svn.wordpress.org/branches/5.6@49694 602fd350-edb4-49c9-b593-d223f7449a82
Set the default value to `false`. This brings some consistency with the `pre_get_space_used` filter.
Follow-up to [49212], [49616], [49628].
See #19879.
git-svn-id: https://develop.svn.wordpress.org/trunk@49629 602fd350-edb4-49c9-b593-d223f7449a82
When multiple CSS classes are added to a menu item, the nav_menu_link_attributes
filter should be called with $item->classes set to an array of CSS class names.
When previewing in the Customizer, however, a single string was being passed to
$item->classes because WP_Customize_Nav_Menu_Item_Setting::preview() bypasses
wp_update_nav_menu_item() and instead uses filter_wp_get_nav_menu_items().
The fix is to make filter_wp_get_nav_menu_items() match what
wp_update_nav_menu_item() does and split the string into an array.
Fixes#43113.
Props dlh.
git-svn-id: https://develop.svn.wordpress.org/trunk@49624 602fd350-edb4-49c9-b593-d223f7449a82
This largely reverts [49563] due to attachment pages returning 404: File not found errors when they use the `inherit` status.
Permalink changes to attachment pages are retained when they are descendants of trashed or deleted posts.
Props Toro_Unit, helen, johnbillion, peterwilsoncc.
Fixes#51776.
See #5272.
git-svn-id: https://develop.svn.wordpress.org/trunk@49622 602fd350-edb4-49c9-b593-d223f7449a82
Previously App Passwords used a mix of "enabled" and "available". We've now standardized on using "available".
Additionally, we now use a 501 status code when indicating that App Passwords is not available.
Props SergeyBiryukov, ocean90, TimothyBlynJacobs.
Fixes#51513.
git-svn-id: https://develop.svn.wordpress.org/trunk@49617 602fd350-edb4-49c9-b593-d223f7449a82
Move the pre_render_block, render_block_data, and render_block_context
filters from render_block() to WP_Block. This ensures that they are
called for all blocks, including nested blocks, not just top-level
blocks.
Fixes#51612.
Props gaambo, gziolo, TimothyBlynJacobs.
git-svn-id: https://develop.svn.wordpress.org/trunk@49608 602fd350-edb4-49c9-b593-d223f7449a82
This test previously performed 1,010 assertions, and a failure in any one would prevent the other assertions from running. Using a data provider means simultaneous failures will all be reported at once.
See #51344, #32394
git-svn-id: https://develop.svn.wordpress.org/trunk@49605 602fd350-edb4-49c9-b593-d223f7449a82
The existing assertions were erroneously placed outside the iteration of all users, and therefore were only run against the last user in the list, which is the Subscriber role.
See #51344, #32394
git-svn-id: https://develop.svn.wordpress.org/trunk@49604 602fd350-edb4-49c9-b593-d223f7449a82
This brings consistency to this often-used method, and allows IDEs to provide help to developers when using its `$factory` parameter.
See #51344
git-svn-id: https://develop.svn.wordpress.org/trunk@49603 602fd350-edb4-49c9-b593-d223f7449a82
This test already ensures `WP_Scripts->do_concat` is true, therefore it has no dependency on `SCRIPT_DEBUG` being false. This means the test can run in an environment where the `.min` suffix is not used.
This change allows for the test to pass in this situation.
See #36392, #51734, #51344
git-svn-id: https://develop.svn.wordpress.org/trunk@49601 602fd350-edb4-49c9-b593-d223f7449a82
This allows other users of the WordPress unit test suite framework to run their own unit tests without needing the GD extension, which should only be a requirement if running core tests.
Follow-up to [49535].
Props jamescollins.
Fixes#50640.
git-svn-id: https://develop.svn.wordpress.org/trunk@49571 602fd350-edb4-49c9-b593-d223f7449a82
Add check to `redirect_canonical()` to ensure the destination post is not using a private post status.
Props dd32, Denis-de-Bernardy, donmhico, helen, nacin, peterwilsoncc, pishmishy, TimothyBlynJacobs, tzafrir, Viper007Bond, whyisjake.
Fixes#5272.
git-svn-id: https://develop.svn.wordpress.org/trunk@49563 602fd350-edb4-49c9-b593-d223f7449a82
This ensures that not only the return values match the expected results, but also that their type is the same.
Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.
Follow-up to [48937], [48939], [48940], [48944].
See #38266.
git-svn-id: https://develop.svn.wordpress.org/trunk@49547 602fd350-edb4-49c9-b593-d223f7449a82
* The array of network data returned from the `networks_pre_query` filter is assigned to the `networks` property of the current `WP_Network_Query` instance.
* The array of site data returned from the `sites_pre_query` filter is assigned to the `sites` property of the current `WP_Site_Query` instance.
This avoids the performance overhead of calling `WP_Network_Query::get_networks()` or `WP_Site_Query::get_sites()` twice: first when creating the object instance, then to retrieve the filtered results.
This also makes the filters a bit more consistent with other similar filters, e.g. `posts_pre_query`, `terms_pre_query`, `comments_pre_query`, or `users_pre_query`.
Follow-up to [46086], [48990].
Props yakimun, spacedmonkey.
Fixes#51333.
git-svn-id: https://develop.svn.wordpress.org/trunk@49538 602fd350-edb4-49c9-b593-d223f7449a82
Add the GD extension as a hard requirement.
This improves the reliability of the test suite and ensures that if the test infrastructure changes in the future and a platform requirement such as GD accidentally gets removed, the tests fail with an appropriate error message.
Follow-up to [48592].
Props ayeshrajans, jrf, johnbillion.
Fixes#50640.
git-svn-id: https://develop.svn.wordpress.org/trunk@49535 602fd350-edb4-49c9-b593-d223f7449a82