Commit Graph

46162 Commits

Author SHA1 Message Date
Sergey Biryukov
af466c7620 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.
Built from https://develop.svn.wordpress.org/trunk@54052


git-svn-id: http://core.svn.wordpress.org/trunk@53611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 16:50:07 +00:00
Sergey Biryukov
6600b5b5f6 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.
Built from https://develop.svn.wordpress.org/trunk@54051


git-svn-id: http://core.svn.wordpress.org/trunk@53610 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 16:42:08 +00:00
Sergey Biryukov
426274d7a8 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.
Built from https://develop.svn.wordpress.org/trunk@54050


git-svn-id: http://core.svn.wordpress.org/trunk@53609 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 16:23:08 +00:00
Sergey Biryukov
5db90313f1 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.
Built from https://develop.svn.wordpress.org/trunk@54049


git-svn-id: http://core.svn.wordpress.org/trunk@53608 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 16:05:09 +00:00
desrosj
e69d717f37 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.
Built from https://develop.svn.wordpress.org/trunk@54048


git-svn-id: http://core.svn.wordpress.org/trunk@53607 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 15:45:09 +00:00
Sergey Biryukov
acf94cb859 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.
Built from https://develop.svn.wordpress.org/trunk@54047


git-svn-id: http://core.svn.wordpress.org/trunk@53606 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 15:28:16 +00:00
audrasjb
a05073bbdd 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.

Built from https://develop.svn.wordpress.org/trunk@54046


git-svn-id: http://core.svn.wordpress.org/trunk@53605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 06:12:15 +00:00
Sergey Biryukov
d6bb75e7c7 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.
Built from https://develop.svn.wordpress.org/trunk@54045


git-svn-id: http://core.svn.wordpress.org/trunk@53604 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 01:36:13 +00:00
Sergey Biryukov
7a94e6c200 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.
Built from https://develop.svn.wordpress.org/trunk@54044


git-svn-id: http://core.svn.wordpress.org/trunk@53603 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 00:19:18 +00:00
Felix Arntz
fab7a3bb92 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.

Built from https://develop.svn.wordpress.org/trunk@54043


git-svn-id: http://core.svn.wordpress.org/trunk@53602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-31 22:46:11 +00:00
Felix Arntz
7322419ced 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.

Built from https://develop.svn.wordpress.org/trunk@54042


git-svn-id: http://core.svn.wordpress.org/trunk@53601 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-31 22:19:12 +00:00
Sergey Biryukov
ee9fd97241 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.
Built from https://develop.svn.wordpress.org/trunk@54041


git-svn-id: http://core.svn.wordpress.org/trunk@53600 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-31 16:17:13 +00:00
Sergey Biryukov
1d71ca9ed8 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.
Built from https://develop.svn.wordpress.org/trunk@54040


git-svn-id: http://core.svn.wordpress.org/trunk@53599 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-31 16:04:15 +00:00
desrosj
2534bb6554 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.
Built from https://develop.svn.wordpress.org/trunk@54039


git-svn-id: http://core.svn.wordpress.org/trunk@53598 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-31 14:31:12 +00:00
Sergey Biryukov
76b0575b97 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.
Built from https://develop.svn.wordpress.org/trunk@54038


git-svn-id: http://core.svn.wordpress.org/trunk@53597 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-31 13:41:08 +00:00
Sergey Biryukov
b251f368e0 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.
Built from https://develop.svn.wordpress.org/trunk@54037


git-svn-id: http://core.svn.wordpress.org/trunk@53596 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-31 13:07:11 +00:00
gziolo
f07974056f 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.


Built from https://develop.svn.wordpress.org/trunk@54036


git-svn-id: http://core.svn.wordpress.org/trunk@53595 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-31 10:13:13 +00:00
Sergey Biryukov
0337f74a34 Plugins: Escape output in error messages.
Props tykoted, paulkevan, peterwilsoncc.
Built from https://develop.svn.wordpress.org/trunk@53960


