5045 Commits

Author SHA1 Message Date
Sergey Biryukov
2652d2eb25 Tests: Add a test case for safecss_filter_attr() with object-position property.
Follow-up to [50634].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54667 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-22 12:55:56 +00:00
SergeyBiryukov
92084e6f69 Tests: Move padding-* test data in KSES tests into its own test case.
This creates separate test cases for `safecss_filter_attr()` with `margin-*` and `padding-*` logical properties for additional clarity.

Follow-up to [54102].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54666 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-22 12:24:01 +00:00
Jb Audras
3adb24ff8c Docs: Align spelling with American English.
This changeset replaces "behaviour" with "behavior" in various docblocks.

Props kebbet, jrf.
See #56811, #56792.


git-svn-id: https://develop.svn.wordpress.org/trunk@54663 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-21 21:10:29 +00:00
Sergey Biryukov
755d5baff3 Editor: Add font size constraints for fluid typography.
This commit:
* Adds default minimum font size limits so that min font size, where provided, does not become smaller than `14px`/`0.875rem`/`0.875em`.
* For font sizes of `< 14px` that have no defined minimum sizes, uses the font size to set the floor of the `clamp()` value.

This bugfix prevents converting existing small font sizes to clamp values that will reduce their font size even further in narrow widths. It therefore improves backward compatibility and accessibility.

Original PR from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/44993 #44993 Fluid typography: add font size constraints]

Follow-up to [54260], [54360], [54497], [54500].

Props ramonopoly, andrewserong, isabel_brison, Joen, bernhard-reiter.
See #56467.

git-svn-id: https://develop.svn.wordpress.org/trunk@54646 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-19 12:25:21 +00:00
David Baumwald
96a158b138 Networks and Sites: Revert the use of the metadata API for *_network_options functions.
[54080] refactored the logic in `get_network_option()`, `update_network_option()` and `delete_network_option()` to use the metadata API. However, this change resulted in issues with large multisite installs that utilize memcached having network options > 1MB in size.

This change reverts [54080] and all related follow-up changes.

Reverts [54080], [54081], and [54082].  Partially reverts [54267] and [54402].

Props pavelschoffer, rebasaurus, johnbillion, spacedmonkey, desrosj, rinatkhaziev.
Fixes #56845.
See #37181.

git-svn-id: https://develop.svn.wordpress.org/trunk@54637 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-18 18:14:01 +00:00
Sergey Biryukov
3977b6b06d Bootstrap/Load: Correct sending the X-Pingback header in WP::send_headers().
The logic for sending the `X-Pingback` header for single posts that allow pings was recently moved from `WP::handle_404()`​ to a more appropriate place in `WP::send_headers()`.

To check whether pings are open for a particular post, that logic relies on the `$wp_query` global, which is declared in `WP::handle_404()`, but not in `WP::send_headers()`

This commit ensures that `$wp_query` is globalized in `WP::send_headers()` too, so that the check works as expected.

Follow-up to [54250].

Props strategio, sabernhardt, dlh, davidbaumwald, SergeyBiryukov.
Fixes #56840.

git-svn-id: https://develop.svn.wordpress.org/trunk@54636 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-18 16:09:50 +00:00
Jonny Harris
7b176e6dea Query: Remove placeholder from query cache key.
Remove escape placeholder from query cache key, as placeholders are a based on a unique id on every request. This means that it is impossible for a cache to be reused, making queries that use escape placeholders such as `LIKE` searches, unable to be cached.  

Props dhl, spacedmonkey, peterwilsoncc, desrosj, chaion07, davidbaumwald, mukesh27.
Fixes #56802.

git-svn-id: https://develop.svn.wordpress.org/trunk@54634 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-18 15:06:48 +00:00
Sergey Biryukov
5d537503df Tests: Correct the wp_theme_json_data_default filter name in assertion messages.
The `theme_json_default` filter was previously renamed to `wp_theme_json_data_default`.

This commit updates the messages in `WP_Theme_JSON_Resolver` tests to match the new name.

Follow-up to [54501], [54630].

See #56796, #56835.

