4042 Commits

Author SHA1 Message Date
Felix Arntz
e78d988aa2 Security, Site Health: Detect HTTPS support and encourage switching.
This changeset modifies the Site Health panel for HTTPS to provide more accurate recommendations based on whether the environment is already set up for HTTPS.

* Introduces `wp_is_using_https()` to check whether the site is configured to use HTTPS (via its Site Address and WordPress Address).
* Introduces `wp_is_https_supported()` to check whether the environment supports HTTPS. This relies on a cron job which periodically checks support using a loopback request.

Props Clorith, flixos90, miinasikk, westonruter.
Fixes #47577.


git-svn-id: https://develop.svn.wordpress.org/trunk@49904 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-23 19:11:20 +00:00
Sergey Biryukov
d2c8fae049 Tests: Correct @ticket references in tests/query/invalidQueries.php.
This ensures that running `phpunit --group 48556` works as expected.

Follow-up to [49900].

See #48556.

git-svn-id: https://develop.svn.wordpress.org/trunk@49902 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-23 15:04:54 +00:00
Peter Wilson
6da93c4588 Query: Add bad path tests with invalid WP_Query parameters.
See #48556.


git-svn-id: https://develop.svn.wordpress.org/trunk@49900 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-23 03:03:56 +00:00
Peter Wilson
254131d009 Query: Revert post-type specific capability changes.
The modified checks of the `read_private_posts` capability could result in unexpected SQL queries when calling `WP_Query` with invalid parameters.

Reverts [49830], [49832] and [49833].
See #48556.


git-svn-id: https://develop.svn.wordpress.org/trunk@49899 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-23 03:01:00 +00:00
Sergey Biryukov
96555f949a Tests: Use shared post fixture in comment template tests.
This reinstates [49848], previously reverted in [49849], with the addition of `static` keyword for the `wpSetUpBeforeClass()` method, allowing the tests to pass on PHP 8.

Props peterwilsoncc.
See #51802.

git-svn-id: https://develop.svn.wordpress.org/trunk@49863 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-22 07:42:23 +00:00
John Blackbourn
7ef5a65f44 XML-RPC: Emit an appropriate HTTP status code when an error is returned in response to an XML-RPC request.
This most notably affects the response when XML-RPC is disabled or when the supplied username and password is incorrect.

Props ericmann

Fixes #48213


git-svn-id: https://develop.svn.wordpress.org/trunk@49862 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 20:21:12 +00:00
John Blackbourn
3202790820 Build/Test Tools: Don't mark the Tests_Cache::test_flush() test as risky when running the test suite with an object cache in place.
See #51802


git-svn-id: https://develop.svn.wordpress.org/trunk@49857 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 17:49:20 +00:00
John Blackbourn
51f9a54c9d XML-RPC: Fix a type error when requesting the menu field of a taxonomy.
Fixes #51493


git-svn-id: https://develop.svn.wordpress.org/trunk@49856 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 17:09:50 +00:00
Greg Ziółkowski
3d43e57237 Blocks: Align with Gutenberg the name of generated asset handle for core blocks
Related Gutenberg PR: https://github.com/WordPress/gutenberg/pull/25220.

It aligns with the latest changes added by aristath to the Gutenberg project. As part of styles splitting for core blocks, there was a special pattern introduced for how style handles are named. Ideally, we would apply it to all blocks but there might be some backward compatibility considerations so I left the handling for non-core blocks unchanged.

Props aristath.
See #50328.



git-svn-id: https://develop.svn.wordpress.org/trunk@49850 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 11:37:30 +00:00
Peter Wilson
91a6444e50 Tests: Revert use of shared post fixture in comment template tests.
Removes code throwing a fatal in PHP 8.

Reverts [49848] from trunk.
See #51802.


git-svn-id: https://develop.svn.wordpress.org/trunk@49849 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 03:33:48 +00:00
Peter Wilson
9fa63c38ef Tests: Use shared post fixture in comment template tests.
See #51802.


git-svn-id: https://develop.svn.wordpress.org/trunk@49848 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 03:15:59 +00:00
Peter Wilson
c88cbe35e8 Query: Correct some coding standards after [49843].
See #44183


git-svn-id: https://develop.svn.wordpress.org/trunk@49847 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 02:54:43 +00:00
John Blackbourn
f141418a5f Query: Correct some coding standards after [49843].
See #44183

git-svn-id: https://develop.svn.wordpress.org/trunk@49846 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-21 00:31:54 +00:00
John Blackbourn
99cfb00d13 Mail: Introduce a pre_wp_mail filter to allow short-circuiting the wp_mail() function without having to override the pluggable function.
Props DvanKooten, swissspidy, SergeyBiryukov, jtsternberg, ericlewis, Mte90, birgire, ayeshrajans

Fixes #35069


git-svn-id: https://develop.svn.wordpress.org/trunk@49844 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-20 15:07:23 +00:00
John Blackbourn
b04671e52f Query: Ensure the author archive title always shows the name of the queried author, regardless of whether there are results.
This brings the behaviour inline with the `<title>` element of the page which always shows the author name.