git-svn-id: http://core.svn.wordpress.org/trunk@53519 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-30 15:18:17 +00:00
Sergey Biryukov
a7edef876d General: Ensure bookmark query limits are numeric.
Props paulkevan, xknown.
Built from https://develop.svn.wordpress.org/trunk@53959


git-svn-id: http://core.svn.wordpress.org/trunk@53518 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-30 15:17:08 +00:00
Sergey Biryukov
da3f89485a Posts, Post Types: Escape output within the_meta().
Convert markup to entities when displaying on the front end. Deprecates `the_meta()` in favor of `get_post_meta()`.

Props tykoted, martinkrcho, xknown, dd32, peterwilsoncc, paulkevan, timothyblynjacobs.

Built from https://develop.svn.wordpress.org/trunk@53958


git-svn-id: http://core.svn.wordpress.org/trunk@53517 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-30 15:15:09 +00:00
Sergey Biryukov
fa76bbbb0b Code Modernization: Explicitly declare all properties in Gettext_Translations.
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 `$_nplurals` and `$_gettext_select_plural_form` properties, both being set in the class constructor, fall in the “known property” category.

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

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

Props jrf, antonvlasenko, costdev.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53957


git-svn-id: http://core.svn.wordpress.org/trunk@53516 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-30 13:57:15 +00:00
noisysocks
1d55913400 Editor: Ensure that timezone.offset passed to @wordpress/date is a float
Fixes inconsistent type of `timezone.offset` passed to `@wordpress/date`. It
should always be a float, never a string.

Props talldanwp.
Fixes #56459.

Built from https://develop.svn.wordpress.org/trunk@53956


git-svn-id: http://core.svn.wordpress.org/trunk@53515 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-30 01:04:12 +00:00
Felix Arntz
09369981e1 Site Health: Introduce persistent object cache check.
This changeset adds a new `persistent_object_cache` check which determines whether the site uses a persistent object cache, and if not, recommends it if it is beneficial for the site. A support resource to learn more about object caching has been created and is linked in the check.

A few filters are included for customization of the check, aimed primarily at hosting providers to provide more specific information in regards to their environment:

* `site_status_persistent_object_cache_url` filters the URL to learn more about object caching, so that e.g. a hosting-specific object caching support resource could be linked.
* `site_status_persistent_object_cache_notes` filters the notes added to the check description, so that more fine tuned information on object caching based on the environment can be provided.
* `site_status_should_suggest_persistent_object_cache` is a short-circuit filter which allows using entirely custom logic to determine whether a persistent object cache would make sense for the site.
* `site_status_persistent_object_cache_thresholds` filters the thresholds in the default logic to determine whether a persistent object cache would make sense for the site, which is based on the amount of data in the database.

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

Props furi3r, tillkruss, spacedmonkey, audrasjb, Clorith.
Fixes #56040.

Built from https://develop.svn.wordpress.org/trunk@53955


git-svn-id: http://core.svn.wordpress.org/trunk@53514 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-29 16:54:12 +00:00
Sergey Biryukov
644d8cd6f1 Code Modernization: Explicitly declare all properties in POMO_Reader et al.
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 `$is_overloaded` property and the `$_f` property fall in the “known property” category. In both cases, these are being set in the `__construct()` method of the class they apply to.

The `$_post` property appears to be a typo however. The `$_post` property looks to be unused, while there is an undeclared integer `$_pos` (“position”) property, which is used throughout the class and used by the child classes.

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

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

Props jrf, antonvlasenko, costdev.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53954


git-svn-id: http://core.svn.wordpress.org/trunk@53513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-29 14:07:11 +00:00
Sergey Biryukov
2b8a847051 Code Modernization: Explicitly declare WP-specific property in WP_SimplePie_File.
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 `$timeout` property falls in the “known property” category.

