5120 Commits

Author SHA1 Message Date
Tonya Mork
008277583b Themes: Adds outline CSS properties support in theme.json.
Adds the ability to define outline CSS properties for elements and blocks within `theme.json` to render `outline-color`, `outline-offset`, `outline-style`, and `outline-width` styles.

Originally developed and tested in [https://github.com/WordPress/gutenberg/pull/43526 Gutenberg PR 43526].

Props onemaggie, hellofromTonya, audrasjb, ironprogrammer.
Fixes #57354.

git-svn-id: https://develop.svn.wordpress.org/trunk@55008 602fd350-edb4-49c9-b593-d223f7449a82
2022-12-19 20:53:15 +00:00
Tonya Mork
429829d6d9 HTTP API: Adds BC-layer /library/Requests.php file.
When the Requests 2.0.0 [7ef0774f0b/src/Autoload.php (L141-L143) autoloader detects the older (deprecated) `Requests` class], it attempts to load [https://github.com/WordPress/Requests/blob/v2.0.0/library/Requests.php its `/library/Requests.php` file]. Prior to this commit, this file did not exist in Core. Thus, a fatal error happened.

Why not change Requests Autoloader?
Requests is an external dependency that Core consumes. It is also used by other projects outside of Core. Thus, Core needs a fix to guard itself to prevent a fatal error.

The fix:
* Adds the missing `wp-includes/Requests/library/Requests.php` file, which then loads the `wp-includes/class-requests.php` (which will throw a deprecation notice to alert developers to upgrade).
* Adds a test.

Follow-up to [54997].

Props bjorsch, costdev, jrf, mukesh27, peterwilsoncc, ironprogrammer, hellofromTonya.
Fixes #57341.

git-svn-id: https://develop.svn.wordpress.org/trunk@55007 602fd350-edb4-49c9-b593-d223f7449a82
2022-12-19 15:10:20 +00:00
Sergey Biryukov
dd9fa21839 Tests: Correct a flaky wp_nonce_field() test.
The test for `wp_nonce_field()` with a custom action name verifies that the nonce value matches the one returned by `wp_create_nonce()` with the same action name.

The created nonce, in turn, depends on `wp_nonce_tick()`, which returns a different result in the first and the second half of the nonce's lifespan, one day by default:
* 00:00:01 to 12:00:00 — First tick
* 12:00:01 to 00:00:00 — Second tick

In practice, due to a delay between initializing data providers and running the actual tests, it is possible for the nonce tick to change in the process, for example if the test suite run starts at 11:59:30, and the affected test runs at 12:00:30, causing a test failure.

This commit reduces the chance of a race condition by moving the `wp_create_nonce()` call from the data provider into the test itself.

Includes wrapping long lines with the expected results for better readability.

Follow-up to [54420].

Props NekoJonez, SergeyBiryukov.
See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@55006 602fd350-edb4-49c9-b593-d223f7449a82
2022-12-19 14:43:02 +00:00
Peter Wilson
e27c5a38e3 Menus: Account for legacy calls to nav_menu_css_class filter.
Modify `wp_nav_menu_remove_menu_item_has_children_class()` to account for changes to the `nav_menu_css_class` filter since it's introduction.

The `$args` and `$depth` parameters were added after the filter's introduction so this protects against fatal errors in custom walkers applying the filter in a legacy format.

Without the `$args` or `$depth` parameters, `wp_nav_menu_remove_menu_item_has_children_class()` no longer attempts to remove the `menu-item-has-children` from the lowest level menu items as these are required to determine the current branch the walker is walking.

Follow up to [54999].

Props dd32, azaozz, peterwilsoncc.
See #56926, #28620.


git-svn-id: https://develop.svn.wordpress.org/trunk@55005 602fd350-edb4-49c9-b593-d223f7449a82
2022-12-18 23:59:51 +00:00
Tonya Mork
d7dd42d72f External Libraries: Update Requests library to version 2.0.0.
This is a major release and contains breaking changes.

Most important changes to be aware of for this release:
* All code is now namespaced. Though there is a full backward compatibility layer available and the old class names are still supported, using them will generate a deprecation notice (which can be silenced by plugins if they'd need to support multiple WP versions). See the [https://requests.ryanmccue.info/docs/upgrading.html upgrade guide] for more details.
* A lot of classes have been marked `final`. This should generally not affect userland code as care has been taken to not apply the `final` keyword to classes which are known to be extended in userland code.
* Extensive input validation has been added to Requests. When Requests is used as documented though, this will be unnoticable.
* A new `WpOrg\Requests\Requests::has_capabilities()` method has been introduced which can be used to address #37708.
* A new `WpOrg\Requests\Response::decode_body()` method has been introduced which may be usable to simplify some of the WP native wrapper code.
* Remaining PHP 8.0 compatibility fixed (support for named parameters).
* PHP 8.1 compatibility.

Release notes: https://github.com/WordPress/Requests/releases/tag/v2.0.0

For a full list of changes in this update, see the Requests GitHub:
https://github.com/WordPress/Requests/compare/v1.8.1...v2.0.0

This commit also resolves 2 blocking issues which previously caused the revert of [52244]:

* New Requests files are loaded into `wp-includes/Requests/src/`, matching the location of the library. In doing so, filesystems that are case-insensitive are not impacted (see #54582).
* Preload: During a Core update, the old Requests files are preloaded into memory before the update deletes the files. Preloading avoids fatal errors noted in #54562. 

Follow-up to [50842], [51078], [52244], [52315], [52327], [52328].

Props jrf, schlessera, datagutten, wojsmol, dustinrue, soulseekah, szepeviktor. costdev, sergeybiryukov, peterwilsoncc, ironprogrammer, antonvlasenko, hellofromTonya, swissspidy, dd32, azaozz, TobiasBg, audrasjb.
Fixes #54504.
See #54582, #54562.

git-svn-id: https://develop.svn.wordpress.org/trunk@54997 602fd350-edb4-49c9-b593-d223f7449a82
2022-12-15 21:30:26 +00:00
Peter Wilson
4b4faae6cf Built/Test tools, HTTP API: Refactor test for multiple location headers.
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.
Fixes #57306.
See #56793.



git-svn-id: https://develop.svn.wordpress.org/trunk@54968 602fd350-edb4-49c9-b593-d223f7449a82
2022-12-14 01:26:39 +00:00
Sergey Biryukov
1b42990b0c Tests: Temporarily disable a WP_Http test for multiple Location headers.
The test verifies that `WP_Http::handle_redirects()` uses the last specified URL as the redirect location if multiple `Location` headers are specified in the response.

It appears that the redirection script on api.wordpress.org no longer sends the expected two `Location` headers, causing the test to fail.

While the exact cause is being investigated and confirmed, this commit disables the affected test for now, so that other commits and PRs are not blocked by these failures.

Follow-up to [342/tests], [874/tests], [1329/tests], [24846].

Props costdev, SergeyBiryukov.
See #57306.

git-svn-id: https://develop.svn.wordpress.org/trunk@54955 602fd350-edb4-49c9-b593-d223f7449a82
2022-12-10 13:31:55 +00:00
Sergey Biryukov
cb99ef08f0 Code Modernization: Rename parameters that use reserved keywords in wp-includes/pluggable.php.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit:
* Renames the `$die` parameter to `$stop` in `check_ajax_referer()`.
* Renames the `$default` parameter to `$fallback_url` in `wp_validate_redirect()`.
* Renames the `$default` parameter to `$default_value` in `get_avatar()`.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.

git-svn-id: https://develop.svn.wordpress.org/trunk@54952 602fd350-edb4-49c9-b593-d223f7449a82
2022-12-09 00:22:14 +00:00
Sergey Biryukov
0e9c555840 Tests: Use more descriptive name for a wp_new_comment() test.
Includes:
* Correcting the order of expected and actual values.
* Adding a missing `@covers` tag for another test next to it.

Follow-up to [32299], [53863], [54489].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54949 602fd350-edb4-49c9-b593-d223f7449a82
2022-12-08 15:07:45 +00:00
Jonny Harris
ab0feb8b44 Tests: Change the wp_cache_get_multiple function to get cache keys in a single request.
Follow up from [54423].

Change the `wp_cache_get_multiple` function to call the `getMulti` method in the object cache object, to get cache keys in a single call to memcache. This speeds up test by loading caches faster. 

Props spacedmonkey, SergeyBiryukov.
See #54864.

git-svn-id: https://develop.svn.wordpress.org/trunk@54942 602fd350-edb4-49c9-b593-d223f7449a82
2022-12-06 19:59:45 +00:00
spacedmonkey
08dfd2b550 Users: Clear the user_meta cache when clean_user_cache function is called.
Unlike other clean cache functions like `clean_post_cache`, `clean_user_cache` did not also clear user meta caches. This is inconsistent and can result in some strange side effects. Update the `clean_user_cache` function to also clear user meta caches when called. 

Props dd32, spacedmonkey, peterwilsoncc.
Fixes #54316.

git-svn-id: https://develop.svn.wordpress.org/trunk@54940 602fd350-edb4-49c9-b593-d223f7449a82
2022-12-06 13:52:02 +00:00
Sergey Biryukov
999b52eb75 Coding Standards: Fix a non-snake_case function name in WP_Block tests.
As the filter is only intended for a single test, it can be converted to a closure instead of being declared as a function in the global namespace. The `remove_filter()` part is redundant, as `WP_UnitTestCase_Base` saves the state of filter-related globals at `set_up()` and restores them on `tear_down()`.

Follow-up to [54175].

Props jrf, SergeyBiryukov.
See #56791.

git-svn-id: https://develop.svn.wordpress.org/trunk@54917 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-30 18:30:57 +00:00
Sergey Biryukov
75aaa65770 Coding Standards: Fix indentation of multi-line chained method call in test_json_error_with_status().
Follow-up to [34928], [42228].

Props jrf.
See #56791.

git-svn-id: https://develop.svn.wordpress.org/trunk@54915 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-30 16:33:48 +00:00
Bernie Reiter
112d16165f Build/Test Tools: Stylistic changes to Gutenberg e2e test.
Make some stylistic changes (multiline comment formatting, test description) that had been suggested during code review and that didn't make it into the previous commit.

Props costdev.
Follows [54913].
See #57197.

git-svn-id: https://develop.svn.wordpress.org/trunk@54914 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-30 14:05:58 +00:00
Bernie Reiter
bb2f8a6d4f Build/Test Tools: Add basic e2e coverage for Gutenberg.
Add some minimal e2e test coverage to install and activate the Gutenberg plugin.

This will catch naming collisions between Core and Gutenberg and help avoid crashing WordPress installations that run the stable version of the Gutenberg plugin on top of Core trunk.

Props costdev.
Fixes #57197.

git-svn-id: https://develop.svn.wordpress.org/trunk@54913 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-30 13:16:00 +00:00
Sergey Biryukov
8e44ab05a6 Coding Standards: Fix spacing for incrementors and decrementors in various files.
Note: This will be enforced by WPCS 3.0.0.

Props jrf.
See #56791.

git-svn-id: https://develop.svn.wordpress.org/trunk@54896 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-29 21:11:42 +00:00
Dominik Schilling
35421f2b07 Query: Account for primed post caches without primed post meta/term caches.
In [54352] `update_post_caches()` was replaced by `_prime_post_caches()` to reduce excessive object cache calls. That's because `_prime_post_caches()` checks first if post IDs aren't already cached. Unfortunately this becomes an issue if a post itself is cached but not the meta/terms.
To fix this regression, `_prime_post_caches()` now always calls `update_postmeta_cache()` and `update_object_term_cache()` depending on the arguments passed to it. Both functions internally check whether IDs are already cached so the fix from [54352] remains in place.

Props peterwilsoncc, spacedmonkey, ocean90.
Fixes #57163.

git-svn-id: https://develop.svn.wordpress.org/trunk@54894 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-29 20:27:29 +00:00
Sergey Biryukov
e50c65caf4 Coding Standards: Always use parentheses when instantiating an object.
Note: This will be enforced by WPCS 3.0.0.

Props jrf.
See #56791.

git-svn-id: https://develop.svn.wordpress.org/trunk@54891 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-29 15:49:49 +00:00
Sergey Biryukov
6821cb07ef Coding Standards: Add visibility to properties in tests/phpunit/tests/.
Adds a `private` visibility to some test class properties where it was not explicitly specified. This continues the previous efforts to make sure visibility is declared on all properties. 

Note: This will be enforced by WPCS 3.0.0.

Follow-up to [49184], [51919], [52009], [52010], [54889].

Props jrf.
See #56791.

git-svn-id: https://develop.svn.wordpress.org/trunk@54890 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-29 12:40:08 +00:00
Sergey Biryukov
8f86cdb2e0 Coding Standards: Add visibility to methods in tests/phpunit/tests/.
Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods. This continues the previous efforts to make sure visibility is declared on all methods. 

Note: This will be enforced by WPCS 3.0.0.

Follow-up to [51919], [52009], [52010].

Props jrf.
See #56791.

git-svn-id: https://develop.svn.wordpress.org/trunk@54889 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-29 12:32:37 +00:00
Sergey Biryukov
5cb17e222d Comments: Make moderated or disallowed key check case-insensitive for non-Latin words.
The `check_comment()` and `wp_check_comment_disallowed_list()` functions are expected to be case-insensitive, but that only worked for words using Latin script and consisting of ASCII characters.

This commit adds the Unicode flag to the regular expression used for the check in these functions, so that both pattern and subject can be treated as UTF-8 strings.

Reference: [https://www.php.net/manual/en/reference.pcre.pattern.modifiers.php PHP Manual: Pattern Modifiers].

Follow-up to [984], [2075], [48121], [48575].

Props bonjour52, SergeyBiryukov.
Fixes #57207.

git-svn-id: https://develop.svn.wordpress.org/trunk@54888 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-28 19:42:56 +00:00
Jb Audras
d19f5f0170 Coding Standards: Remove extra slashes when concatenating ABSPATH with a path.
Since `ABSPATH` is defined and documented to end with a forward slash `/`, this changeset removes the first `/` from strings appended to `ABSPATH` in various files, leading to `//` in the resulting path.

Props TobiasBg, audrasjb, SergeyBiryukov, emanuelx.
Fixes #57074.
See #57071.


git-svn-id: https://develop.svn.wordpress.org/trunk@54872 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-24 22:09:39 +00:00
Sergey Biryukov
e385beb747 Tests: Correct references to set_up() and tear_down() in various DocBlocks.
The `setUp()` and `tearDown()` methods were renamed to `set_up()` and `tear_down()`, respectively, as part of implementing the `void` return type solution for PHPUnit 8.0.

Follow-up to [29120], [29251], [30277], [32173], [32806], [38829], [42379], [50450], [51276], [51568].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54865 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-22 21:25:27 +00:00
Sergey Biryukov
95d11878b0 Tests: Clean up test file in wpmu_delete_blog() tests.
This makes sure there are no leftover files after the tests from the `multisite` directory are run separately.

Follow-up to [30404].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54864 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-22 20:17:08 +00:00
Sergey Biryukov
ea651b1fc1 Tests: Add unit tests for attachment’s file size being included in metadata.
These tests ensure that `wp_generate_attachment_metadata()` stores the file size of all newly uploaded attachments under the `filesize` array key. The tests were initially supposed to be committed with [52837].

Follow-up to [52837], [52932], [54861].

Props spacedmonkey, johnwatkins0, mitogh, adamsilverstein, pbearne, SergeyBiryukov.
Fixes #57171.

git-svn-id: https://develop.svn.wordpress.org/trunk@54863 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-22 19:43:25 +00:00
Sergey Biryukov
9ed27339b1 Tests: Add a public visibility to wp_filesize() tests.
Follow-up to [52010], [52837], [52932], [54861].

See #57171.

git-svn-id: https://develop.svn.wordpress.org/trunk@54862 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-22 15:09:33 +00:00
Sergey Biryukov
e507aee79f Tests: Move wp_filesize() tests to their own file.
This aims to make the tests more discoverable and easier to expand.

Includes splitting the `wp_filesize` and `pre_wp_filesize` filter tests into a separate test case.

Follow-up to [52837], [52932], [54402].

Props pbearne, spacedmonkey, SergeyBiryukov.
See #57171.

git-svn-id: https://develop.svn.wordpress.org/trunk@54861 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-22 15:02:26 +00:00
Sergey Biryukov
239a6c33ec Site Editor: Show correct theme per template or template part.
Child themes inherit templates and template parts from the parent theme. In Site Editor, the "Added by" column for a template defaults to displaying the child theme, even though it is inherited from the parent, creating confusion as to where the actual templates are located.

This commit ensures that the parent theme is correctly displayed in that scenario.

Follow-up to [51003], [52062].

Props ptahdunbar, WoutPitje, petaryoast, costdev, poena, audrasjb, SergeyBiryukov.
Fixes #55437.

git-svn-id: https://develop.svn.wordpress.org/trunk@54860 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-21 16:48:33 +00:00
Sergey Biryukov
acbbee8a11 Docs: Update various DocBlocks and inline comments per the documentation standards.
Includes minor formatting edits for consistency.

Follow-up to [53/tests], [12179], [12946], [35288], [37884], [38810], [38928], [46596], [48131], [52955], [53548], [53813], [53873], [54118], [54316], [54420], [54421], [54803].

See #56792.

git-svn-id: https://develop.svn.wordpress.org/trunk@54855 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-17 18:13:47 +00:00
Sergey Biryukov
55cddb2ac9 Tests: Resolve WP_Query test failures on MariaDB due to indeterminate sort order.
[54768] added a few tests to verify that caching within `WP_Query` is bypassed when the `SELECT` clause has been modified via a filter, to avoid cache key collisions and the returning of incomplete or unexpected results.

However, creating several posts with the same date/time fields can result in inconsistent sort ordering between MySQL and MariaDB, as each engine refines the order further using a different index.

This commit aims to stabilize the tests by using `assertEqualSets()` instead of `assertEquals()`, since testing the order is out of their scope. Includes removing `array_unshift()` and `array_reverse()` calls as no longer needed.

This resolves a few test failures on MariaDB along the lines of:
{{{
Tests_Query_FieldsClause::test_should_limit_fields_to_id_and_parent_subset
Posts property for first query is not of expected form.
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
     0 => stdClass Object (
-        'ID' => 36019
+        'ID' => 36015
         'post_parent' => 0
     )
     1 => stdClass Object (
-        'ID' => 36018
+        'ID' => 36016
         'post_parent' => 0
     )
     2 => stdClass Object (...)
     3 => stdClass Object (
-        'ID' => 36016
+        'ID' => 36018
         'post_parent' => 0
     )
     4 => stdClass Object (
-        'ID' => 36015
+        'ID' => 36019
         'post_parent' => 0
     )
 )

/tmp/wp-test-runner/tests/phpunit/tests/query/fieldsClause.php:67
/tmp/wp-test-runner/phpunit-5.7.phar:598
}}}

Follow-up to [54768].

Props peterwilsoncc, SergeyBiryukov.
See #57012.

git-svn-id: https://develop.svn.wordpress.org/trunk@54829 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-12 14:49:25 +00:00
Jonathan Desrosiers
49949cea2c Editor: Improve how min/max font sizes are calculated for fluid typography.
- Where no fluid max values are set (e.g., single or custom font size values), the "size" value will act as the maximum value in a `clamp()` function.
- In the absence of any fluid `min`/`max` values, the lower bound rule of `>16px` will be enforced. This applies to custom values from the editor or single-value `theme.json` styles. Font sizes below this will not be clamped.
- In a preset, if a `fluid.min` value has been specified, the lower bound rule of `>16px` won't be enforced on this value. Presets with a fluid object therefore, give precedence to theme author's values.
- In a preset, if there is NOT a `fluid.max` but there is `fluid.min`, use the incoming "size" value as the `max`.
- In a preset, if there is NOT a `fluid.min` but there is a `fluid.max`, use `size * min_size_factor` as the `min`. The lower bound rule of `>16px` is enforced here, because the block editor is computing the `min` value. This is consistent with the way minimum sizes are calculated for single or custom values.


Props ramonopoly, mamaduka, andrewserong, aristath, joen, desrosj.
Fixes #57075.

git-svn-id: https://develop.svn.wordpress.org/trunk@54823 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-11 17:46:05 +00:00
Jonathan Desrosiers
368587707d Editor: Correctly style separator blocks when only a background-color is defined.
When separator blocks are configured using only a `background-color`, they are shown correctly within the editor but not on the front end.

This changes `WP_Theme_JSON` to detect this scenario and move the `background-color` value to just `color` when both `color` and `border-color` are missing.

Props cbravobernal, flixos90, davidbaumwald, hellofromTonya, desrosj, andrewserong, czapla, glendaviesnz, wildworks.
Fixes #56903.

git-svn-id: https://develop.svn.wordpress.org/trunk@54821 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-11 17:09:11 +00:00
Felix Arntz
23a646a25a Editor: Improve performance of WP_Theme_JSON class by reducing usage of expensive array functions.
In many scenarios array functions are more expensive than using simpler `for` or `foreach` loops.

This changeset results in roughly 4% faster `wp_head` execution time for both block themes and classic themes. While this may seem like a small win, it is a worthwhile enhancement and only one part of several other little performance tweaks which are being worked on to improve performance of `theme.json` parsing further.

Props aristath, desrosj, jrf, spacedmonkey.
Fixes #56974.
See #57067.


git-svn-id: https://develop.svn.wordpress.org/trunk@54804 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-11 01:48:05 +00:00
Peter Wilson
51032426b5 Media: Prevent decoding attribute corrupting JSON data.
Workaround `wp_img_tag_add_decoding_attr()` potentially breaking JavaScript and JSON data by limiting the addition of the decoding attribute to image tags using unescaped double quoted attributes `src` attributes.

Props rodricus, TimothyBlynJacobs, joelmadigan, mw108, adamsilverstein, flixos90, desrosj, mukesh27.
Fixes #56969.


git-svn-id: https://develop.svn.wordpress.org/trunk@54802 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-11 00:59:20 +00:00
Peter Wilson
ac84f67ee4 Menus: Apply menu-item-has-children class in sub-menus.
Ensure the `menu-item-has-children` class is added to sub-menu items when `wp_nav_menu()` is called with the `depth` parameter specified to a non-zero value.

Follow up to [54478].

Props davidvongries, fpodhorsky, hellofromTonya, innovext, larsmqller, LeonidasMilossis, mattkeys, mukesh27, nuvoPoint, ocean90, outrankjames, petitphp, SergeyBiryukov, sippis, webmandesign.
Fixes #56946.
See #28620.


git-svn-id: https://develop.svn.wordpress.org/trunk@54801 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-11 00:04:58 +00:00
Felix Arntz
8368eef8e0 Editor: Avoid running certain logic around theme.json parsing unnecessarily for classic themes.
Here's what it does:
* Do not load and parse `theme-i18n.json` schema if the theme does not have a `theme.json` file.
* Fix the variable caching layer around the theme's `theme.json` parsing so that a parent's theme `theme.json` is cached as well.
* Do not run a `WP_Query` for global styles for a user when the theme does not have a `theme.json`.

In a basic WordPress setup, this changeset improves `wp_head` execution time for classic themes by 10%, and overall response time for both block themes and classic themes by 4%. This may seem like a small win, but 4% reduced overall response time is actually quite a bit for one change, and it is worth mentioning that this is just one of several other little performance tweaks which are being worked on to improve performance of `theme.json` parsing further.

Props flixos90, manuilov, oandregal, peterwilsoncc, spacedmonkey.
Fixes #56945.


git-svn-id: https://develop.svn.wordpress.org/trunk@54799 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-10 22:14:53 +00:00
Sergey Biryukov
302ba4f45f Tests: Correct the test for get_blogaddress_by_id() with a non-existing ID.
Due to auto-increment, when running various test groups or classes separately, in this case running all of the tests under `phpunit/tests/multisite/` by including the `--filter Tests_Multisite` parameter, it is entirely possible for the blog ID 42 to actually exist, making the test's assumption incorrect.

By using `PHP_INT_MAX` instead, we can avoid a collision with a fixture of another test.

Follow-up to [31157].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54791 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-10 13:05:57 +00:00
Peter Wilson
b9304148f1 Canonical: Protect against error for term not exists queries.
Prevent term `NOT EXISTS` queries causing `redirect_canonical()` to throw a fatal error in PHP 8 and above, or a warning in earlier versions.

This ensures the `tax_query`'s `terms` property both exists and is countable before attempting to count it.

Props codesdnc, SergeyBiryukov, kadamwhite, costdev, miguelaxcar.
Fixes #55955.



git-svn-id: https://develop.svn.wordpress.org/trunk@54785 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-10 02:59:56 +00:00
Peter Wilson
19d5bd0787 Posts, Post Types: Revert get_page_by_title()'s use of WP_Query.
Revert to legacy database query in `get_pages_by_title()`. Due to the lack of `orderby` clause in the previous database query, it is not possible to gain consistent results by converting the function to a `WP_Query` wrapper.

Reverts [54271, 54242, 54234].

Props Bjorn2404, 10upsimon, dilipbheda, mukesh27, spacedmonkey, TimothyBlynJacobs, rjasdfiii, stentibbing, pbiron, pento.
Fixes #57039, #56991.
See #57041.



git-svn-id: https://develop.svn.wordpress.org/trunk@54782 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-10 00:44:10 +00:00
peterwilsoncc
4edede48eb Query: Prevent ID only queries erroring when starting the loop.
Ensure only full post objects are passed to `update_post_author_caches()` when called within `WP_Query::the_post()`. This prevents an error when starting the Loop for Queries initiated with a subset of fields or IDs only.

Props konyoldeath, dd32, lozula, TimothyBlynJacobs, spacedmonkey, mxbclang, peterwilsoncc.
Fixes #56948.



git-svn-id: https://develop.svn.wordpress.org/trunk@54771 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-09 00:57:02 +00:00
Felix Arntz
b8bf29746a Editor: Improve frontend performance for get_default_block_editor_settings().
The `wp_max_upload_size()` function can be expensive to call, especially for large sites or multisites. For the frontend usage of `get_default_block_editor_settings()` knowing the allowed upload size is typically unnecessary.

This changeset adds a condition so that `wp_max_upload_size()` is only called if the current user can actually `upload_files`. It keeps the data present when it is actually needed while avoiding the execution overhead when it is not needed.

Props janthiel, Clorith, flixos90, spacedmonkey.
Fixes #56815.


git-svn-id: https://develop.svn.wordpress.org/trunk@54769 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-09 00:28:33 +00:00
Peter Wilson
fba9680eda Query: Bypass caching for filtered SELECTs.
Bypass caching within `WP_Query` when the `SELECT` clause has been modified via a filter. This prevents both cache key collisions and the returning of incomplete or unexpected results when the `SELECT` clause has been modified by an extender.

Props pypwalters, claytoncollie, johnwatkins0, TimothyBlynJacobs, costdev, spacedmonkey, peterwilsoncc.
Fixes #57012.



git-svn-id: https://develop.svn.wordpress.org/trunk@54768 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-09 00:26:41 +00:00
Sergey Biryukov
be4f63f00f Tests: Restore blog switching in update_posts_count() test.
The previous iteration of the test passed when run in isolation but failed when running the whole test suite.

Restoring the `switch_to_blog()` call allows the test to pass again pending a deeper investigation.

Follow-up to [54760].

See #57023.

git-svn-id: https://develop.svn.wordpress.org/trunk@54762 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-07 20:53:18 +00:00
Sergey Biryukov
ad31a2e424 Tests: Combine duplicate update_posts_count() tests.
This combines the newer test for `update_posts_count()` located in its own file with the pre-existing one from `tests/multisite/site.php`, which was essentially testing the same thing in a similar way.

Includes:
* Renaming the test class per the [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization naming conventions].
* Adjusting comments per the documentation standards.
* Updating `@covers` tags for accuracy.
* Removing unnecessary blog switching.
* Using `assertSame()` to check the value type.

Follow-up to [28835], [29667], [52207].

See #57023, #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54760 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-07 17:45:29 +00:00
Sergey Biryukov
711dbb7993 Tests: Move update_blog_status() tests to their own file.
Reduce some of the clutter in `tests/multisite/site.php` and introduce `tests/multisite/updateBlogStatus.php`. Tests moved over are verbatim at this point.

Follow-up to [1078/tests], [29916], [30784], [30785], [33253].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54757 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-06 16:19:15 +00:00
Sergey Biryukov
399bc757fc Tests: Remove a custom callback for checking action call count in multisite tests.
Use `MockAction::get_call_count()` instead, for consistency with the rest of the test suite.

Follow-up to [24/tests], [99/tests], [1078/tests], [1089/tests], [29916], [30784], [30785], [33253].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54756 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-06 15:54:34 +00:00
Sergey Biryukov
c87a1d6e2e Docs: Update comments in wp_nav_menu() tests per the documentation standards.
Includes:
* Fixing a few typos.
* Using the correct format for multi-line comments.
* Removing some comments that duplicate the assertion messages without providing any additional context.

Follow-up to [54478].

See #56792.

git-svn-id: https://develop.svn.wordpress.org/trunk@54741 602fd350-edb4-49c9-b593-d223f7449a82
2022-11-01 20:15:25 +00:00
Tonya Mork
7e2a0a9572 Database: Revert [53575].
When using `'%%%s%%'` pattern with `$wpdb->prepare()`, it works on 6.0.3 but does not on 6.1-RC. Why? The inserted value is wrapped in quotes on 6.1-RC5 whereas it is not on <= 6.0.3.

With 6.1 final release tomorrow, more time is needed to further investigate and test. Reverting this changeset to restore the previous behavior.

This commit also adds a dataset for testing the `'%%%s%%'` pattern.

Props SergeyBiryukov, hellofromTonya, bernhard-reiter, desrosj, davidbaumwald, jorbin.

Fixes #56933.
See #52506.

git-svn-id: https://develop.svn.wordpress.org/trunk@54733 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-31 20:38:20 +00:00
Sergey Biryukov
18f244c440 Tests: Move some @covers tags in the formatting group to the class DocBlock.
This aims to bring more consistency, as these test classes typically cover a single function, unless noted otherwise.

Follow-up to [53562], [53571], [54051].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54728 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-31 13:54:00 +00:00
Sergey Biryukov
8fd6b038ac Docs: Update a link to the Custom Elements spec in unsupported_valid_tag_names() unit test docblock.
This changeset replaces a link to the outdated W3C specs on Custom Elements with a link to the corresponding WhatWG specification.

Previously committed in [53205], this appears to be accidentally reverted in [53562].

Follow-up to [53204], [53205], [53562].

Props audrasjb.
See #56792.

git-svn-id: https://develop.svn.wordpress.org/trunk@54727 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-31 13:22:22 +00:00