This aims to bring some consistency to the location of multisite function tests, as well as to make the tests more discoverable and easier to expand.
Follow-up to [29916], [32638], [46251], [54717].
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54726 602fd350-edb4-49c9-b593-d223f7449a82
In the tests for updating a theme via Ajax, `wp_installing( true )` is called to prevent `wp_update_themes()` from running.
This worked as expected in `test_update_theme()`, however, it was missed in `test_uppercase_theme_slug()`, which was accidentally relying on the `wp_installing()` status not being properly restored in the previous test.
Now that the `wp_installing()` status was corrected in [54723], the latter test started throwing an error on PHP 8.2:
{{{
1) Tests_Ajax_wpAjaxUpdateTheme::test_uppercase_theme_slug
http_build_query(): Passing null to parameter #2 ($numeric_prefix) of type string is deprecated
/var/www/src/wp-includes/Requests/Transport/cURL.php:345
/var/www/src/wp-includes/Requests/Transport/cURL.php:135
/var/www/src/wp-includes/class-requests.php:381
/var/www/src/wp-includes/class-wp-http.php:395
/var/www/src/wp-includes/class-wp-http.php:615
/var/www/src/wp-includes/http.php:179
/var/www/src/wp-includes/update.php:719
/var/www/src/wp-admin/includes/ajax-actions.php:4292
/var/www/src/wp-includes/class-wp-hook.php:308
/var/www/src/wp-includes/class-wp-hook.php:332
/var/www/src/wp-includes/plugin.php:517
/var/www/tests/phpunit/includes/testcase-ajax.php:265
/var/www/tests/phpunit/tests/ajax/wpAjaxUpdateTheme.php:157
}}}
Replicating the `wp_installing()` status changes in this test too resolves the error.
Follow-up to [38168], [38710], [54722], [54723].
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54725 602fd350-edb4-49c9-b593-d223f7449a82
A recent change to how WOFF files are processed in PHP 8.2 RC3 has caused a new test failure.
The tests was previously skipped on PHP 8.2, however, apparently after a `fileinfo` extension update, it started failing on PHP 8.1 too.
This commit adjusts the skipping condition to include PHP 8.1.
Follow-up to [54508], [54509].
See #56817.
git-svn-id: https://develop.svn.wordpress.org/trunk@54724 602fd350-edb4-49c9-b593-d223f7449a82
In the tests for updating a plugin or theme via Ajax, `wp_installing( true )` was called to prevent `wp_update_plugins()` or `wp_update_themes()` from running.
Since the subsequent `wp_installing( false )` call was in the same `try { ... }` block, it could not be executed if an exception was thrown, affecting other tests.
In this case, after rearranging the Ajax tests in [54722], this started affecting the `get_site_option()` calls in the tests for `wp_ajax_wp_compression_test()`.
By moving both `wp_installing()` calls out of the `try`/`catch` block, we can ensure the status is correctly restored.
Follow-up to [734/tests], [37150], [38168], [38710], [54722].
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54723 602fd350-edb4-49c9-b593-d223f7449a82
This updates the test classes to match the names of the functions being tested.
Includes moving the `@covers` tags from individual test methods to the class DocBlocks.
Reference: [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization Writing PHP Tests: Naming and Organization].
Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623], [51639], [51646], [51650], [51651], [51860], [52264], [52265], [53489], [53561], [54704].
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54722 602fd350-edb4-49c9-b593-d223f7449a82
This fixes an `Equals sign not aligned with surrounding assignments` WPCS warning.
Follow-up to [54720].
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54721 602fd350-edb4-49c9-b593-d223f7449a82
This was previously used to delete the users created during `wpSetUpBeforeClass()`, however that now happens automatically in `WP_UnitTestCase_Base::tear_down_after_class()` via `_delete_all_data()`.
Follow-up to [35311], [37404], [38398].
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54720 602fd350-edb4-49c9-b593-d223f7449a82
As the tests belong to either the `ms-excluded` or the `ms-required` group, the skipping should not be necessary.
While these methods were initially intended to be used in conjunction with the respective group, the PHPUnit configuration files for single site and multisite exclude these groups as appropriate, so calling these methods explicitly is no longer required.
Follow-up to [40520], [40543], [40564], [43005], [46683], [53011].
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54719 602fd350-edb4-49c9-b593-d223f7449a82
This was previously removed in [51870] and appears to be accidentally readded in [53561].
As the test belongs to the `ms-excluded` group, the skipping is unnecessary and does not affect anything in practice.
Follow-up to [46693], [49835], [51870], [53561].
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54718 602fd350-edb4-49c9-b593-d223f7449a82
This aims to bring some consistency to the location of category function tests, as well as to make the tests more discoverable and easier to expand.
Follow-up to [28438], [28566], [31006], [31025], [37464], [28438], [31299], [36988], [42364], [42367], [42368], [46413], [53684].
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54717 602fd350-edb4-49c9-b593-d223f7449a82
This aims to bring some consistency to the location of pluggable function tests.
Includes:
* Renaming the test class to better reflect the intention of the tests.
* Adding a `@coversNothing` tag to the class DocBlock.
Follow-up to [34126], [53478], [54702].
Props pbearne, SergeyBiryukov.
See #56793, #56782.
git-svn-id: https://develop.svn.wordpress.org/trunk@54716 602fd350-edb4-49c9-b593-d223f7449a82
Based on feedback from network storage configurations there was a noticed slowdown due to the usage of the `path_join()` function. This needs more time to find a workaround.
Follow-up to [53934].
Props mreishus, SergeyBiryukov, desrosj, mikeschroder.
Reverts [53934].
See #56924.
git-svn-id: https://develop.svn.wordpress.org/trunk@54712 602fd350-edb4-49c9-b593-d223f7449a82
This aims to bring some consistency with other database-related tests.
Includes adding a missing `@covers` tag to the class DocBlock.
Follow-up to [30345], [32108], [32770], [51798].
Props pbearne, SergeyBiryukov.
See #56793, #56782.
git-svn-id: https://develop.svn.wordpress.org/trunk@54711 602fd350-edb4-49c9-b593-d223f7449a82
This aims to bring some consistency to the location of the tests for this class.
Includes adding the missing `@covers` tags.
Follow-up to [36177], [51622], [54250].
Props pbearne, SergeyBiryukov.
See #56793, #56782.
git-svn-id: https://develop.svn.wordpress.org/trunk@54710 602fd350-edb4-49c9-b593-d223f7449a82
This change removes caching of global styles for logged in users, allowing "wp_global_styles" custom post type to be imported completely, regardless of any previously cached data. This change now relies on the lower-level native `WP_Query` cache invalidation methods for the global styles post type.
Follow-up to [52275], [54186].
Props anariel-design, bernhard-reiter, andrewserong, spacedmonkey, andraganescu, peterwilsoncc, oandregal, hellofromTonya.
Fixes#56901.
git-svn-id: https://develop.svn.wordpress.org/trunk@54706 602fd350-edb4-49c9-b593-d223f7449a82
This change ensures custom styles for all third-party blocks are rendered on the front end if assets are set to be loaded on a per-block basis. Additionally, this change includes new unit tests to help prevent a similar bug in the future.
Props scruffian, aristath, poena, wildworks, ajlende, andraganescu, ndiego, gigitux, cbravobernal, ramonopoly, andrewserong, oandregal, hellofromTonya, bernhard-reiter.
Fixes#56915.
git-svn-id: https://develop.svn.wordpress.org/trunk@54703 602fd350-edb4-49c9-b593-d223f7449a82
This aims to bring some consistency with other pluggable function tests.
Includes moving the `@covers` tag from a single test method to the class DocBlock.
Follow-up to [221/tests], [909/tests], [54529].
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54702 602fd350-edb4-49c9-b593-d223f7449a82
This aims to bring some consistency with other comment function tests.
Includes moving the `@covers` tags from individual test methods to the class DocBlock.
Follow-up to [34799], [34801], [53863].
See #56793.
git-svn-id: https://develop.svn.wordpress.org/trunk@54701 602fd350-edb4-49c9-b593-d223f7449a82
Introduce `WP_Query::generate_cache_key()` for generating the cache key used by the main database query.
This removes the need for a filter to test that cache keys do not include the WPDB placeholder causing unreachable cache keys. The tests now call `WP_Query::generate_cache_key()` directly.
The filter `wp_query_cache_key` is removed as a hard deprecation. The filter was not included in a stable release.
Follow up to [54634].
Props spacedmonkey, jorbin, azaozz, hellofromtonya, mukesh27, peterwilsoncc, desrosj, audrasjb, adamsilverstein, flixos90, davidbaumwald, joedolson, sergeybiryukov.
Fixes#56802.
git-svn-id: https://develop.svn.wordpress.org/trunk@54685 602fd350-edb4-49c9-b593-d223f7449a82
This resolves a bug in Featured Image blocks where `object-fit` was being removed during the `render_callback`.
Props raduiason, pbiron, kebbet, SergeyBiryukov, bernhard-reiter, ironprogrammer, xknown, audrasjb, ckanderson22, ivanjeronimo, seriouslysenpai.
Fixes#56855.
git-svn-id: https://develop.svn.wordpress.org/trunk@54675 602fd350-edb4-49c9-b593-d223f7449a82
Based on feedback, this enhancement isn't quite ready. Reverting [54213] for now to continue the work in the next cycle.
Follow-up to [54213].
Props manfcarlo, peterwilsoncc.
git-svn-id: https://develop.svn.wordpress.org/trunk@54673 602fd350-edb4-49c9-b593-d223f7449a82
In `register_block_type`, continue to allow passing arrays as the `editor_script`, `script`, `view_script`, `editor_style`, and `style` arguments. Note that those fields were soft-deprecated in favor of their `_handles` counterparts in [54155], which would allow specifying multiple items. At the same time, the deprecated fields were limited to `string` or `null`.
However, this broke existing code that passed an array as one of those arguments. For backwards compatibility, this change thus restores the previous behavior. It is implemented in `WP_Block_Type` as a pair of `__get()` and `__set()` methods that wrap around the corresponding `_handles` members, which are arrays of strings.
It also affects the REST API endpoint for block types. The latter’s schema has never allowed for anything other than `string` or `null` for any of those fields. For this reason, it now returns the first element of the array stored in the corresponding `_handles` member in `WP_Block_Type`.
Follow-up [54155].
Props nendeb55, costdev, gziolo, spacedmonkey, mukesh27, sergeybiryukov, audrasjb.
Fixes#56707.
git-svn-id: https://develop.svn.wordpress.org/trunk@54670 602fd350-edb4-49c9-b593-d223f7449a82
`WP_Textdomain_Registry` was introduced in [53874] to store text domains and their language directory paths, addressing issues with just-in-time loading of textdomains when using locale switching and when using`load_*_textdomain()` functions.
Said change has inadvertently caused a performance regression exactly when using`load_*_textdomain()`, which still often is the case, where the cached information was not further used or even overridden.
This change addresses that issue by storing the default languages paths in a separate way, while at the same time making `WP_Textdomain_Registry` easier to maintain and adding new tests to catch future regressions.
Props flixos90, spacedmonkey, ocean90, SergeyBiryukov, costdev.
Fixes#39210.
git-svn-id: https://develop.svn.wordpress.org/trunk@54669 602fd350-edb4-49c9-b593-d223f7449a82
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
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
[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
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
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
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
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
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
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
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
`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
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
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
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
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
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