Note: In contrast to the other properties being set in the constructor, this property is not declared on the parent class, so not inherited.

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

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

Props jrf, antonvlasenko, costdev.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53953


git-svn-id: http://core.svn.wordpress.org/trunk@53512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-29 13:19:12 +00:00
Sergey Biryukov
a0163f91d4 Code Modernization: Explicitly declare all properties in WP_Ajax_Upgrader_Skin.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this case, the `$plugin_info` and `$theme_info` properties are set in `Plugin_Upgrader::bulk_upgrade()` and `Theme_Upgrader::bulk_upgrade()` specifically.

The `Bulk_Plugin_Upgrader_Skin` class and the `Bulk_Theme_Upgrader_Skin` class both already allow for this, but the `wp_ajax_update_plugin()` and `wp_ajax_update_theme()` functions also call the `*_Upgrader::bulk_upgrade()` methods, so the `WP_Ajax_Upgrader_Skin` class also needs to have these properties explicitly declared.

Includes adding proper DocBlocks for the pre-existing properties in the `Bulk_Plugin_Upgrader_Skin` and the `Bulk_Theme_Upgrader_Skin` classes.

Follow-up to [13686], [37714], [38199], [42677], [42873], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936], [53937], [53938], [53942], [53945], [53948], [53949].

Props jrf, costdev.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53952


git-svn-id: http://core.svn.wordpress.org/trunk@53511 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-29 12:46:10 +00:00
Clorith
00fb102dae Site Health: Improve the fatal error handling text in multisite scenarios.
The fatal error handler is responsible for providing a more user-friendly page to visitors if a site would normally encounter a fatal error, informing them of the next steps to access recovery mode (where applicable).

Those next steps would be to check the email address for the site administrator, but this was only the case for single site installs; In a multisite scenario, no email is sent.

This changes the text to account for that, still informing site administrators to check their email if it is a single site, but for multisite directing users to reach out to their site administrator for further assistance, so that they may take appropriate action.

Props rkaiser0324, Clorith.
Fixes #48929.
Built from https://develop.svn.wordpress.org/trunk@53951


git-svn-id: http://core.svn.wordpress.org/trunk@53510 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-28 19:51:09 +00:00
Clorith
7518c75208 Site Health: Don't show issue groups unless there are items in them.
The Site Health Status screen groups issues into the categories `good`, `recommended`, and `critical` when displaying them to the end user.

Initially, this screen would show `0 critical issues` while the checks were being performed, and then hide the group if no issues were discovered after all checks had completed, this not being an ideal user experience, as it is a better experience to show areas that have content, instead of hiding them after the fact.

This change makes the groups hidden by default, and also changes the logic to see if a group should be displayed when an item is added to the list (as opposed to the previous approach which only did this check once every single test had completed).

Props DavidAnderson, palmiak.
Fixes #47222.
Built from https://develop.svn.wordpress.org/trunk@53950


git-svn-id: http://core.svn.wordpress.org/trunk@53509 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-28 19:17:11 +00:00
Sergey Biryukov
6f9dd431da Code Modernization: Explicitly declare all properties in WP_Test_Stream.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

The `WP_Test_Stream` class is a stream wrapper for use in the tests and must comply with the PHP requirements for such stream wrappers.

In this case, the class did not declare the required public `$context` property, which led to deprecation notices about the property being dynamically created from the `Tests_Image_Editor_Imagick::test_streams()` and `Tests_Image_Meta::test_stream()` tests.

Reference: [https://www.php.net/manual/en/class.streamwrapper.php#streamwrapper.props PHP Manual: streamWrapper: Properties].

Follow-up to [49230], [50771], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936], [53937], [53938], [53942], [53945], [53948].

Props jrf, antonvlasenko.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53949


