5038 Commits

Author SHA1 Message Date
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
Peter Wilson
e5a0d1364d Users: Revert use of shared objects for current user.
Reverts [50790].

Props oztaser, ravipatel, dd32, costdev, SergeyBiryukov, tykoted, cu121, xknown.
Fixes #54984.



git-svn-id: https://develop.svn.wordpress.org/trunk@54397 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-06 04:36:46 +00:00
Sergey Biryukov
aac3784618 Tests: Add comments to clarify a REST API test for password protected posts.
Authenticated users should only be allowed to read password protected content if they have the `edit_post` meta capability for the post. In other words, the content of a password protected post created by an Editor should not be viewable by a Contributor.

This commit aims to clarify the usage of a negative assertion `assertStringNotContainsString()` and describe the intention behind the test to avoid confusion.

Follow-up to [50717].

Fixes #56681.

git-svn-id: https://develop.svn.wordpress.org/trunk@54396 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-05 14:47:07 +00:00
Sergey Biryukov
bb37d755bb Tests: Ignore EOL differences in Style Engine API tests.
Unix vs. Windows EOL style mismatches can cause misleading failures in tests using the heredoc syntax (`<<<`) or multiline strings as the expected result.

This resolves two failures when running the test suite on Windows along the lines of:
{{{
1) Tests_Style_Engine_wpStyleEngineCSSRule::test_should_prettify_css_rule_output
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
 #Warning: Strings contain different line endings!
-'.baptiste {
-       margin-left: 0;
-       font-family: Detective Sans;
+'.baptiste {
+       margin-left: 0;
+       font-family: Detective Sans;
}'

/var/www/tests/phpunit/tests/style-engine/wpStyleEngineCssRule.php:159
}}}

Follow-up to [46612], [48443], [48466], [49691], [51135], [53282], [53319], [54156].

See #56467, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54394 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-05 14:04:05 +00:00
Sergey Biryukov
fed98bd9ef Database: Correct MariaDB version check in wpdb::has_cap().
MariaDB version is reported differently between PHP versions:
* PHP 8.0.16 or later: `10.6.8-MariaDB`
* PHP 8.0.15 or earlier: `5.5.5-10.6.8-MariaDB`

The latter includes PHP 7.4.x and PHP 5.6.x as well, where the version is also reported with the `5.5.5-` prefix.

This commit makes an adjustment to `wpdb::has_cap()` to check for the correct MariaDB version.

This resolves an issue where the `utf8mb4_unicode_520_ci` collation, which is available in MariaDB since version 10.2, was previously not detected correctly.

References:
* [https://github.com/php/php-src/issues/7972 php-src: #7972: MariaDB version prefix 5.5.5- is not stripped]
* [https://github.com/php/php-src/pull/7963 php-src: PR #7963 Fix GH-7932: MariaDB version prefix not always stripped]
* [https://mariadb.com/docs/reference/mdb/collations/utf8mb4_unicode_520_ci/ MariaDB Documentation: utf8mb4_unicode_520_ci]

Follow-up to [37523], [53919].

Props jamieburchell, SergeyBiryukov.
Fixes #54841.

git-svn-id: https://develop.svn.wordpress.org/trunk@54384 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-04 15:39:28 +00:00
Tonya Mork
7e25b96f06 Editor: Add PHPUnit tests for 5.9.0 new functions.
During the 5.9.0 cycle, tests were missed during the porting from Gutenberg to Core for the following functions:

* `_disable_block_editor_for_navigation_post_type()`
* `_disable_content_editor_for_navigation_post_type()`
* `_enable_content_editor_for_navigation_post_type()`
* `wp_filter_global_styles_post()`

This commit adds new test classes for these functions.

Reference:
* [https://github.com/WordPress/gutenberg/blob/release/13.6/phpunit/global-styles-test.php Gutenberg v13.6] for `WP_Global_Styles_Test`
* [https://github.com/WordPress/gutenberg/blob/release/13.6/phpunit/navigation-test.php Gutenberg v13.6] for `WP_Navigation_Test`

Follow-up to [52298], [52145], [52052].

Props antonvlasenko, costdev, ironprogrammer, robinwpdeveloper, hellofromTonya.
Fixes #56266.

git-svn-id: https://develop.svn.wordpress.org/trunk@54382 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-04 14:20:18 +00:00
Peter Wilson
4a9ab59d91 Posts, Post types: Prevent get_page_by_title() parsing query twice.
In `get_page_by_title()` access the populated `WP_Query::posts` property directly rather than via the `WP_Query::get_posts()` method. This removes unnecessary reprocessing of the query.

Follow up to [54234].

Props david.binda, mukesh27, spacedmonkey.
Fixes #56721.



git-svn-id: https://develop.svn.wordpress.org/trunk@54377 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-04 03:31:04 +00:00
Sergey Biryukov
7fe48a3d62 Code Modernization: Correct default values in wp_handle_comment_submission().
This affects the following parameters subsequently passed to `wp_new_comment()`:
* `comment_author`
* `comment_author_email`
* `comment_author_url`
* `comment_content`

The default values for these parameters were previously set to `null`, causing PHP 8.1 "null to non-nullable" deprecation notices when running sanitization filters on them via `wp_filter_comment()`.

While the deprecation notices were temporarily silenced in the unit test suite, that caused an unexpected issue in a test for [source:tags/6.0.2/tests/phpunit/tests/comment-submission.php#L202 submitting a comment to a password protected post], where the `$_COOKIE[ 'wp-postpass_' . COOKIEHASH ]` value was no longer unset, as the test stopped any further execution once the deprecation notice was triggered.

Due to how WordPress handles password protected posts, once that value is set, it affects all posts protected with the same password, so this resulted in unintentionally affecting [source:tags/6.0.2/tests/phpunit/tests/rest-api/rest-posts-controller.php#L1866 another test] which happened to use the same password.

These values are all documented to be a string in various related filters, and core also expects them to be a string, so there is no reason for these defaults to be set to `null`. Setting them to an empty string instead resolves the issues.

This commit includes:
* Setting the defaults in `wp_handle_comment_submission()` to an empty string.
* Adding a dedicated unit test to verify the type of these default values.
* Removing the deprecation notice silencing as no longer needed.

Follow-up to [34799], [34801], [51968].

Props jrf, desrosj, mukesh27, SergeyBiryukov.
Fixes #56712. See #56681, #55656.

git-svn-id: https://develop.svn.wordpress.org/trunk@54368 602fd350-edb4-49c9-b593-d223f7449a82
2022-10-03 15:20:49 +00:00