This needs more investigation to address the test failure with persistent object cache.
Follow-up to [53506].
Props hellofromTonya.
See #55593.
git-svn-id: https://develop.svn.wordpress.org/trunk@53511 602fd350-edb4-49c9-b593-d223f7449a82
This ensures that not only the array values being compared are equal, but also that their type is the same.
Going forward, stricter type checking by using `assertSameSets()` or `assertSameSetsWithIndex()` should generally be preferred, to make the tests more reliable.
Follow-up to [48939], [51137], [51943], [53499], [53504], [53506], [53509].
See #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53510 602fd350-edb4-49c9-b593-d223f7449a82
* Give the test methods more specific names and move them closer together.
* Correct the `@covers` tags.
Follow-up to [53499], [53504], [53506], [53507], [53508].
See #55593, #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53509 602fd350-edb4-49c9-b593-d223f7449a82
* Make the function description more specific, for consistency with other similar functions.
* Add a `@since` note for the `$update_menu_item_cache` parameter of `WP_Query::parse_query()`.
* Add missing `@covers` tags for the unit tests.
Follow-up to [53504].
See #55620.
git-svn-id: https://develop.svn.wordpress.org/trunk@53508 602fd350-edb4-49c9-b593-d223f7449a82
* Make the function description more specific, for consistency with `update_post_author_caches()`.
* Add missing `@covers` tags for the unit test.
Follow-up to [53506].
See #55593.
git-svn-id: https://develop.svn.wordpress.org/trunk@53507 602fd350-edb4-49c9-b593-d223f7449a82
Prime caches for all post parents in the post REST API controller using the `_prime_post_caches` function. Post parent objects are required as part of the `check_read_permission` method’s permission check in post REST API controller.
Props spacedmonkey, furi3r, peterwilsoncc, mitogh, madpixels.
Fixes#55593.
git-svn-id: https://develop.svn.wordpress.org/trunk@53506 602fd350-edb4-49c9-b593-d223f7449a82
Add a new parameter to `WP_Query` called `update_menu_item_cache` that when set to true, primes the caches for linked terms and posts for menu item post objects. This change moves logic
found in `wp_get_nav_menu_items` into a new function called `update_menu_item_cache`. Update the menu item REST API controller, to pass the `update_menu_item_cache` parameter to the
arguments used for the `WP_Query` run to get menu items.
Props furi3r, TimothyBlynJacobs, spacedmonkey, peterwilsoncc, mitogh.
Fixes#55620.
--This line, and those below, will be ignored--
M src/wp-includes/class-wp-query.php
M src/wp-includes/nav-menu.php
M src/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php
M tests/phpunit/tests/post/nav-menu.php
git-svn-id: https://develop.svn.wordpress.org/trunk@53504 602fd350-edb4-49c9-b593-d223f7449a82
Ensure that featured image caches are primed for post collections in the post REST API controller, by calling the `update_post_thumbnail_cache` function.
Props Spacedmonkey, TimothyBlynJacobs, mitogh.
Fixes#55592.
git-svn-id: https://develop.svn.wordpress.org/trunk@53499 602fd350-edb4-49c9-b593-d223f7449a82
Avoid duplicated query when retrieving empty posts collections by adding a check if the page is more than 1.
Props furi3r, gdetassigny, TimothyBlynJacobs, spacedmonkey.
Fixes#55677.
git-svn-id: https://develop.svn.wordpress.org/trunk@53498 602fd350-edb4-49c9-b593-d223f7449a82
The test bootstrap requires GD to be available, so this test skip condition will never be matched.
Also, test skipping from within a helper method, which may be used in a data provider, can lead to test runtime errors.
Follow-up to [49009], [49014], [49535], [49571], [51415].
Props jrf.
See #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53497 602fd350-edb4-49c9-b593-d223f7449a82
Introduced [52836] when passing `child_of` or `pad_counts` parameters to `get_terms` or `WP_Term_Query` class, the array of terms received by the query, was not correctly cached. This
change simplifies the logic in `WP_Term_Query` and ensures terms are correctly cached. This change also, improves performance, by only caching an array of term ids where possible.
Props denishua, spacedmonkey, oztaser, peterwilsoncc, SergeyBiryukov, georgestephanis, jnz31, knutsp, mukesh27, costdev.
Fixes#55837.
git-svn-id: https://develop.svn.wordpress.org/trunk@53496 602fd350-edb4-49c9-b593-d223f7449a82
* Move a non-test specific helper function used by multiple tests up to the top of the class to make it more easily discoverable.
* Move a test-specific helper function used by only one test to be directly below the test using the helper function and make the link with the test explicit by adding a `@see` tag.
Follow-up to [1201/tests], [51415].
Props jrf.
See #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53495 602fd350-edb4-49c9-b593-d223f7449a82
This ensures that PHP 8.1 "passing null to non-nullable" deprecation notice is not thrown for the `$domain` parameter of `setcookie()` calls in the function.
Follow-up to [53490].
See #54914.
git-svn-id: https://develop.svn.wordpress.org/trunk@53493 602fd350-edb4-49c9-b593-d223f7449a82
This ensures that the expected results use the default permalink structure, not affected by other tests.
Follow-up to [27550], [27684], [53487].
See #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53488 602fd350-edb4-49c9-b593-d223f7449a82
In the `WP_REST_Post_Search_Handler` class, ensure that post, post meta and term caches are correctly primed when performing a search.
Props furi3r, spacedmonkey, TimothyBlynJacobs, audrasjb, peterwilsoncc.
Fixes#55674.
git-svn-id: https://develop.svn.wordpress.org/trunk@53485 602fd350-edb4-49c9-b593-d223f7449a82
* Make the descriptions for `update_post_author_caches()` and `update_post_caches()` more specific.
* Move the unit test into its own file, for consistency with `update_post_cache()` tests. This also allows for using shared fixtures in case more tests are added in the future.
Follow-up to [53482].
See #55716.
git-svn-id: https://develop.svn.wordpress.org/trunk@53483 602fd350-edb4-49c9-b593-d223f7449a82
For a call to `WP_Query` or a post REST API request that contains posts from multiple authors, call the `cache_users` function, to ensure that all user data for post authors is primed in
a single database query. This results in far fewer database queries on multiple author sites.
Props spacedmonkey, timothyblynjacobs, peterwilsoncc.
Fixes#55716.
git-svn-id: https://develop.svn.wordpress.org/trunk@53482 602fd350-edb4-49c9-b593-d223f7449a82
* Add a `@since` note for the `decoding` attribute in `wp_get_attachment_image()`.
* Adjust `wp_img_tag_add_decoding_attr()` DocBlocks per the documentation standards.
* Wrap some long `sprintf()` calls in unit tests for better readability. In at least one case, `the_content` was unnecessarily passed to `sprintf()` as an extra (unused) parameter.
Follow-up to [53480].
See #53232.
git-svn-id: https://develop.svn.wordpress.org/trunk@53481 602fd350-edb4-49c9-b593-d223f7449a82
Dynamically add `decoding="async"` to image tags on the front end of a site to instruct browsers to download them in parallel.
Modifies `wp_get_attachment_image()`, `get_avatar()` to include the attribute by default. Modifies `wp_filter_content_tags()` to add the attribute during the front-end render of the site.
Introduces `wp_img_tag_add_decoding_attr()` to take an image tag and modify it to include the attribute. Introduces the filter `wp_img_tag_add_decoding_attr` used to define the default value for the attribute.
Props adamsilverstein, ayeshrajans, costdev, flixos90, hellofromtonya, isaumya, michaelbourne, mihai2u, mitogh, sergiomdgomes, spacedmonkey, westonruter, peterwilsoncc.
Fixes#53232.
git-svn-id: https://develop.svn.wordpress.org/trunk@53480 602fd350-edb4-49c9-b593-d223f7449a82
This aims to make the tests more discoverable and easier to expand.
Follow-up to [50790], [53473], [53477].
See #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53478 602fd350-edb4-49c9-b593-d223f7449a82
This aims to clarify the intention of the tests.
Follow-up to [53473].
Props mlajo, costdev, acoulombe, azouamauriac, swissspidy, tobifjellner, peterwilsoncc, audrasjb, marekdedic, SergeyBiryukov.
See #55194.
git-svn-id: https://develop.svn.wordpress.org/trunk@53477 602fd350-edb4-49c9-b593-d223f7449a82
This changeset ensures `wp_rand()` returns zero instead of a random number when both `$min` and `$max` values are equal to zero.
Fixes#55194.
git-svn-id: https://develop.svn.wordpress.org/trunk@53473 602fd350-edb4-49c9-b593-d223f7449a82
This was unnecessarily replacing the original image metadata with a scaled version, leading to a few leftover images with the `-scaled` suffix in the `wp-content/uploads` directory.
Follow-up to [35412].
See #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53465 602fd350-edb4-49c9-b593-d223f7449a82
Convert some `wp_delete_post()` calls to `wp_delete_attachment()` to avoid an extra function call.
See #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53464 602fd350-edb4-49c9-b593-d223f7449a82
This makes sure there are no leftover images in case of a test failure.
Follow-up to [161/tests], [1255/tests].
See #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53463 602fd350-edb4-49c9-b593-d223f7449a82
This aims to improve performance by calling `sanitize_url()` directly, instead of the `esc_url_raw()` wrapper. As of WordPress 6.1, `sanitize_url()` is the recommended function for sanitizing a URL for database or redirect usage.
Follow-up to [11383], [13096], [51597], [53452].
Props benjgrolleau, peterwilsoncc, SergeyBiryukov.
Fixes#55852.
git-svn-id: https://develop.svn.wordpress.org/trunk@53455 602fd350-edb4-49c9-b593-d223f7449a82
This avoids a test failure if the `ZipArchive` class is missing.
Additionally, this commit replaces an inline check for the `ZipArchive` class in personal data export file tests with a `@requires` annotation, for consistency with similar PHP extension requirements in other tests.
Follow-up to [44786], [51415], [52286].
See #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53454 602fd350-edb4-49c9-b593-d223f7449a82
This fixes an `Equals sign not aligned correctly` WPCS warning.
Additionally, this commit sets the `svn:eol-style` property for the `phpunit/tests/ajax/wpAjaxCropImage.php` file and corrects line endings, so that the output of `composer format` is clean.
Follow-up to [53027], [53217], [53404].
Props hellofromTonya, SergeyBiryukov.
See #55647.
git-svn-id: https://develop.svn.wordpress.org/trunk@53441 602fd350-edb4-49c9-b593-d223f7449a82
MariaDB 10.2 has reached EOL in May 2022. The recommended minimum is bumped to 10.3 for now.
Follow-up to [52319], [52358], [52420], [52424], [53431], [53433], [meta11866].
Props hellofromTonya.
Fixes#55791. See #meta6322.
git-svn-id: https://develop.svn.wordpress.org/trunk@53435 602fd350-edb4-49c9-b593-d223f7449a82
Comparing human-readable dates instead of numeric timestamps gives identical results, but makes the message more clear in case of failure.
Follow-up to [33946], [52418], [52421], [52424].
See #55791, #55652.
git-svn-id: https://develop.svn.wordpress.org/trunk@53433 602fd350-edb4-49c9-b593-d223f7449a82
TEMPORARY COMMIT.
MariaDB version 10.2 is no longer supported as of 23 May 2022. This commit temporarily skips the version test. Why? To avoid test failures during this period, i.e. until the version is bummped and `readme.html` file changed.
See #55791, [https://meta.trac.wordpress.org/ticket/5999 Meta5999].
git-svn-id: https://develop.svn.wordpress.org/trunk@53431 602fd350-edb4-49c9-b593-d223f7449a82
The odd / even class attribute global variables are causing issues in comments tests when a new test is added or an existing test is modified. To stabilize the odd / even comment tests, the comment global variables are added to the base test class' `tear_down()` using the same patterns as the other global resets. This change ensures each comment test starts at the same state. In doing so, the expected odd / even class attributes are no longer affected by previous tests, i.e. test leaks.
Follow-up to [53172].
Props hellofromTonya, zieladam, peterwilsoncc.
See #54725.
git-svn-id: https://develop.svn.wordpress.org/trunk@53430 602fd350-edb4-49c9-b593-d223f7449a82
This avoids a PHP fatal error if any of these functions are called too early:
* `have_posts()`
* `in_the_loop()`
* `rewind_posts()`
* `the_post()`
* `have_comments()`
* `the_comment()`
bringing some consistency with conditional tags: `is_single()`, `is_home()`, etc.
This commit also removes unnecessary `return` from `the_comment()`, for consistency with `the_post()`. As `WP_Query::the_comment()` does not have a return value, this statement did not have any effect in practice.
Follow-up to [4934], [8807], [16947], [17068], [17083], [49147], [53395], [53396], [53400].
Props vdankbaar, thijso, teunvgisteren, timkersten655, SergeyBiryukov.
Fixes#55722.
git-svn-id: https://develop.svn.wordpress.org/trunk@53429 602fd350-edb4-49c9-b593-d223f7449a82
`phpversion()` return value and `PHP_VERSION` constant value are identical, but the latter is several times faster because it is a direct constant value lookup compared to a function call.
Props ayeshrajans, jrf, mukesh27, costdev, hellofromTonya, SergeyBiryukov.
Fixes#55680.
git-svn-id: https://develop.svn.wordpress.org/trunk@53426 602fd350-edb4-49c9-b593-d223f7449a82
Updates theme validation to accept block themes. This replaces the requirement for an `index.php` with a requirement for either an `index.php`, `/templates/index.html` or the deprecated `/block-templates/index.html`.
Validation is updated for theme uploads, within `WP_Theme::__construct` and `validate_current_theme()`.
A block theme using the deprecated file structure is now included in the unit tests.
Props peterwilsoncc, sergeybiryukov, hellofromtonya, costdev, azaozz, gziolo, FlorianBrinkmann, Boniu91, aristath, poena, audrasjb.
Fixes#55754.
git-svn-id: https://develop.svn.wordpress.org/trunk@53416 602fd350-edb4-49c9-b593-d223f7449a82
This avoids an `Undefined array key 0` PHP warning for `current_user_can()` capability checks that require a specific object to check against but an object ID was not passed.
A `_doing_it_wrong()` notice is also added, so that developers and site administrators are aware that the capability mapping is failing in the absence of the required object ID.
The list of mapped capabilities that require an object ID:
* `delete_post` / `delete_page`
* `edit_post` / `edit_page`
* `read_post` / `read_page`
* `publish_post`
* `edit_(post|comment|term|user)_meta` / `delete_*_meta` / `add_*_meta`
* `edit_comment`
* `edit_term` / `delete_term` / `assign_term`
Follow-up to [34091], [34113], [47178].
Props jeherve, peterwilsoncc, henry.wright, johnbillion, mattheweppelsheimer, hellofromTonya, JeffPaul, azouamauriac, Ninos Ego, TobiasBg, wpsmith, GaryJ, nacin, johnstonphilip, azaozz, SergeyBiryukov.
Fixes#44591.
git-svn-id: https://develop.svn.wordpress.org/trunk@53408 602fd350-edb4-49c9-b593-d223f7449a82
When called too early, conditional query tags should throw a `_doing_it_wrong()` notice and return `false`. This commit verifies that behavior not only for `is_main_query()`, but for all the other conditional tags too.
Follow-up to [16947], [17068], [17083], [18699], [37985], [53395].
See #55104.
git-svn-id: https://develop.svn.wordpress.org/trunk@53396 602fd350-edb4-49c9-b593-d223f7449a82
This avoids a PHP fatal error and triggers a `_doing_it_wrong()` notice if `is_main_query()` is called too early, bringing consistency with all the other `is_*()` conditionals: `is_single()`, `is_home()`, etc.
Follow-up to [16947], [17068], [17083], [18699], [37985].
Props vdankbaar, nhadsall, johnbillion, costdev, thijsoo, teunvgisteren, timkersten655, SergeyBiryukov.
Fixes#55104.
git-svn-id: https://develop.svn.wordpress.org/trunk@53395 602fd350-edb4-49c9-b593-d223f7449a82
Backport of the remaining Comment Template block tests from Gutenberg:
* `assertEquals()` replaced with `assertSameSetsWithIndex()`.
* assertion's argument order changed to ensure expected and then actual.
Follow-up to [53353], [53298], [53172], [53138].
Props bernhard-reiter.
Fixes#55708.
git-svn-id: https://develop.svn.wordpress.org/trunk@53388 602fd350-edb4-49c9-b593-d223f7449a82