git-svn-id: http://core.svn.wordpress.org/trunk@53508 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-28 10:11:13 +00:00
Sergey Biryukov
13f618c449 Code Modernization: Explicitly declare all properties created in set_up() methods of various test classes.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In each of the cases included in this commit, one or more properties are dynamically created in the `set_up()` method of the test class. This commit explicitly declares these properties.

As these properties are being declared on test classes, they are marked as private. Even though the original dynamic property was public, this should not be considered a backward compatibility break as this only involves test classes.

Notes:
* As these properties receive assignments during test runs or a one-time assignment, but the assignment uses a function call or variable access, these properties cannot be changed to class constants, but they should be declared explicitly as properties on the class.
* In `Tests_Theme_CustomHeader`, the `$customize_manager` property is given a default value of `null`, same as it was already being reset to `null` in the `tear_down()` method.
* In `Tests_Privacy_wpPrivacyProcessPersonalDataExportPage` and `Tests_Privacy_wpPrivacyGeneratePersonalDataExportFile` classes, the property name had a leading `_` underscore. This is an outdated PHP 4 practice to indicate a private property. As PHP 4 is no longer supported, the property has been renamed to `$orig_error_level`.
* Along the same lines, in `Tests_Menu_Walker_Nav_Menu`, the property name also had a leading `_` underscore. The property has been renamed to `$orig_wp_nav_menu_max_depth`.
* In the `Tests_Shortcode` class, three properties were already being (re)set in the `set_up() `method, while three others were being set for most tests via the `shortcode_test_shortcode_tag()` method or in the tests themselves. It is ensured now that all six properties are given their initial `null` value in the `set_up()` method and are explicitly declared.

Additionally:
* In the `Tests_User_Session` class, the `set_up()` method is incorrect. No assertions should be executed in fixture methods, but the `set_up()` method contains two assertions. This has not been addressed yet as it is outside the scope of this commit, but should be addressed at a later point in time.

Follow-up to [12/tests], [218/tests], [374/tests], [384/tests], [986/tests], [1106/tests], [1239/tests], [28704], [29221], [29347], [32648], [36519], [37953], [38832], [40142], [40825], [43584], [43768], [44786], [45141], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936], [53937], [53938], [53942], [53945].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53948


git-svn-id: http://core.svn.wordpress.org/trunk@53507 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-27 12:32:12 +00:00
desrosj
ca27343248 Build/Test Tools: Automatically rerun a workflow the first time it fails.
There are several common reoccurring issues that sometimes cause GitHub Action workflows to fail (connection timeouts to WordPress.org or the Docker container registry, `npm install` failures, Chromium issues, etc.). Except when there are service level outages, most of these issues can be resolved by simply rerunning the workflow.

This introduces a new step within each of Core’s GitHub Action workflows that attempts to rerun the failed jobs within the workflow that encountered a failure if they are running for the first time. Since a workflow is not allowed to restart itself, a new `failed-workflow.yml` callable workflow is being introduced.

Other related adjustments in this changeset:
- The `actions/github-script` 3rd-party action is also now updated to the latest version (v6.2.0).
- A new secret, `GHA_WORKFLOW_DISPATCH`, has been introduced. This will replace the current one in use (`GHA_OLD_BRANCH_DISPATCH`) with a less specific name.

Props jorbin, desrosj.
Fixes #56407.
Built from https://develop.svn.wordpress.org/trunk@53947


git-svn-id: http://core.svn.wordpress.org/trunk@53506 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-26 19:21:11 +00:00
antpb
6a03ea5001 Coding Standards: Use strict comparisons in path_is_absolute().
This patch adjusts conditions to use strict comparisons when comparing `realpath()` in `path_is_absolute()`.

Props jrf.
See #36308.


Built from https://develop.svn.wordpress.org/trunk@53946


git-svn-id: http://core.svn.wordpress.org/trunk@53505 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-26 18:59:13 +00:00
Sergey Biryukov
893fd396da Code Modernization: Remove unused dynamic property in WP_Test_REST_Pages_Controller.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this case, it appears that the dynamically created `$has_setup_template` property is not actually used. It is unclear what the original intention was, but since it is undeclared and unused, it can be safely removed.