git-svn-id: https://develop.svn.wordpress.org/trunk@54631 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-18 13:28:59 +00:00
Sergey Biryukov
313ebd3162 Tests: Increase test coverage for WP_Theme_JSON_Resolver.
This commit adds a unit test to check that `WP_Theme_JSON_Resolver::get_theme_data()` returns a `WP_Theme_JSON` object, and that an `add_theme_support()` call overrides the settings from `theme.json`.

Follow-up to [54443], [54493].

Props cbravobernal.
Fixes #56835.

git-svn-id: https://develop.svn.wordpress.org/trunk@54630 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-18 13:19:38 +00:00
Jb Audras
d815d2e8b2 Query: Validate relation in WP_Date_Query.
Props dd32, johnjamesjacoby, martinkrcho, ehtis, paulkevan, peterwilsoncc.


git-svn-id: https://develop.svn.wordpress.org/trunk@54530 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-17 11:47:41 +00:00
Jb Audras
3765886b49 Mail: Reset PHPMailer properties between use.
Props xknown, martinkrcho, tykoted.


git-svn-id: https://develop.svn.wordpress.org/trunk@54529 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-17 11:40:36 +00:00
Jb Audras
89c8f79194 Comments: Apply kses when editing comments.
Props davidbaumwald, xknown, peterwilsoncc, paulkevan.


git-svn-id: https://develop.svn.wordpress.org/trunk@54527 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-17 11:29:55 +00:00
Jb Audras
8836d46822 Media: Refactor search by filename within the admin.
Props vortfu, xknown, peterwilsoncc, paulkevan.


git-svn-id: https://develop.svn.wordpress.org/trunk@54524 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-17 11:17:38 +00:00
Sergey Biryukov
c39a45cd3f Tests: Delete leftover image sub-sizes after WP_Customize_Manager tests.
After running `phpunit --filter test_import_theme_starter_content`, the following files were generated and left in place in the version-controlled `DIR_TESTDATA` directory, resulting in a dirty working copy of the project:
{{{
tests/phpunit/data/images/canola-150x150.jpg
tests/phpunit/data/images/canola-300x225.jpg
}}}

In the test, `canola.jpg` is mocked as an **existing attachment**. When the test invokes `WP_Customize_Manager::import_theme_starter_content()`, existing attachments are passed directly to `wp_generate_attachment_metadata()`, which does not make a copy of the file, and `wp_create_image_subsizes()` creates the above referenced files in the original image's location.

By contrast, `waffles.jpg`, also used in the test, is **not** set as an existing attachment, and in  `import_theme_starter_content()` is passed to `media_handle_sideload()`, which makes a **copy** of the file in the `wp-content/uploads/` directory, and then calls `wp_create_image_subsizes()` against the new file. The resulting sub-sizes are generated in that location, and are cleaned up during `tear_down()`.

The test's `tear_down()` uses `remove_added_uploads()`, which only clears items created in `wp-content/uploads/` (i.e. `waffles*.jpg`), but not the files in the `DIR_TESTDATA` directory (`canola-*.jpg`).

This commit addresses the issue by creating a copy of the file in uploads. This better matches the intention of the test, as existing attachments will most likely be located in uploads and not in an arbitrary path like the test data directory.

Follow-up to [39276], [39346], [39411], [40142], [54424], [54425].

Props ironprogrammer, audrasjb, boniu91, dariak, SergeyBiryukov.
Fixes #56807.

git-svn-id: https://develop.svn.wordpress.org/trunk@54519 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-15 01:08:33 +00:00
Jonathan Desrosiers
e6240966b7 Tests: Revert unintentional change in [54508].
Unprops desrosj.
See #56817.

git-svn-id: https://develop.svn.wordpress.org/trunk@54509 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-13 16:43:36 +00:00
Jonathan Desrosiers
b267249df9 Tests: Temporarily skip WOFF file test on PHP 8.2.
A recent change to how WOFF files are processed in PHP 8.2 RC3 has caused a new test failure.

This temporarily marks the `test_wp_check_filetype_and_ext_with_filtered_woff()` test skipped until a deeper analysis can be performed.