Props Tkama, subrataemfluence

Fixes #44183


git-svn-id: https://develop.svn.wordpress.org/trunk@49843 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-20 14:35:58 +00:00
Jonathan Desrosiers
3723941a9c Build/Test Tools: Run the Ajax test group for multisite.
This will help catch issues with Ajax related functionality on multisite.

A few tests have also been marked as `skipWithMultisite()` as they require network admin level capabilities when performing the same operations on a multisite install.

Props garrett-eclipse, netweb.
Fixes #46567.

git-svn-id: https://develop.svn.wordpress.org/trunk@49835 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-18 14:38:28 +00:00
Peter Wilson
c0f76faef8 Coding Standards: Minor fixes following [49830].
Fixes the fixes missed in [49832]. They are fixed now.

See #13509, #48968, #48556.


git-svn-id: https://develop.svn.wordpress.org/trunk@49833 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-18 00:26:21 +00:00
Boone Gorges
f7ced48ad8 Query: Respect post-type specific capabilities when querying for multiple post types.
After this change, the relevant `read_private_posts` capability is checked for
each queried post type. This ensures that private posts appear in search and
archive queries for users who have the ability to view those posts.

Props leogermani.

Fixes #13509, #48968, #48556.

git-svn-id: https://develop.svn.wordpress.org/trunk@49830 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-17 16:15:38 +00:00
Felix Arntz
8505c99a1b Media: Enable lazy-loading of iframes by adding the loading="lazy" attribute to iframe tags on the front-end.
* Expands the capabilities of `wp_filter_content_tags()` to add the attribute to iframe tags if enabled.
* Modifies the default behavior of `wp_lazy_loading_enabled()` so that it returns `true` for `iframe` tags.
* Introduces a `wp_iframe_tag_add_loading_attr()` function.
* Introduces a `wp_iframe_tag_add_loading_attr` filter.

Like for images, the attribute is only added to iframes which have both `width` and `height` specified (see related #50367).

Props azaozz, flixos90, westonruter.
Fixes #50756.


git-svn-id: https://develop.svn.wordpress.org/trunk@49808 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-16 21:17:24 +00:00
Ian Dunn
4595dcf7f9 Feed: Merge multiple header values to avoid fatal error.
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.
Fixes #51056. See #51956.



git-svn-id: https://develop.svn.wordpress.org/trunk@49803 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-16 00:49:32 +00:00
Jonathan Desrosiers
707d5df176 Build/Test Tools: Allow code coverage reports to be generated when running tests as a multisite.
This adds the information needed to generate a code coverage report to the multisite ruleset.

Fixes #52034.

git-svn-id: https://develop.svn.wordpress.org/trunk@49797 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-12 20:07:55 +00:00
Jonathan Desrosiers
f2c287aaee Build/Test Tools: Remove PHPUnit 3.6.x specific settings from the multisite configuration.
In PHPUnit 3.6.x, `exclude` and `file` paths were required to be relative to the checkout root. This changed in PHPUnit 4 when the path requirements were changed require them to be relative to the configuration file.

Since PHPUnit 3.6.x is only used to test on PHP 5.2 in older branches and is no longer supported, these can be safely removed from the configuration file.

See #51802.

git-svn-id: https://develop.svn.wordpress.org/trunk@49796 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-12 18:06:45 +00:00
John Blackbourn
81b89682c3 Docs: Various docblock corrections.
See #51800


git-svn-id: https://develop.svn.wordpress.org/trunk@49789 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-10 23:51:52 +00:00
Peter Wilson
a6e1d392f2 Docs, Tests: Correctly capitalize JavaScript.
Correct Javascript to JavaScript within Wordpress core ;)

See #51800, #51802.



git-svn-id: https://develop.svn.wordpress.org/trunk@49758 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-06 02:19:56 +00:00
Sergey Biryukov
85bc0628b4 Tests: Correct @ticket references in some test files.
See #51802.

git-svn-id: https://develop.svn.wordpress.org/trunk@49757 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-05 15:49:25 +00:00
Timothy Jacobs
38361be8e6 App Passwords: Prevent conflicts when Basic Auth is already used by the site.
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.
Fixes #51939.



git-svn-id: https://develop.svn.wordpress.org/trunk@49752 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-04 21:42:52 +00:00
Ian Dunn
8724f546c9 Media: Return WP_Error when cropping with bad input to avoid fatal.
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.
Fixes #51937.


git-svn-id: https://develop.svn.wordpress.org/trunk@49751 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-04 21:39:30 +00:00
Ian Dunn
cac678f807 Multisite: Cache absolute dirsize paths to avoid PHP 8 fatal.
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.
Fixes #51913. See #19879.



git-svn-id: https://develop.svn.wordpress.org/trunk@49744 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-03 20:37:43 +00:00
John Blackbourn
f1e610531a REST API: Pass the previous state of the post as a parameter to the wp_after_insert_post hook.
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.