Follow-up to [38832], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936], [53937], [53938], [53942].

Props jrf, antonvlasenko.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53945


git-svn-id: http://core.svn.wordpress.org/trunk@53504 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-26 11:45:11 +00:00
Peter Wilson
ba9dd1d7d7 Cache API, Docs: Remove private delegation from cache priming functions.
Remove the private delegation from the following cache priming functions for various object types:

- `_prime_post_caches()`
- `_prime_term_caches()`
- `_prime_comment_caches()`
- `_prime_network_caches()`
- `_prime_site_caches()`
- `_get_non_cached_ids() `

Plugins and themes are now encouraged to use these functions to improve the performance of their code by reducing the number of database queries.

Props robinwpdeveloper, desrosj, SergeyBiryukov, mukesh27, costdev.
Fixes #56386.


Built from https://develop.svn.wordpress.org/trunk@53944


git-svn-id: http://core.svn.wordpress.org/trunk@53503 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-26 01:03:14 +00:00
mcsf
668a2ec9ff Block Patterns: Add new Footers category
Quoting poena from the ticket: "[...] To make it easier for users to find these
patterns, a new block pattern category should be added. The patterns have
already been built to include the new category, with the slug "footer" [to]
match the existing Headers category"

Props poena.

Fixes #56416.


Built from https://develop.svn.wordpress.org/trunk@53943


git-svn-id: http://core.svn.wordpress.org/trunk@53502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-25 15:42:10 +00:00
Sergey Biryukov
2a2a865310 Code Modernization: Explicitly declare all properties in various tests.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In each of the cases included in this commit, one or more individual tests set a property to allow a filter or action access to certain information.

This commit:
* Explicitly declares these properties and documents in which tests they are being used.
* Adds a reset to the default value of the property to a pre-existing `tear_down()` method or adds that method specifically for that purpose. This ensures that tests do not accidentally “taint” each other.

As these properties are being declared on test classes, they are marked as private. Even though the original dynamic property was public, this should not be considered a backward compatibility break as this only involves test classes.

Includes:
* In the `Tests_Post_Query` class, there were two tests assigning a value to an undeclared `$post_id` property, but subsequently not using the property, so those assignments should have been to a local variable (if they should be assignments at all).
* In the `Test_User_Capabilities` class, the property name had a leading `_` underscore. This is an outdated PHP 4 practice to indicate a private property. As PHP 4 is no longer supported, the leading underscore is removed from the property name.
* In the `Tests_User_Capabilities` class, an unused `$_role_test_wp_roles_role` property was declared somewhere in the middle of the class. That property is now removed in favor of `$_role_test_wp_roles_init`, which appears to be the intended name, previously misspelled.

Follow-up to [27294], [36277], [36750], [37712], [38571], [39082], [40290], [43049], [44628], [48328], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936], [53937], [53938].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53942


git-svn-id: http://core.svn.wordpress.org/trunk@53501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-25 15:36:13 +00:00
Peter Wilson
790e806e3f Query: Cache post ID database query within WP_Query.
Add object caching to the first database query in `WP_Query`, ie the database query for post IDs that match the desired result. Randomly ordered queries remain uncached as they are not intended to return consistent results.

Caching of ID queries is enabled by default, per the post object, term and meta caches.

Props spacedmonkey, aaroncampbell, batmoo, chriscct7, costdev, dd32, drewapicture, johnbillion, mukesh27, nacin, ocean90, peterwilsoncc, ryan, scribu, sergeybiryukov, tillkruss.
Fixes #22176.

Built from https://develop.svn.wordpress.org/trunk@53941


