46251 Commits

Author SHA1 Message Date
Adam Silverstein
87047ccf3a Media: revert the multi-mime feature.
This feature isn't quite ready to land.

Reverts r53786, r53848, r53847, r53845, r53751.

Props flixos90, azaozz, dd32.
See #55443.



git-svn-id: https://develop.svn.wordpress.org/trunk@54085 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-06 21:11:41 +00:00
Sergey Biryukov
9c45c90679 Block Editor: Preload settings and templates permissions.
This is a path for following changes in the Gutenberg plugin:
* [https://github.com/WordPress/gutenberg/pull/42209 #42209: Post Editor: Preload templates post type permissions]
* [https://github.com/WordPress/gutenberg/pull/42413 #42413: Post Editor: Avoid 403 errors for users with low permissions].

Follow-up to [43815], [44172], [46110], [51962], [52995].

Props Mamaduka, bernhard-reiter, TimothyBlynJacobs.
See #56467.

git-svn-id: https://develop.svn.wordpress.org/trunk@54084 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-06 16:16:07 +00:00
Sergey Biryukov
18e1e81dea REST API: Add the missing site_icon_url to the index.
The `site_icon_url` index was supposed to ship with WordPress 5.6, but was [https://github.com/WordPress/gutenberg/pull/22952 never backported to core].

This commit backports the original PR from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/42957 #42957: REST API: Add the missing 'site_icon_url' to the index]

Follow-up to [52080].

Props Mamaduka, bernhard-reiter, TimothyBlynJacobs.
See #56467.

git-svn-id: https://develop.svn.wordpress.org/trunk@54083 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-06 14:41:08 +00:00
Sergey Biryukov
31fa0c854f Docs: Add a @since note for the update_network_meta_cache parameter of WP_Network_Query::__construct().
Follow-up to [54080].

See #55646.

git-svn-id: https://develop.svn.wordpress.org/trunk@54082 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-06 14:19:22 +00:00
Sergey Biryukov
040afa7ae3 Docs: Simplify a comment in WP_Network_Query::get_networks() and WP_Site_Query::get_sites().
This aims to improve readability. The arguments ignored are listed in the line directly below, so there is no need to mention them twice.

Follow-up to [41059], [41063], [53097], [53098], [54080].

See #55646.

git-svn-id: https://develop.svn.wordpress.org/trunk@54081 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-06 13:57:23 +00:00
Jonny Harris
bfbbf4928f Networks and Sites: Use metadata api in `*_network_options functions.
Replace logic found in `get_network_option`, `update_network_option` and `delete_network_option` to use the metadata api. Using the metadata api has a number of benefits, such as consistency, default values and useful filters. This change also improves performance by priming the caches of all network options in a single database request. 

Props spacedmonkey, swissspidy, sc0ttkclark, johnjamesjacoby, flixos90, jeremyfelt, pento, peterwilsoncc, mukesh27, desrosj.
Fixes #37181

git-svn-id: https://develop.svn.wordpress.org/trunk@54080 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-06 11:26:45 +00:00
Robert Anderson
bb0cbe3f55 Script Loader: Pass startOfWeek setting to @wordpress/date
Allows the block editor to respect the site's Week Starts On setting by defining
`i10n.startOfWeek` when initialising the `@wordpress/date` module.

This is a backport of https://github.com/WordPress/gutenberg/pull/41648.

See #56467.
Props andrewserong.


git-svn-id: https://develop.svn.wordpress.org/trunk@54079 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-06 02:50:35 +00:00
Sergey Biryukov
225b6cbe78 Tests: Consistently create a post fixture in old date or slug redirect tests.
This affects:
* `Tests_Rewrite_OldDateRedirect`
* `Tests_Rewrite_OldSlugRedirect`

This commit updates the latter test class to create a post in the `wpSetUpBeforeClass()` method, for consistency with the former class. This ensures that both classes declare the `$post_id` property as `static`, to avoid a situation where non-static access is accidentally used when copying similar test cases from one class to the other.

Follow-up to [34659], [42587], [54077].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54078 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-06 01:25:45 +00:00
Sergey Biryukov
7771a7c7a9 Tests: Correct the cache invalidation tests for old date or slug redirect.
This affects:
* `Tests_Rewrite_OldDateRedirect::test_old_date_redirect_cache_invalidation()`
* `Tests_Rewrite_OldSlugRedirect::test_old_slug_redirect_cache_invalidation()`

In the former test, the `$post_id` property is declared as `static`, so can only be approached as static, even when used within the same class in which the property is declared.

Using non-static access will result in `null`. See: https://3v4l.org/93HQL

This PHP notice was hidden so far, due to the existence of magic methods in the `WP_UnitTestCase_Base class`.

All the same, the magic methods as they were, would also return `null` for this property. All in all, the post being updated for this test would never get the correct `post_id`.

Fixed by using static access to approach the `static` property.

On a related note, the described bug fix (using the actual `$post_id` instead of `null`) exposed that this test was as a matter of fact failing. This was just hidden by the first bug.

Based on the original commit introducing the test, an adjustment is now made which appears to be what the test actually ''intended'' to test. A similar change is made to the cache invalidation test for old slug redirects. While not strictly required, it brings some consistency between the two tests and ensures that both tests use a unique `post_name` value to avoid collisions with the previous values.

This bug was discovered while fixing (removing) the magic methods in the `WP_UnitTestCase_Base` class in an effort to improve compatibility with PHP 8.2.

Follow-up to [53549].

Props jrf, costdev, SergeyBiryukov.
See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54077 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-06 00:59:17 +00:00
Sergey Biryukov
b48ec1408e Tests: Correct the tests for Site Health SQL versions matching readme.html.
These tests should check the initial `$mysql_recommended_version` and `$mariadb_recommended_version` properties, as `WP_Site_Health::prepare_sql_data()` redefines the former with the latter to simplify further processing if MariaDB is used, leading to a test failure:
{{{
Tests_Site_Health::test_mysql_recommended_version_matches_readme_html
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'5.7'
+'10.3'
}}}

This commit uses the initial property values to ensure the correct versions are being compared.

Follow-up to [54069].

See #55791.

git-svn-id: https://develop.svn.wordpress.org/trunk@54076 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-06 00:11:20 +00:00
Sergey Biryukov
af52988c22 Tests: Move Site Health unit test class to phpunit/tests/admin/.
Includes:
* Renaming the test class per the [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization naming conventions].
* Creating a `WP_Site_Health` instance in the `set_up()` method, instead of leaving that to each individual test.

This brings some consistency with the tests for other admin classes, e.g. `WP_Community_Events`.

Follow-up to [45802], [51639].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54075 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-05 22:25:54 +00:00
Sergey Biryukov
98cf070991 Tests: Temporarily skip the test for recommended PHP version in readme.html.
This test verifies that the WordPress `readme.html` file recommends a PHP version that is actively supported. However, WordPress currently still recommends PHP 7.4 due to PHP 8.0/8.1 compatibility not being fully achieved, even though PHP 7.4 is end-of-life.

As things were, the assertion in the test was commented out, leading to this test being marked as “risky” for not performing any assertions.

Instead, let’s skip the test with a clear skip notification.

Follow-up to [52260].

Props jrf.
See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54074 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-05 21:14:38 +00:00
Sergey Biryukov
3ab0dc20b3 Tests: Prevent an Ajax test for IMAGE_EDIT_OVERWRITE from being marked as risky.
This affects `Tests_Ajax_MediaEdit::testImageEditOverwriteConstant()`.

In case the `$files_that_should_not_exist` file list is empty, the test would be marked as risky, since it would not perform any assertions.

This small tweak prevents that from happening.

Follow-up to [38113].

Props jrf.
See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54073 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-05 19:22:27 +00:00
Sergey Biryukov
10f6d876c9 Build/Test Tools: Do not allow tests to fail for select PHP 8.1 test runs.
This affects the following test groups:
* Ajax tests
* ms-files tests
* External HTTP tests
* Xdebug tests

The tests being run in these particular test groups are passing on PHP 8.1, however, the test runs are still allowed to “continue on error”. This creates the risk that new PHP 8.1 incompatibilities will be introduced without anyone noticing.

By no longer allowing these test runs to “continue on error”, that risk is removed.

Follow-up to [51588], [51604], [53922].

Props jrf.
See #55656, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54072 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-05 18:55:08 +00:00
Sergey Biryukov
a4ec93f438 Coding Standards: Use more meaningful variable names for output in the admin.
This renames some variables for clarity, per the [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions Naming Conventions]:
> Don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting.

* `$out` is renamed to `$output` in various list table methods and admin functions.
* `$sep` is renamed to `$separator` in various list table methods and admin functions.

This affects:
* `WP_Comments_List_Table::handle_row_actions()`
* `WP_List_Table::row_actions()`
* `WP_Media_List_Table::column_default()`
* `WP_MS_Sites_List_Table::site_states()`
* `WP_MS_Users_List_Table::column_blogs()`
* `WP_Terms_List_Table::column_name()`
* `_wp_dashboard_recent_comments_row()`
* `image_align_input_fields()`
* `image_size_input_fields()`
* `wp_doc_link_parse()`
* `_post_states()`
* `_media_states()`

Follow-up to [8653], [8692], [8864], [8910], [8911], [8916], [9103], [9153], [10607], [15491], [17793], [32644], [54070].

Props mukesh27, costdev.
See #56448, #55647.

git-svn-id: https://develop.svn.wordpress.org/trunk@54071 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-05 17:17:21 +00:00
Sergey Biryukov
81a14c3889 Coding Standards: Use more meaningful variable names in WP_Users_List_Table.
This renames some variables for clarity, per the [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions Naming Conventions]:
> Don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting.

* `$c` is renamed to `$columns` in `::get_columns()` and `::get_sortable_columns()`.
* `$r` is renamed to `$row` in `::single_row()`.

Follow-up to [3677], [5542], [6852], [8936], [15491], [16573].

Props burhandodhy, costdev, mukesh27, Presskopp.
See #56448, #55647.

git-svn-id: https://develop.svn.wordpress.org/trunk@54070 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-05 16:00:16 +00:00
Sergey Biryukov
604abb0216 Site Health: Bump the recommended MySQL and MariaDB versions.
* MySQL 5.6 has reached EOL (“End of Life”) in February 2021. The recommended minimum is bumped to 5.7 for now.
* MariaDB 10.2 has reached EOL in May 2022. The recommended minimum is bumped to 10.3 for now.

This commit brings the Site Health recommendations in line with `readme.html`.

Includes:
* Adding two unit tests to ensure the SQL server versions recommended by Site Health match `readme.html`.
* Consistently declaring the recommended and required versions as the `WP_Site_Health` class properties.
* Renaming some pre-existing private properties for clarity.

Follow-up to [44986], [52319], [52358], [52420], [52424], [53431], [53433], [53435], [meta11407], [meta11866].

See #55791, #meta5999, #meta6322.

git-svn-id: https://develop.svn.wordpress.org/trunk@54069 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-05 15:18:13 +00:00
Sergey Biryukov
c7af86080d Tests: Consistently set the current user in the tests for retaining a sticky status.
This affects:
* `test_user_without_publish_posts_cannot_affect_sticky()`
* `test_user_without_publish_posts_cannot_affect_sticky_with_edit_post()`

In both tests, the user is now set after creating the post, not before. This aims to better match the intention of the tests, as they ensure that a sticky status is unaffected for a post that is ''edited'' by a user without the `publish_posts` capability, not necessarily ''created'' by that user.

Includes minor documentation updates for consistency.

Follow-up to [33096], [35183].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54068 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-05 14:31:05 +00:00
Sergey Biryukov
b087346757 Tests: Set the current user to Editor in test_utf8mb3_post_saves_with_emoji().
This avoids a "Sorry, you are not allowed to edit this post" error further in the test. The test is currently skipped on GitHub Actions, as only runs on older MySQL versions specifically with the `utf8` character set.

The user was previously set for all tests in the file in the `set_up()` method, however that is no longer the case, as it was not required for the majority of the tests. It is, however, necessary for the `edit_post()` call in this particular test.

Follow-up to [30346], [53785].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54067 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-05 14:04:12 +00:00
Peter Wilson
37b2a7fb14 Posts, Post Types: Allow bypassing of term classes in get_post_class().
Introduces the filter `wp_post_class_taxonomies` to allow developers to bypass the generation of term based classes with the `get_post_class()` function.

Developers can use this filter to reduce the number of taxonomies for which classes term classes are generated. This can improve performance on sites with a large number of custom taxonomies.

Props boonebgorges, bordoni, davidbaumwald, desrosj, invelity, mukesh27, sebastianpisula, steveo2000, swissspidy, system909, tlovett1, xparham.
Fixes #37114.


git-svn-id: https://develop.svn.wordpress.org/trunk@54066 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-05 05:43:57 +00:00
Sergey Biryukov
fd1bd360b0 Site Health: Use $wpdb->db_server_info() to retrieve database server type.
This updates an older fragment in `WP_Site_Health::prepare_sql_data()` to use a dedicated `$wpdb` method introduced later in WordPress 5.5 specifically for retrieving the database server information.

Follow-up to [44986], [47451].

Props hilayt24, mukesh27, Clorith, SergeyBiryukov.
Fixes #56484.

git-svn-id: https://develop.svn.wordpress.org/trunk@54065 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-04 14:38:05 +00:00
Sergey Biryukov
18acdb68f5 Tests: Restore @covers tags for PHP polyfill tests in phpunit/tests/compat/.
These tags were previously removed to avoid notices when generating the code coverage report on PHP versions where these functions are natively available and not user-defined:
{{{
"@covers ::array_key_first" is invalid
"@covers ::array_key_last" is invalid
"@covers ::hash_hmac" is invalid
"@covers ::is_countable" is invalid
"@covers ::is_iterable" is invalid
"@covers ::mb_strlen" is invalid
"@covers ::mb_substr" is invalid
"@covers ::str_contains" is invalid
"@covers ::str_ends_with" is invalid
"@covers ::str_starts_with" is invalid
}}}

It has been pointed out that those tests do cover the WP implementation of those functions and should be marked as such with a `@covers` tag. The reason PHPUnit displays notices about it, is that code coverage is only run on PHP 7.4 instead of multiple PHP versions.

For those PHP versions which don't natively contain the function, the WP polyfill is being tested and should be seen as covered by tests. The reason the tests are also run on PHP versions in which the function already exists in PHP natively, is to make sure that the polyfill test expectations line up with the PHP native behaviour, even though at that point, they are no longer testing the WP polyfill, but the PHP native function.

With the above in mind, while those PHPUnit notices add some noise to the code coverage report, in this case, they should be ignored and the `@covers` tags should be brought back.

As a potential future enhancement, the code coverage script could be updated to run against the highest and lowest supported PHP versions and with some variations of extensions enabled or disabled to ensure those tests actually test the polyfills.

Follow-up to [51852], [52038], [52039], [52040], [54049], [54060].

Props jrf.
See #39265, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54064 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-03 14:45:20 +00:00
Jb Audras
53a5e4f0ac Docs: Use third-person singular verbs for various function descriptions, as per docblocks standards.
This addresses various files modified in changeset [54062].

See #55646.


git-svn-id: https://develop.svn.wordpress.org/trunk@54063 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-02 06:56:12 +00:00
Jb Audras
991dc2a5cc Coding Standards: Use a consistent markup for line break tags across Core.
This changeset replaces `<br/>` with `<br />` on various places, as per WordPress Coding Standards.
See https://developer.wordpress.org/coding-standards/wordpress-coding-standards/html/#self-closing-elements

Props haritpanchal, costdev, audrasjb.
Fixes #56457.


git-svn-id: https://develop.svn.wordpress.org/trunk@54062 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-02 06:49:17 +00:00
Sergey Biryukov
1f0289d890 Tests: Simplify and correct get_term_link() and get_edit_term_link() tests:
* Some assertions were unnecessarily duplicated. They aim to test the function behavior both when passing a term ID and term object, however that is already handled via the `$use_id` parameter of the `get_term()` helper in the same test class. The data providers already supply test cases both with a term ID and term object, so there is no need for a second assertion or a whole second test method with a term object.
* One `get_term_feed_link()` test was unnecessarily skipped half of the time, when term object was passed instead of term ID. Instead, it can use a dedicated data provider and avoid skipping.

Includes:
* Using more descriptive test method names to clarify the intention of the tests.
* Some documentation updates for clarity.

Follow-up to [52180], [52255], [52258], [52305], [53833], [53836].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54061 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-02 01:14:29 +00:00
Sergey Biryukov
8b106a9e54 Tests: Add @coversNothing tag for PHP polyfill tests in phpunit/tests/compat/.
The `@covers` tags for these tests were previously removed to avoid notices when generating the code coverage report on PHP versions where these functions are natively available and not user-defined:
{{{
"@covers ::array_key_first" is invalid
"@covers ::array_key_last" is invalid
"@covers ::hash_hmac" is invalid
"@covers ::is_countable" is invalid
"@covers ::is_iterable" is invalid
"@covers ::mb_strlen" is invalid
"@covers ::mb_substr" is invalid
"@covers ::str_contains" is invalid
"@covers ::str_ends_with" is invalid
"@covers ::str_starts_with" is invalid
}}}

Explicitly including a `@coversNothing` annotation in this case appears to be a more appropriate option than not including any annotation at all.

Follow-up to [51852], [52038], [52039], [52040], [54049].

See #39265, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54060 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-02 00:11:28 +00:00
Sergey Biryukov
34abc9e55c Tests: Correct the @covers tag in a WP_REST_URL_Details_Controller test for registered route.
`WP_REST_URL_Details_Controller::register_routes()` appears to be a better match than `WP_REST_Server::get_routes()`, and is also more consistent with other test classes.

Follow-up to [51973], [54056].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54059 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 23:11:34 +00:00
Sergey Biryukov
32ead26653 Tests: Explicitly mark empty REST API tests as not performing any assertions.
WordPress core test suite uses PHPUnit's `beStrictAboutTestsThatDoNotTestAnything` option set to true, which marks a test as risky when no assertions are performed.

REST API test classes have some empty tests for non-implemented methods because these test classes extend the abstract `WP_Test_REST_Controller_Testcase` class, which requires several methods to be implemented that don't necessarily make sense for all REST API routes.

As these tests are intentionally empty, they were previously marked as skipped, so that they are not reported as risky.

This commit aims to further reduce noise in the test suite and effectively ignores these empty tests altogether, which seems like a more appropriate option at this time.

The `@doesNotPerformAssertions` annotation can be reconsidered in the future when the tests are either removed as unnecessary or updated to actually perform assertions related to their behavior.

Follow-up to [40534], [41176], [41228], [53921].

See #40538, #41463, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54058 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 22:54:19 +00:00
Sergey Biryukov
c4594ec05b Tests: Correct the @covers tag in a test for strip_ws() utility function.
This addresses a notice when generating the code coverage report:
{{{
"@covers ::test_strip_ws" is invalid
}}}

Follow-up to [53686], [54049], [54050], [54051], [54052], [54055], [54056].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54057 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 19:06:19 +00:00
Sergey Biryukov
e962841c3a Tests: Correct the @covers tag in a WP_REST_URL_Details_Controller test for registered route.
This addresses a notice when generating the code coverage report:
{{{
"@covers WP_REST_URL_Details_Controller::get_routes" is invalid
}}}

The `WP_REST_URL_Details_Controller` class does not have a `get_routes()` method, `WP_REST_Server` does.

Follow-up to [51973].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54056 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 18:57:47 +00:00
Sergey Biryukov
36bc1177cd Tests: Correct the @covers tag in a WP_REST_Posts_Controller test for unique post slugs.
This addresses a notice when generating the code coverage report:
{{{
"@covers WP_REST_Request::create_item" is invalid
}}}

The `WP_REST_Request` class does not have a `create_item()` method, `WP_REST_Posts_Controller` is the class being tested here.

Includes fixing a typo in the test method name.

Follow-up to [53813].

See #52422, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54055 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 18:42:56 +00:00
Felix Arntz
14410c50da Site Health: Ensure persistent object cache check short-circuit filter also short-circuits multisite.
Follow up to [54053].

See #56040.


git-svn-id: https://develop.svn.wordpress.org/trunk@54054 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 17:45:38 +00:00
Felix Arntz
033d43e7d9 Site Health: Refine persistent object cache check tests.
This changeset makes these tests more reliable by having them less affected by external environment factors, fixing occasional failures.

See #56040.


git-svn-id: https://develop.svn.wordpress.org/trunk@54053 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 17:04:52 +00:00
Sergey Biryukov
36d14b8691 Tests: Correct the @covers tag syntax in a taxonomy_exists() test with non-string taxonomy.
This addresses a notice when generating the code coverage report:
{{{
"@covers :taxonomy_exists" is invalid
}}}

Follow-up to [53869].

See #56338, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54052 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 16:48:26 +00:00
Sergey Biryukov
191bf18e90 Tests: Correct some @covers tags in wp_html_split() and wptexturize() tests.
As `preg_split()` is not a user-defined function, it causes notices when generating the code coverage report:
{{{
"@covers ::preg_split" is invalid
}}}

Instead, it appears that the intention was to test the performance of these WordPress functions:

* `get_html_split_regex()`
* `_get_wptexturize_split_regex()`
* `_get_wptexturize_shortcode_regex()`

Follow-up to [34761], [53562].

See #39265, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54051 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 16:40:33 +00:00
Sergey Biryukov
427f1676af Tests: Correct the @covers tags in WP::send_headers() tests for feeds.
As this is a class method and not a global function, the correct annotation syntax is `@covers WP::send_headers`.

Follow-up to [53233].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54050 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 16:21:46 +00:00
Sergey Biryukov
3fe5b93277 Tests: Remove @covers tags for native PHP functions in phpunit/tests/compat/.
As these are not user-defined functions, they cause notices when generating the code coverage report:
{{{
"@covers ::array_key_first" is invalid
"@covers ::array_key_last" is invalid
"@covers ::hash_hmac" is invalid
"@covers ::is_countable" is invalid
"@covers ::is_iterable" is invalid
"@covers ::mb_strlen" is invalid
"@covers ::mb_substr" is invalid
"@covers ::str_contains" is invalid
"@covers ::str_ends_with" is invalid
"@covers ::str_starts_with" is invalid
}}}

Follow-up to [51852], [52038], [52039], [52040].

See #39265, #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54049 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 16:03:08 +00:00
Jonathan Desrosiers
ef326a6545 Script Loader: Allow a priority to be passed to wp_enqueue_block_support_styles().
`wp_enqueue_block_support_styles()` attaches inline styles to the `wp_head` or `wp_footer` actions. This adds a priority parameter to the function to allow the styles to be given a loading order when necessary.

Props bernhard-reiter, ramonopoly.
See #56467.

git-svn-id: https://develop.svn.wordpress.org/trunk@54048 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 15:43:25 +00:00
Sergey Biryukov
3909611f9a Site Health: Some documentation and test improvements for WP_Site_Health:
* Add a `@coversDefaultClass` annotation to address `@covers ::get_test_page_cache" is invalid` notices.
* Rename data providers to start with the `data_` prefix and match the test method names, for consistency.
* Move data providers next to the test methods they are used in.
* Move `::get_test_page_cache()` closer to `::get_test_persistent_object_cache()`, for a bit more predictable placement.
* Fix a typo in `::get_test_persistent_object_cache()` description.

Follow-up to [53955], [54043], [54044], [54045].

See #56041.

git-svn-id: https://develop.svn.wordpress.org/trunk@54047 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 15:26:29 +00:00
Jb Audras
08057c8cc5 Twenty Twenty: Improve word wrap in comments required message.
Because `.comments-notes` and `.logged-in-as` paragraphs are centered in Twenty Twenty, words were wrapping poorly to the next line, and even more often with "Edit your profile" displayed as visible text (see [53796]). This changeset ensures the required message is displayed on a new line.

Follow-up to [53796].

Props sabernhardt, audrasjb, mukesh27, nidhidhandhukiya.
Fixes #56397.


git-svn-id: https://develop.svn.wordpress.org/trunk@54046 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 06:10:43 +00:00
Sergey Biryukov
3a730ec57c Tests: Increase the time difference for the expires header in Site Health page cache tests.
This aims to avoid a race condition in the Code Coverage Report, which takes longer than 10 minutes to run, and by the time the page cache test runs, the `expires` header that is supposed to be in the future is already in the past.

Follow-up to [54043].

Props Clorith, davidbaumwald, flixos90, desrosj, SergeyBiryukov.
See #56041.

git-svn-id: https://develop.svn.wordpress.org/trunk@54045 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 01:34:21 +00:00
Sergey Biryukov
1006729247 Site Health: Minor i18n cleanup in page cache and persistent object cache tests.
Includes:
* Moving leading and trailing spaces out of a translatable string.
* Using the established format for translator comments.
* Using a consistent typography for the apostrophe.

Follow-up to [53955], [54043].

See #56041.

git-svn-id: https://develop.svn.wordpress.org/trunk@54044 602fd350-edb4-49c9-b593-d223f7449a82
2022-09-01 00:17:02 +00:00
Felix Arntz
6ff5bf856a Site Health: Introduce page cache check.
This changeset adds a new `page_cache` check which determines whether the site uses a full page cache, and in addition assesses the server response time. If no page cache is present and the server response time is slow, the check will suggest use of a page cache.

A few filters are included for customization of the check:
* `site_status_good_response_time_threshold` filters the number of milliseconds below which the server response time is considered good. The default value is based on the `server-response-time` Lighthouse audit and can be altered using this filter.
* `site_status_page_cache_supported_cache_headers` filters the map of supported cache headers and their callback to determine whether it was a cache hit. The default list includes commonly used cache headers, and it is filterable to support e.g. additional cache headers used by specific vendors.

Note that due to the nature of this check it is only run in production environments.

Props furi3r, westonruter, spacedmonkey, swissspidy, Clorith.
Fixes #56041.


git-svn-id: https://develop.svn.wordpress.org/trunk@54043 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-31 22:44:04 +00:00
Felix Arntz
b6290a3dbf Site Health: Update persistent object cache check documentation URL.
The anchor for the relevant documentation section had changed since the original code had been written.

Props furi3r.
See #56040.


git-svn-id: https://develop.svn.wordpress.org/trunk@54042 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-31 22:17:51 +00:00
Sergey Biryukov
4610a4b22c Tests: Use correct post_author value in WP_Test_REST_Attachments_Controller.
The `$editor_id` property is declared as static, so can only be approached as static, even when used within the same class in which the property is declared.

Using non-static access will result in `null`. See: https://3v4l.org/93HQL

This PHP notice was hidden so far, due to the existence of magic methods in the `WP_UnitTestCase_Base` class.

All the same, the magic methods as they were, would also return `null` for this property. All in all, the attachment being created for this test would never get the correct `post_author`.

Fixed by using static access to approach the static property.

This bug was discovered while fixing (removing) the magic methods in the `WP_UnitTestCase_Base` class in an effort to improve compatibility with PHP 8.2.

Follow-up to [38832].

Props jrf, costdev, johnbillion.
See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54041 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-31 16:15:46 +00:00
Sergey Biryukov
7f08fac299 Tests: Correctly back up and restore theme directories in Tests_Theme.
In the `set_up()` method, a copy would be made of the original value of the global `$wp_theme_directories` variable, with the intention to restore that original value in the `tear_down()` method after running each test. Unfortunately, this was not implemented correctly.

* The backup is made to a function local variable in `set_up()` and not stored somewhere where it is accessible from the `tear_down()` method.
* The restoring then references a non-existent property to restore, which would effectively set the `$wp_theme_directories` global to `null`.

Fixed by declaring and using a private property to store the original `$wp_theme_directories` value.

This bug was discovered while fixing (removing) the magic methods in the `WP_UnitTestCase_Base` class in an effort to improve compatibility with PHP 8.2.

Follow-up to [38907].

Props jrf, costdev, johnbillion, swissspidy.
See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@54040 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-31 16:02:05 +00:00
Jonathan Desrosiers
69b9ecc54e Build/Test Tools: Correct the context variable being used when auto-retrying failed and cancelled workflows.
The correct variable here is `github.run_attempt`, which represents the unique number for each attempt of a particular workflow run in a repository.

The `github.run_number` currently being used represents the unique number for each run of a particular workflow in a repository.

Follow up to [53947].

Fixes #56407.

git-svn-id: https://develop.svn.wordpress.org/trunk@54039 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-31 14:29:22 +00:00
Sergey Biryukov
843c27e6f9 Coding Standards: Use more consistent formatting in wp-includes/class-json.php.
As an adopted library that does not follow the WordPress Coding Standards, the file ended with a mix of tab and spaces as part of maintenance updates over the years.

This commit standardizes on spaces for now, to bring some consistency while minimizing the number of changes.

Includes moving all the declared properties to the top of the class.

Follow-up to [11875], [11877], [23376], [32990], [46377], [54037].

See #55647.

git-svn-id: https://develop.svn.wordpress.org/trunk@54038 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-31 13:39:33 +00:00
Sergey Biryukov
78fc3cdd91 Code Modernization: Explicitly declare all properties in Services_JSON.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

There are a number of ways to mitigate this:
* If it is an accidental typo for a declared property: fix the typo.
* For known properties: declare them on the class.
* For unknown properties: add the magic `__get()`, `__set()`, et al. methods to the class or let the class extend `stdClass` which has highly optimized versions of these magic methods built in.
* For unknown ''use'' of dynamic properties, the `#[AllowDynamicProperties]` attribute can be added to the class. The attribute will automatically be inherited by child classes.

In this case, the `$use` property, as set in the class constructor, falls in the “known property” category.

Reference: [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties].

Follow-up to [11875], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936], [53937], [53938], [53942], [53945], [53948], [53949], [53952], [53953], [53954], [53957].

Props jrf, antonvlasenko, costdev.
See #56033.

git-svn-id: https://develop.svn.wordpress.org/trunk@54037 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-31 13:05:11 +00:00
Greg Ziółkowski
20e024dd29 Tests: Increase coverage for translations applied to theme.json
Ensures that translations are correctly applied to the `title` field in the `theme.json` and all style variations located in the them inside the `styles` folder.

Follow-up #55495, [53038].
See also #54336.



git-svn-id: https://develop.svn.wordpress.org/trunk@54036 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-31 10:11:30 +00:00