Props SergeyBiryukov, jrf, desrosj, oandregal.
See #56817.

git-svn-id: https://develop.svn.wordpress.org/trunk@54508 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-13 16:34:42 +00:00
Tonya Mork
90a7ecc474 Editor: Rename new theme_json_{$context} filters.
The newly introduced filters are renamed to use the `wp_theme_json_data{$context}` structure:

* `theme_json_default` renamed to `wp_theme_json_data_default`
* `theme_json_theme` renamed to `wp_theme_json_data_theme`
* `theme_json_blocks` renamed to `wp_theme_json_data_blocks`
* `theme_json_user` renamed to `wp_theme_json_data_user`

The following new filter gets the `wp_` prefix added:
* `theme_json_get_style_nodes` renamed to `wp_theme_json_get_style_nodes`

Follow-up to [56467], [54183], [54118].

Props kebbet, desrosj, mukesh27, ocean90, sergeybiryukov, davidbaumwald, hellofromTonya.
Fixes #56796.

git-svn-id: https://develop.svn.wordpress.org/trunk@54501 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 20:06:16 +00:00
David Baumwald
64591219a0 Editor: Add test data for Fluid Typography.
Follow-up to [54280] and [54497].

Props desrosj, hellofromTonya, SergeyBiryukov.
See #56467.