git-svn-id: http://core.svn.wordpress.org/trunk@53500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-25 04:23:13 +00:00
desrosj
105a3d9782 Build/Test Tools: Update third-party GitHub Actions to latest versions.
Updated actions:
- `actions/cache`
- `actions/github-script`
- `actions/setup-node`
- `bubkoo/welcome-action`
- `shivammathur/setup-php`
- `slackapi/slack-github-action`

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53940


git-svn-id: http://core.svn.wordpress.org/trunk@53499 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-24 16:32:13 +00:00
desrosj
a81704ed5f Docs: Correct typo in wp_maybe_clean_new_site_cache_on_update() parameter description.
Props kebbet.
See #55646.
Built from https://develop.svn.wordpress.org/trunk@53939


git-svn-id: http://core.svn.wordpress.org/trunk@53498 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-24 15:26:12 +00:00
Sergey Biryukov
c45366a8ce Code Modernization: Remove dynamic properties in Tests_Comment_Walker.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this test file, the `Tests_Comment_Walker::set_up()` method created a dynamic `$post_id` property, which should have been explicitly declared.

Along the same lines, the `Comment_Callback_Test::__construct()` method also assigned values to two undeclared properties.

This is now fixed by explicitly declaring the properties in both classes.

Includes renaming the `Comment_Callback_Test` class to `Comment_Callback_Test_Helper` as it does not contain any test methods and its only purpose is as a “helper” class for the `Tests_Comment_Walker::test_has_children()` test.

Follow-up to [28824], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936], [53937].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53938


git-svn-id: http://core.svn.wordpress.org/trunk@53497 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-24 14:05:13 +00:00
Sergey Biryukov
930975efaf Code Modernization: Remove dynamic properties in WP_UnitTestCase_Base.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this particular case, the `scandir()` method sets a dynamic `$matched_dirs` property, which is subsequently used in the `delete_folders()` method.

This commit removes the need for the property. Effectively, this changes the `scandir()` method to return an array of the matched directories instead of setting the property by using recursion in the method itself in an optimized manner.

Note the `array_merge()` not being in the loop itself, but at the very end of the function. This is for performance reasons, see [https://github.com/dseguy/clearPHP/blob/master/rules/no-array_merge-in-loop.md clearPHP: No array_merge() In Loops] for a more detailed explanation of this.

It has been verified in detail that the actual results of the previous version of the method and this version match, even when the paths passed are more complex and have deeper nested subdirectories.

Follow-up to [30658], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936].

Props jrf, johnbillion, markjaquith, SergeyBiryukov.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53937


git-svn-id: http://core.svn.wordpress.org/trunk@53496 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-24 13:51:12 +00:00
Sergey Biryukov
ecc308e729 Code Modernization: Remove dynamic properties in WP_Test_REST_Users_Controller.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In these particular cases, individual tests set a couple of properties (`$author_id`, `$post_id`) that are never used outside of the context of the test in which they are created.

In other words: these should never have been properties, but should be local variables instead.

Follow-up to [38832], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53936


git-svn-id: http://core.svn.wordpress.org/trunk@53495 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-24 13:20:13 +00:00
Sergey Biryukov
ede8eb333a Code Modernization: Remove dynamic properties in WP_Test_REST_Posts_Controller.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this particular case, the `test_create_update_post_with_featured_media()` method creates an attachment and writes the ID of the attachment to a dynamic (undeclared) property to be used as a flag to determine whether attachments need to be cleaned up after the test in the `tear_down()` method.

As the actual ''value'' of the property is irrelevant for the cleaning up and the property is realistically being used as a “flag”, this is now fixed as follows:

* Have an actual “flag” property declared with a descriptive name — `$attachments_created` — to make the code in the `tear_down()` more easily understandable.
* As for the actual ID of the attachment, save that to a test method local variable as that is the only place where it has any relevance.

Includes moving the `tear_down()` method up to be directly below the `set_up()` method.

Follow-up to [38832], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53935