Props Collizo4sky, peterwilsoncc, hellofromTonya, TimothyBlynJacobs, SergeyBiryukov

Fixes #45114


git-svn-id: https://develop.svn.wordpress.org/trunk@49731 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-01 20:45:43 +00:00
Timothy Jacobs
901909bf2c Site Health, App Passwords: Ensure REST API responses are properly translated.
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.
Fixes #51871.


git-svn-id: https://develop.svn.wordpress.org/trunk@49716 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-01 03:42:31 +00:00
Sergey Biryukov
1c2aada05b Tests: Test that sanitize_title_with_dashes() strips HTML tags.
`sanitize_title()` already has the same test in its own file.

Props pbearne.
Fixes #51881.

git-svn-id: https://develop.svn.wordpress.org/trunk@49701 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-27 12:50:11 +00:00
Peter Wilson
0addc4ac04 Build/Test Tools: Use dataProviders for some kses tests.
Refactor several kses tests to use dataProviers rather than looping through assertions.

See #51802.


git-svn-id: https://develop.svn.wordpress.org/trunk@49697 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-25 04:49:04 +00:00
Peter Wilson
95751aeec2 Build/Test Tools: Remove unused posts from AJAX test setUp().
Removes the creation of five posts from the AJAX test suite `setUp()` function, replacing it with a shared fixture only where required.

See #51802.


git-svn-id: https://develop.svn.wordpress.org/trunk@49696 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-25 04:09:41 +00:00
Robert Anderson
a86bedfc92 Editor: Remove render_block hooks from WP_Block
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/trunk@49695 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-25 01:18:25 +00:00
Sergey Biryukov
c869ef617e Tests: Ignore EOL differences in WP_List_Table::get_bulk_items() test for optgroups.
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].

See #19278.

git-svn-id: https://develop.svn.wordpress.org/trunk@49691 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-24 20:41:13 +00:00
Sergey Biryukov
1a338a859b I18N: Avoid PHP notices for relative URLs in load_script_textdomain().
Props hellofromTonya, SeBsZ, archon810, nourma, justinahinon, SergeyBiryukov.
Fixes #49145.

git-svn-id: https://develop.svn.wordpress.org/trunk@49639 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-17 20:50:21 +00:00
Sergey Biryukov
22e4cb5266 Docs: Further remove tautology from comments in recurse_dirsize() tests.
Follow-up to [49212], [49616], [49628].

See #19879.

git-svn-id: https://develop.svn.wordpress.org/trunk@49630 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-17 15:48:07 +00:00
Sergey Biryukov
205c025c63 Multisite: Rename the calculate_current_dirsize filter to pre_recurse_dirsize.
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
2020-11-17 15:42:57 +00:00
Sergey Biryukov
025ad3469b Docs: Adjust comments for recurse_dirsize() and related tests per the documentation standards.
Follow-up to [49212], [49616].

See #19879.

git-svn-id: https://develop.svn.wordpress.org/trunk@49628 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-17 15:36:02 +00:00
Robert Anderson
ac71fffac0 Customize: Ensure multiple CSS classes are passed to nav_menu_link_attributes as an array
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
2020-11-17 04:29:02 +00:00
Peter Wilson
64ad8eb332 Permalinks: Prevent attachment pages 404ing following [49563].
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
2020-11-17 03:27:07 +00:00
Timothy Jacobs
ba8de96fc6 App Passwords: Unify availability language.
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
2020-11-16 22:40:11 +00:00
Helen Hou-Sandi
56ffe940b0 Multisite: More consistency for clean_dirsize_cache().
Props SergeyBiryukov.
Fixes #19879.


git-svn-id: https://develop.svn.wordpress.org/trunk@49616 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-16 22:29:42 +00:00
Robert Anderson
7a42314c8b Editor: Move pre_render_block, render_block_data, render_block_context
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
2020-11-16 00:45:55 +00:00
John Blackbourn
82e44bc702 Build/Test Tools: Misc test enhancements.
See #51344


git-svn-id: https://develop.svn.wordpress.org/trunk@49606 602fd350-edb4-49c9-b593-d223f7449a82
2020-11-15 17:17:55 +00:00
John Blackbourn
cd9ed5e3ad Built/Test Tools: Switch to a data provider for the default user role and capability tests.
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
2020-11-15 14:57:39 +00:00
John Blackbourn
ea852af151 Build/Test Tools: Ensure user capability assertions are performed for all default roles.
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
2020-11-15 14:17:31 +00:00
John Blackbourn
e8435082d6 Build/Test Tools: Standardise the name, signature, and usage of the wpSetUpBeforeClass() method that's used in test classes.
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
2020-11-15 13:59:32 +00:00
John Blackbourn
5f257b4931 Build/Test Tools: Improve the reliability of the test that ensures correct dependency order when inline scripts are used.
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
2020-11-14 17:20:57 +00:00
Sergey Biryukov
9befeb00cc Build/Test Tools: Only enforce PHP extension requirements when running core tests.
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
2020-11-12 17:23:44 +00:00