git-svn-id: https://develop.svn.wordpress.org/trunk@54500 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 19:50:46 +00:00
David Baumwald
a874e5fe5e Editor: Merge latest fluid typography bugfixes for 6.1 Release Candidate 1.
Merges the following:
* [https://github.com/WordPress/gutenberg/pull/44761 Gutenberg PR 44761] - Fluid Typography: Fix bug in global styles where fluid `clamp()` rules were not calculated for custom values
* [https://github.com/WordPress/gutenberg/pull/44762 Gutenberg PR 44762] - Fluid Typography: Convert server-side block support values
* [https://github.com/WordPress/gutenberg/pull/44764 Gutenberg PR 44764] - Fluid Typography: Convert font size inline style attributes to fluid values
* [https://github.com/WordPress/gutenberg/pull/44807 Gutenberg PR 44807] - Fluid Typography: Covert font size number values to pixels
* [https://github.com/WordPress/gutenberg/pull/44847 Gutenberg PR 44847] - Fluid Typography: ensure font sizes are strings or integers

Follow-up to [54280].

Props andrewserong, isabel_brison, ramonopoly.
See #56467.

git-svn-id: https://develop.svn.wordpress.org/trunk@54497 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 18:42:20 +00:00
Sergey Biryukov
aa11f4cef1 Query: Avoid PHP notices when get_queried_object() returns null.
`WP_Query` methods assume that `get_queried_object()` would return a non-null value, which is not always the case.

This commit resolves various warnings in `WP_Query` along the lines of:
{{{
Attempt to read property "post_type" on null in wp-includes/class-wp-query.php on line 4338
}}}

Follow-up to [1728], [3639], [8807], [49119].

Props dd32, yellyc, boonebgorges, darkskipper, Howdy_McGee, swissspidy, nacin, mikeschroder, mikejolley, sterlo, datainterlock, utsavmadaan823, kanlukasz, woji29911, hellofromTonya, zikubd, deksar, bwbama, noplanman, nouarah, SergeyBiryukov.
Fixes #29660.

git-svn-id: https://develop.svn.wordpress.org/trunk@54496 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 18:13:34 +00:00
Tonya Mork
4be76617b9 Editor: Fix performance regression in WP_Theme_JSON_Resolver.
A significant performance regression was added late in WP 6.1 beta cycle when some of the existing caching for `theme.json` processing was removed. The rationale for removing the caching was this code was now used before all the blocks are registered (aka get template data, etc.) and resulted in stale cache that created issues (see [https://github.com/WordPress/gutenberg/issues/44434 Gutenberg Issue 44434] and [https://github.com/WordPress/gutenberg/issues/44619 Gutenberg Issue 44619]). The changes were limited to only reads from the file system. However, it introduced a big impact in performance.

This commit adds caching and checks for blocks with different origins. How? It add caching for the calculated data for core, theme, and user based on the blocks that are registered. If the blocks haven't changed since the last time they were calculated for the origin, the cached data is returned. Otherwise, the data is recalculated and cached.

Essentially, this brings back the previous cache, but refreshing it when the blocks change.

It partially adds unit tests for these changes. Additional tests will be added.

References:
* [https://github.com/WordPress/gutenberg/issues/44772 Performance regression in WP 6.1 for theme.json processing]

Follow-up to [54251], [54399].

Props aristath, oandregal, bernhard-reiter, spacedmonkey, hellofromTonya.
See #56467.

git-svn-id: https://develop.svn.wordpress.org/trunk@54493 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 17:15:11 +00:00
Sergey Biryukov
c5e9de416b Comments: Consistently normalize user_ID to user_id in wp_new_comment().
For backward compatibility, the `user_id` parameter of `wp_new_comment()` can be spelled as `user_ID`, and plugins utilizing the `preprocess_comment` filter or the `comment_post` action should be able to receive both variations.

Follow-up to [12267], [12300], [28915], [36038], [53729].

Props peterwilsoncc, SergeyBiryukov.
Fixes #56244.

git-svn-id: https://develop.svn.wordpress.org/trunk@54489 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 16:30:40 +00:00
Sergey Biryukov
645f474fc0 Comments: Return early from comment_form() if an invalid post ID is passed.
If an invalid post ID is passed to the function, `comments_open()` should return `false`, and no comment form be displayed. This commit restores the previous behavior that was unintentionally changed when standardizing on the `$post` parameter name.

Follow-up to [53715].

Props peterwilsoncc.
Fixes #56243.

git-svn-id: https://develop.svn.wordpress.org/trunk@54488 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 15:43:04 +00:00
Jb Audras
525d6d2a34 Networks and Sites: Ensure fileupload_maxk is an int to avoid potential fatal errors.
This changeset fixes a potential fatal error, for example when "Max upload file size" setting is set to an empty value. It also adds unit tests for `upload_size_limit_filter`.

Props mjkhajeh, bhrugesh12, SergeyBiryukov, kebbet, audrasjb, felipeelia.
Fixes #55926.


git-svn-id: https://develop.svn.wordpress.org/trunk@54482 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 15:05:29 +00:00
Sergey Biryukov
865b8ac065 Tests: Relocate the tests for recommended PHP, MySQL, and MariaDB versions.
This commit moves the tests for recommended versions of dependencies referenced in `readme.html` to a new location for better context. Also updates test class name for clarity, and `@covers` annotations to `@coversNothing`.

Follow-up to [26166], [33946], [35172], [52418], [52424].

Props ironprogrammer, bbobnis, antonvlasenko, azaozz, chaion07, priyomukul.
Fixes #45867.

git-svn-id: https://develop.svn.wordpress.org/trunk@54479 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 14:25:47 +00:00
Jb Audras
2414439208 Menus: Remove .menu-item-has-children on wp_nav_menu last level menu items when $depth arg is used.
This changeset prevents `wp_nav_menu` last level menu items from having the `.menu-item-has-children` class when the `$depth` argument is used. It adds a loop in `wp_nav_menu()` to calculate the depth of each menu item with children to make sure the class is added only when applicable.

Props slobodanmanic, kucrut, iCaspar, mdgl, petitphp, audrasjb, costdev.
Fixes #28620.


git-svn-id: https://develop.svn.wordpress.org/trunk@54478 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 14:02:55 +00:00
Sergey Biryukov
d136e57d63 Users: Fetch user by login in retrieve_password() if not found by email.
This ensures that sending a password reset link works as expected if the user's login and email were initially the same, but the email address was subsequently updated and no longer matches the login, which is still set to the old address.

Follow-up to [6643], [18513], [19056], [37474], [50129], [50140].

Props donmhico, pbearne, azouamauriac, boblindner, daxelrod, audrasjb, SergeyBiryukov.
Fixes #53634.

git-svn-id: https://develop.svn.wordpress.org/trunk@54477 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 13:43:20 +00:00
Jb Audras
b20675e8dd Formatting: Strip object replacement characters from slugs.
This changeset prevents object replacement characters – UTF-8 `%ef%bf%bc`, used as a placeholder in text for an otherwise unspecified object – from being added to slugs.

Props cantuaria, costdev, audrasjb, SergeyBiryukov, archon810, maciejmackowiak, BaneD, markparnell, ironprogrammer, dmsnell, nikkigagency, webprom.
Fixes #55117.


git-svn-id: https://develop.svn.wordpress.org/trunk@54474 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 10:27:00 +00:00
Jb Audras
5b5e1bb8c9 Build/Test Tools: Add unit test for non-existing block-styles registration.
Follow-up to [54155].

Props aristath, mukesh27.
Fixes #56664.


git-svn-id: https://develop.svn.wordpress.org/trunk@54472 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-11 09:58:27 +00:00
Jb Audras
5ef83659d0 Query: Prevent PHP notice when get_post_type_object() returns null in is_post_type_archive().
This changeset avoids potential PHP notices caused by `get_post_type_object()` returning `null` when called inside `is_post_type_archive()`.

Props sean212, costdev.
Fixes #56287.


git-svn-id: https://develop.svn.wordpress.org/trunk@54464 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-10 23:01:08 +00:00
Jb Audras
aad26ece43 General: Remove instances of _wp_http_referer from GET forms in the admin.
This changeset removes all instances of `_wp_http_referer` variable from the URL when creating a hidden input for `_wp_http_referer`. It prevents the hidden field from having an additional version of `_wp_http_referer` each time the form is submitted.

Props msolution, justinahinon, pbearne, mikeschroder, mukesh27, audrasjb, Clorith, chaion07, robinwpdeveloper, hztyfoon, davidbaumwald, costdev, adamsilverstein.
Fixes #54106.


git-svn-id: https://develop.svn.wordpress.org/trunk@54449 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-10 18:57:44 +00:00
Sergey Biryukov
832b6c35f3 Cache API: Introduce wp_cache_supports() function.
WordPress has recently introduced a variety of caching API improvements:

* `wp_cache_add_multiple()`
* `wp_cache_set_multiple()`
* `wp_cache_get_multiple()`
* `wp_cache_delete_multiple()`
* `wp_cache_flush_runtime()`
* `wp_cache_flush_group()`

Although WordPress core provides a compatibility layer if these functions are missing from third-party object cache implementations, there should be a method of checking whether the cache backend supports a particular feature.

This commit aims to improve developer experience by allowing third-party object cache plugins to declare a `wp_cache_supports()` function and correctly list their supported features:

* `add_multiple`
* `set_multiple`
* `get_multiple`
* `delete_multiple`
* `flush_runtime`
* `flush_group`

Note: The `wp_cache_supports()` function replaces and supersedes the `wp_cache_supports_group_flush()` function added earlier.

Follow-up to [47938], [47944], [52700], [52703], [52706], [52708], [53763], [53767], [54423].

Props johnjamesjacoby, tillkruess, spacedmonkey, SergeyBiryukov.
Fixes #56605.

git-svn-id: https://develop.svn.wordpress.org/trunk@54448 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-10 18:20:28 +00:00
Sergey Biryukov
5cbf7edcc8 Login and Registration: Rename is_login_screen() function to is_login().
As the function can be used in a variety of contexts, the `_screen` suffix may not always be appropriate.

This commit aims to reduce confusion by renaming the newly added `is_login_screen()` function to `is_login()`, which better aligns with `is_admin()` and the related `is_*_admin()` function family.

While it does not save a lot of lines of code, this function aims to save developers some time that would otherwise be spent investigating the most reliable way to determine whether the current request is for the login screen.

Implementation details:
* By checking `wp_login_url()`, the function accounts for custom login locations set via the `login_url` filter.
* By checking `$_SERVER['SCRIPT_NAME']` directly, instead of `did_action( 'login_form_login' )` or `$pagenow` global, the function can work as early as possible, for example in a must-use plugin.

Follow-up to [53884].

Props azaozz.
Fixes #19898. See #56400.

git-svn-id: https://develop.svn.wordpress.org/trunk@54447 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-10 17:57:52 +00:00
Sergey Biryukov
bd001e80df Tests: Use assertSame() in some WP_Theme_JSON tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Previously committed in [54402], these instances appear to be accidentally reverted to `assertEquals()` in [54443].

Follow-up to [52275], [54162], [54402], [54443].

See #55654.

git-svn-id: https://develop.svn.wordpress.org/trunk@54446 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-10 15:57:11 +00:00
Jb Audras
db94aaa31c Build/Test Tools: Add missing newline character on unit tests files after [54443].
Follow-up to [54443].

See #56611.


git-svn-id: https://develop.svn.wordpress.org/trunk@54444 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-10 15:01:03 +00:00
Jb Audras
22f5f109bc Build/Test Tools: Expand unit tests for theme.json.
This changeset adds unit test coverage for the following features:

- Gradients
- `filter` (Duotones)
- `blockGap`
- `shadow`
- `useRootPaddingAwareAlignments`
- `appearanceTools`

Props gunterer, johnregan3, audrasjb, mukesh27.
Fixes #56611.


git-svn-id: https://develop.svn.wordpress.org/trunk@54443 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-10 14:52:21 +00:00
Sergey Biryukov
21c38bb6b3 Tests: Minimize file copying in WP_REST_Attachments_Controller tests.
The tests use two images that were deleted on teardown and recreated on setup for every single test. This appears to be unnecessary, as the files can instead only be recreated if they are missing, and deleted after the test run is complete.

This commit reduces ~200 redundant file copying operations to ~5 when running this test class.

Follow-up to [38832], [48291], [54424].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54428 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-09 17:45:54 +00:00
SergeyBiryukov
e8f4e448c9 Coding Standards: Correct alignment in test_import_theme_starter_content().
This fixes an `Equals sign not aligned correctly` WPCS warning.

Follow-up to [54425].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54426 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-09 16:37:01 +00:00
Sergey Biryukov
2517aff837 Tests: Clean up test images in WP_Customize_Manager tests.
The test for `WP_Customizer_Manager::import_theme_starter_content()` creates two attachments that remain in the `uploads` directory after the test run is complete.

This commit follows the approach from `WP_REST_Posts_Controller` tests and utilizes an `$attachments_created` property to track any files uploaded in the current test run and clean them up afterwards.

This makes sure there are no leftover images after the test class is run.

Follow-up to [39276], [39346], [39411], [40142], [53935], [54424].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54425 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-09 16:26:57 +00:00
Sergey Biryukov
323ac54d4b Tests: Remove unnecessary file copying in WP_Customize_Manager tests.
This was added to avoid creating leftover image sub-sizes in the version-controlled `DIR_TESTDATA` directory.

However, this does not appear to be necessary:
* `WP_Customizer_Manager::import_theme_starter_content()` already [source:tags/6.0.2/src/wp-includes/class-wp-customize-manager.php?marks=1370-1374#L1367 makes a copy of the image] before sideloading, so the test was essentially working with a copy of a copy.
* The images were only used in one test out of 70 and do not need to be copied for every single test.

Upon further investigation, there is also no evidence that creating these copies actually resolved the reported issue:
* `WP_UnitTest_Factory_For_Attachment::create_object()` inserts an attachment, but does not create image sub-sizes.
* `media_handle_sideload()` does create image sub-sizes, but the file is already in the media library by that time, and sub-sizes are created in the `uploads` directory, not in the version-controlled `DIR_TESTDATA` directory.

This commit removes ~140 redundant file copying operations when running the test suite.

Follow-up to [39276], [39346], [39411], [40142].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54424 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-09 13:45:23 +00:00
Sergey Biryukov
8d25a65892 Tests: Add wp_cache_*_multiple() functions to Memcached implementation used in the test suite.
Since this object cache implementation was added, WordPress has introduced a variety of caching API improvements:
* `wp_cache_add_multiple()`
* `wp_cache_set_multiple()`
* `wp_cache_get_multiple()`
* `wp_cache_delete_multiple()`

Although WordPress core provides a compatibility layer if these functions are missing from third-party object caches, this commit updates the Memcached object cache used in the test suite to implement these new functions directly.

Follow-up to [40561], [47938], [47944], [52700], [52703], [52706], [52708].

Props petitphp, spacedmonkey, tillkruss, SergeyBiryukov.
Fixes #54864.

git-svn-id: https://develop.svn.wordpress.org/trunk@54423 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-08 13:39:43 +00:00
Jb Audras
ec7a7c3f16 Build/Test Tools: Add tests coverage for _wp_check_alternate_file_names().
This changeset adds missing unit tests for this function.

Props pbearne, costdev, peterwilsoncc.
Fixes #55199.


git-svn-id: https://develop.svn.wordpress.org/trunk@54422 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-08 09:16:35 +00:00
Jb Audras
d53d13d6ce Build/Test Tools: Add tests for WP_List_Util::pluck and WP_List_Util::sort.
This changeset adds additional unit tests for these two functions.

Props pbearne, costdev, afragen.
Fixes #55300.


git-svn-id: https://develop.svn.wordpress.org/trunk@54421 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-08 08:44:45 +00:00
Jb Audras
a904cf42f8 Build/Test Tools: Add tests for wp_nonce_field() and wp_referer_field().
This changeset adds missing unit tests for these two functions.

Props pbearne, costdev, audrasjb.
Fixes #55578.


git-svn-id: https://develop.svn.wordpress.org/trunk@54420 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-07 22:17:06 +00:00
Adam Silverstein
16f127dff7 Media: ensure the wp_editor_set_quality filter consistently passes the correct output mime type.
Ensure that the mime type passed to the `wp_editor_set_quality` filter is correct when the output format is altered with the `image_editor_output_format` filter and the image is saved multiple times, for example when generating sub sizes. Previously, the original image mime type was passed instead of the output type after the initial save.

Props flixos90, peterwilsoncc.
Fixes #56442.




git-svn-id: https://develop.svn.wordpress.org/trunk@54417 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-07 19:15:59 +00:00
Jonny Harris
fd60449f92 Query: Move call to update_menu_item_cache in WP_Query
Move call to `update_menu_item_cache` in `WP_Query` to after post meta caches for menu items are primed. 

Props spacedmonkey, peterwilsoncc, mukesh27.
See #55620.

git-svn-id: https://develop.svn.wordpress.org/trunk@54410 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-07 09:58:32 +00:00
Peter Wilson
426d20a60a Build/Test tools: Add tests for wp_nonce_url().
Props pbearne, costdev.
See #55652.
Fixes #54870.


git-svn-id: https://develop.svn.wordpress.org/trunk@54407 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-07 02:49:24 +00:00
Sergey Biryukov
063f946989 Tests: Clean up test image for site icon in Tests_REST_Server on teardown.
This makes sure there are no leftover images after the test class is run.

Follow-up to [52080], [53463], [53920].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54403 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-07 01:07:28 +00:00
Jonathan Desrosiers
28fdf705dc Tests: Replace some occurrences of assertEquals() with assertSame().
This ensures that not only the return values match the expected results, but also that their type is the same.

Props costdev, desrosj.
See #55654.

git-svn-id: https://develop.svn.wordpress.org/trunk@54402 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-07 01:02:07 +00:00
Sergey Biryukov
8128f19599 Tests: Bring some consistency to WP_Image_Editor_GD and WP_Image_Editor_Imagick tests.
Includes:
* Adjusting test method descriptions and comments per the documentation standards.
* Creating image editor class instances directly, instead of calling `wp_get_image_editor()`.
* Cleaning up temporary files before performing assertions, where possible.
* Using more consistent variable names for image editor class instances.
* Reordering some test methods.

Follow-up to [1182/tests], [1188/tests], [27794], [30549], [30990], [31040], [39580], [40123], [49230], [49488], [49542], [49751].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54401 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-07 00:40:07 +00:00