git-svn-id: http://core.svn.wordpress.org/trunk@53494 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-24 13:11:13 +00:00
antpb
0406a3ffd7 Media: Account for Windows when normalizing file paths.
Previously, Windows paths in the `path_is_absolute` function resulted in incorrect URIs. This patch adjusts for forward slashes and adds tests for the `get_attached_file` function.
Props Whissi, SergeyBiryukov, desrosj, stevenlinx, birgire, davidbaumwald, costdev, peterwilsoncc, audrasjb, hellofromTonya, johnbillion.
Fixes #36308.


Built from https://develop.svn.wordpress.org/trunk@53934


git-svn-id: http://core.svn.wordpress.org/trunk@53493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-23 19:59:14 +00:00
Sergey Biryukov
69fe3c1aff Themes: Add support for Update URI header.
This allows third-party themes to avoid accidentally being overwritten with an update of a theme of a similar name from the WordPress.org Theme Directory.

Additionally, introduce the `update_themes_{$hostname}` filter, which third-party themes can use to offer updates for a given hostname.

If set, the `Update URI` header field should be a URI and have a unique hostname.

Some examples include:

* `https://wordpress.org/themes/example-theme/`
* `https://example.com/my-theme/`
* `my-custom-theme-name`

`Update URI: false` also works, and unless there is code handling the `false` hostname, the theme will never get an update notification.

If the header is present, the WordPress.org API will currently only return updates for the theme if it matches the following format:

* `https://wordpress.org/themes/{$slug}/`
* `w.org/theme/{$slug}`

If the header has any other value, the API will not return a result and will ignore the theme for update purposes.

Follow-up to [50921].

Props dd32, meloniq, costdev, audrasjb, DavidAnderson, markjaquith, DrewAPicture, mweichert, design_dolphin, filosofo, sean212, nhuja, JeroenReumkens, infolu, dingdang, joyously, earnjam, williampatton, grapplerulrich, markparnell, apedog, afragen, miqrogroove, rmccue, crazycoders, jdgrimes, damonganto, joostdevalk, jorbin, georgestephanis, khromov, GeekStreetWP, jb510, Rarst, juliobox, Ipstenu, mikejolley, Otto42, gMagicScott, TJNowell, GaryJ, knutsp, mordauk, nvartolomei, aspexi, chriscct7, benoitchantre, ryno267, lev0, gregorlove, dougwollison, leemon, SergeyBiryukov.
See #14179, #23318, #32101.
Built from https://develop.svn.wordpress.org/trunk@53933


git-svn-id: http://core.svn.wordpress.org/trunk@53492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-23 17:48:15 +00:00
gziolo
972e7f2a95 Editor: Backport bug fixes from Gutenberg into Core for WP 6.0.2 RC
This brings a new version of the Gutenberg code from the [https://github.com/WordPress/gutenberg/tree/wp/6.0 wp/6.0 branch] into core.

- @wordpress/block-directory@3.4.14
 - @wordpress/block-editor@8.5.10
 - @wordpress/block-library@7.3.14
 - @wordpress/customize-widgets@3.3.14
 - @wordpress/edit-post@6.3.14
 - @wordpress/edit-site@4.3.14
 - @wordpress/edit-widgets@4.3.14
 - @wordpress/editor@12.5.10
 - @wordpress/format-library@3.4.10
 - @wordpress/reusable-blocks@3.4.10
 - @wordpress/widgets@2.4.10

Props SergeyBiryukov.
Fixes #56414.


Built from https://develop.svn.wordpress.org/trunk@53929


git-svn-id: http://core.svn.wordpress.org/trunk@53488 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-23 15:42:33 +00:00
Sergey Biryukov
08f5675e1c Editor: Ensure get_block_templates() returns unique templates or template parts.
The function was using the `array_column()` PHP function on an array of objects, which works as expected on PHP 7 or later, but not on PHP 5.6.

This resulted in customized templates being listed multiple times on the Templates and Template Parts screens, and being repeatedly added between lists when switching between the screens.

The issue is now resolved by replacing `array_column()` with the `wp_list_pluck()` WordPress core function, which provides consistent behavior beetween PHP versions.

Reference: [https://github.com/php/php-src/blob/PHP-7.0.0/UPGRADING#L626 PHP 7.0 Upgrade Notes: array_column()].

Props uofaberdeendarren, antonvlasenko, ironprogrammer, jonmackintosh, costdev, hellofromTonya, swissspidy, rudlinkon.
Fixes #56271.
Built from https://develop.svn.wordpress.org/trunk@53927


git-svn-id: http://core.svn.wordpress.org/trunk@53486 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-23 14:52:12 +00:00
Sergey Biryukov
cf54dd1b24 Help/About: Improve vertical alignment in the Additional Design Tools section.
This makes a transparent circle SVG smaller by removing empty space to match the height of other images in the same section, so that all three columns are aligned correctly.

Follow-up to [53339].

Props sabernhardt, weboccults, ironprogrammer, webcommsat, marybaum, oglekler.
Fixes #56210.
Built from https://develop.svn.wordpress.org/trunk@53924


git-svn-id: http://core.svn.wordpress.org/trunk@53483 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-23 13:48:10 +00:00
Sergey Biryukov
dabe0df577 Build/Test Tools: Enable running the tests on PHP 8.2.
PHP 8.2 is expected to be released at the end of November 2022.

Enabling the tests to run in CI on PHP 8.2 allows WordPress core to start getting ready.

As an interim measure, while working through the PHP 8.1 and 8.2 issues, builds against these PHP versions are allowed to fail, so that they don't block PR merges in the Gutenberg project.

Notes:
* The `composer install` command for PHP 8.1 was still using the `--ignore-platform-reqs` option, while that has not been needed anymore for quite a while, so the condition is now reused for PHP 8.2.
* The `--ignore-platform...` option used for the install is now made more specific:
 * Composer 2.0 added a `--ignore-platform-req=...` option to selectively ignore platform requirements.
 * Composer 2.2 then added the ability to only ignore the upper bound of platform requirements by adding the `+` sign.
* Xdebug-related tests will not be run on PHP 8.2 at this time as the Docker image for PHP 8.2 does not contain Xdebug yet. Once a stable release of Xdebug 3.2.0 is available, it can be added to the Docker image and the test step can then be enabled for PHP 8.2.

References:

* [https://github.com/WordPress/wpdev-docker-images/pull/87 wpdev-docker-images PR #87: Add PHP 8.2 containers]
* [https://github.com/composer/composer/releases/tag/2.0.0 Composer 2.0 changelog]
* [https://github.com/composer/composer/releases/tag/2.2.0 Composer 2.2 changelog]
* [https://xdebug.org/announcements/2022-07-20 Xdebug 3.2.0alpha1 release notes]
* [https://xdebug.org/announcements/2022-07-25 Xdebug 3.2.0alpha2 release notes]

Follow-up to [49077], [49162], [50299], [51588], [51604].

Props jrf, desrosj.
See #56009.
Built from https://develop.svn.wordpress.org/trunk@53922


git-svn-id: http://core.svn.wordpress.org/trunk@53481 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-23 13:09:12 +00:00
Sergey Biryukov
16ed809c04 Tests: Consistently skip tests for non-implemented methods in REST API test classes.
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.

Some of these empty tests were already marked as skipped, but not in a consistent manner. Since skipping these tests is intentional for the time being, this commit aims to bring some consistency and adjust them all to be more accurately reported as skipped instead of risky.

The skipping 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].

Props Mte90, tomepajk, johnbillion, zieladam, SergeyBiryukov.
See #40538, #41463, #55652.
Built from https://develop.svn.wordpress.org/trunk@53921


git-svn-id: http://core.svn.wordpress.org/trunk@53480 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-22 22:44:14 +00:00