Commit Graph

19976 Commits

Author SHA1 Message Date
Joe McGill
8f390b309a Editor: Refresh nones for metaboxes after reauthentication.
This fixes an issue where metaboxes fail to save after a session expires and a user logs in again via the heartbeat API.

Props LinSoftware.
Fixes #52584.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53681 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-11 20:46:10 +00:00
TimothyBlynJacobs
ef6619d68e REST API: Use helper functions for building routes in more places.
Props get_dave, spacedmonkey.
Fixes #56472.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53680 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-11 18:55:09 +00:00
Aaron Jorbin
a99adb76ed Customize: Use Semantically correct function
Functionally, `add_action` and `add_filter` are essentially the same, but semantically they are not.

Props Drivingralle.
Fixes #56285.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-11 18:18:10 +00:00
Sergey Biryukov
1a37650766 Docs: Correct @global tags in WP_User_Query::prepare_query().
* `$blog_id` global was replaced with `get_current_blog_id()` and is no longer used directly.
* `$wp_roles` global usage was previously undocumented.

Follow-up to [32637], [38457], [51943].

Props shoaibkarimali.
Fixes #56543.
Built from https://develop.svn.wordpress.org/trunk@54119


git-svn-id: http://core.svn.wordpress.org/trunk@53678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-11 13:13:12 +00:00
Sergey Biryukov
70c0f6f0e1 Editor: Backport Elements API updates.
This commit backports the original PRs from Gutenberg repository:

* [https://github.com/WordPress/gutenberg/pull/40260 #40260 Add support for button elements to theme.json]
* [https://github.com/WordPress/gutenberg/pull/40889 #40889 Theme Json: Don't output double selectors for elements inside blocks]
* [https://github.com/WordPress/gutenberg/pull/41140 #41140 Global Styles: Add support for caption elements]
* [https://github.com/WordPress/gutenberg/pull/41160 #41160 Global Styles: Load block CSS conditionally]
* [https://github.com/WordPress/gutenberg/pull/41240 #41240 Global Styles: Button Element: update button element selector]
* [https://github.com/WordPress/gutenberg/pull/41335 #41335 Duotone: Fix CSS Selectors rendered by theme.json duotone/filter settings for blocks on public pages]
* [https://github.com/WordPress/gutenberg/pull/41446 #41446 Block styles: Account for style block nodes that have no name]
* [https://github.com/WordPress/gutenberg/pull/41696 #41696 Global Styles: Allow references to values in other locations in the tree]
* [https://github.com/WordPress/gutenberg/pull/41753 #41753 Elements: Add an API make it easier to get class names]
* [https://github.com/WordPress/gutenberg/pull/41786 #41786 Support pseudo selectors on elements in theme json]
* [https://github.com/WordPress/gutenberg/pull/41822 #41822 Elements: Button - Fix element selectors]
* [https://github.com/WordPress/gutenberg/pull/41981 #41981 Global Styles: Add support for heading elements]
* [https://github.com/WordPress/gutenberg/pull/42072 #42072 Fix link element hover bleeding into button element default styles]
* [https://github.com/WordPress/gutenberg/pull/42096 #42096 Add visited to link element allowed pseudo selector list]
* [https://github.com/WordPress/gutenberg/pull/42669 #42669 Link elements: Add a :where selector to the :not to lower specificity]
* [https://github.com/WordPress/gutenberg/pull/42776 #42776 Theme JSON: Add a static $blocks_metadata data definition to the Gutenberg instance of WP_Theme_JSON]
* [https://github.com/WordPress/gutenberg/pull/43088 #43088 Pseudo elements supports on button elements]
* [https://github.com/WordPress/gutenberg/pull/43167 #43167 Theme_JSON: Use existing append_to_selector for pseudo elements]
* [https://github.com/WordPress/gutenberg/pull/43988 #43988 Styles API: Fixed selectors for nested elements]

Props onemaggie, bernhard-reiter, cbravobernal, mmaattiiaass, scruffian, andraganescu, dpcalhoun, get_dave, Mamaduka, SergeyBiryukov.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54118


git-svn-id: http://core.svn.wordpress.org/trunk@53677 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-10 12:38:12 +00:00
Sergey Biryukov
9ba0095255 KSES: Allow assigning values to CSS variables.
The `safecss_filter_attr()` function allows using custom CSS variables like `color: var(--color)`. However, it did not allow assigning values to CSS variables like `--color: #F00`, which is common in Global Styles and Gutenberg.

This commit adds support for assigning values to CSS variables, so that the function can be used consistently in Global Styles and the future Style Engine in Gutenberg.

Follow-up to [50923], [54100].

Props aristath, ramonopoly, SergeyBiryukov.
Fixes #56353.
Built from https://develop.svn.wordpress.org/trunk@54117


git-svn-id: http://core.svn.wordpress.org/trunk@53676 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-09 12:39:11 +00:00
audrasjb
02032a7562 Docs: Clarify wp-includes/update.php main docblock description.
Props costdev, audrasjb.
See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53675 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-09 09:15:12 +00:00
audrasjb
700787f0c5 Docs: Various docblock fixes in wp-includes/update.php, as per documentation standards.
This addresses some files modified in changeset [54113].

See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53674 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-09 08:58:09 +00:00
audrasjb
7c20a1d2d5 Docs: Various docblock fixes in Site Health related files, as per documentation standards.
This addresses some files modified in changeset [54113].

See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-09 08:47:08 +00:00
audrasjb
c7fe0f88d2 Coding Standards: Clarify time units for various timeout or expiration values.
This changeset implements a clearer and more consistent timeout/duration/expiration format. It updates time durations used in various files, as per WordPress coding standards:

- If the value can be represented as an integer (not a fractional) number of minutes (hours, etc.), use the appropriate constant (e.g.: `MINUTE_IN_SECONDS`) multiplied by that number.
- Otherwise, keep the value as is and add a comment with the units for clarity.

Follow-up to [11823], [13177], [21996], [37747], [53714].

Props hztyfoon, audrasjb, arrasel403, krupalpanchal, GaryJ, SergeyBiryukov, peterwilsoncc, rudlinkon, costdev, robinwpdeveloper.
Fixes #56293.
See #55647.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53672 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-09 08:16:18 +00:00
Peter Wilson
3c6cad73b2 Widgets: Store default options for uninitialized widgets.
Prevent unnecessary database queries on page load by initializing widget options. On sites with uninitialized widgets, this prevents one or two database queries per uninitialized widget on each page load.

Props Chouby, mvraghavan, costdev, peterwilsoncc, spacedmonkey, mukesh27.
Fixes #54677.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53671 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-09 02:19:10 +00:00
Peter Wilson
31c90342c9 Query: Improve WP_Query's cache key generation for taxonomy queries.
Modify how `WP_Query` determines whether a database query contains a taxonomy component and accounts for term changes when generating the cache key. This presents a stale cache been used under some circumstances.

Props Chouby, costdev, peterwilsoncc.
See #22176.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-09 02:06:09 +00:00
Peter Wilson
b8f713ab09 Cron API: Remove unnecessary optimization getting ready events.
Remove the check for future events prior iterating the array of crons in `wp_get_ready_cron_jobs()`. If there are no ready events, the `foreach` loop will break on the first iteration so the optimization is not required.

As WordPress Core adds a number of events by default, accounting for an empty array is not required in most instances.

Props lev0, jrf, SergeyBiryukov.
Fixes #56092.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53669 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-09 01:53:11 +00:00
audrasjb
5f55192c9a Twenty Fifteen: Increase the font size used for h5 headings.
This changeset ensures `h5` and `h5` heading levels don't use the same font size.

Follow-up to [29892].

Props poena, akabarikalpesh, hellofromTonya, afrid1719, aezazshekh, sabernhardt, anitanenova, viralsampat, alansyue, pratiweb, russel07.
Fixes #52028.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 23:57:12 +00:00
desrosj
1a573e1bfc Build/Test Tools: Use the default GITHUB_TOKEN instead of a personal access token.
Previously, it was not possible to use the default `GITHUB_TOKEN` token to create new workflow runs in an effort to prevent accidental recursive workflows.

This has changed, and the `workflow_dispatch` is now one of two exceptions to this rule. Using `GITHUB_TOKEN` is preferred whenever possible to avoid the need for a PAT (personal access token), which expires (when created using the recommended security best practices), and is tied to an individual user.

See https://github.blog/changelog/2022-09-08-github-actions-use-github_token-with-workflow_dispatch-and-repository_dispatch/.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53667 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 23:41:14 +00:00
audrasjb
ee5e12f906 Twenty Twenty: Add a missing border to button-style links with Outline style.
This changeset addresses an issue where button-style links with Outline style variation were not consistent with the corresponding variation of the Button block.

Props umesh84, sabernhardt, mrfoxtalbot, mohitdadhich10.
Fixes #55824.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53666 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 23:03:11 +00:00
audrasjb
c3227c3776 Twenty Nineteen: Add font smoothing to editor styles.
This brings consistency between editor and front-end typography.

Props laurelfulford, sabernhardt, audrasjb.
Fixes #45909.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53665 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 22:42:13 +00:00
Sergey Biryukov
ee5b219070 Global Styles: Add support for heading, button, and caption elements.
This enables themes to:
* Set style rules for all heading elements together rather than having to do it individually.
* Style captions in `theme.json` by adding this into your `theme.json` file:
{{{
{
	"styles": {
		"elements": {
			"caption": {
				"color": {
					"background": "red",
					"text": "yellow"
				}
			}
		}
	}
}
}}}

This commit backports the original PRs from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/41981 #41981: Global Styles: Add support for heading elements]
* [https://github.com/WordPress/gutenberg/pull/41140 #41140: Global Styles: Add support for caption elements]

Follow-up to [50973].

Props cbravobernal, scruffian, madhudollu, mikachan, zieladam, bph, poena, andraganescu, ndiego, bgardner.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54105


git-svn-id: http://core.svn.wordpress.org/trunk@53664 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 16:44:11 +00:00
Sergey Biryukov
be113df39d Editor: Update single default template description.
In order to add more template types we need to update some copy from the current default templates provided.

This updates the `single` template copy as it's needed to clear up the ambiguity between the single template that is the fallback for any custom post type (including `post`) and the menu item to be added in a subsequent commit, that will allow the creation the `single-post` template and any `single_$post_type` template.

This commit backports the original PR from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/41302 #41302: Site Editor: Update single default template copy]

Follow-up to [52062], [52331].

Props ntsekouras, bernhard-reiter, jameskoster, Mamaduka, scruffian.
Fixes #56534.
Built from https://develop.svn.wordpress.org/trunk@54104


git-svn-id: http://core.svn.wordpress.org/trunk@53663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 16:15:08 +00:00
Sergey Biryukov
25e697c948 Twenty Twenty-One: Remove spacer block styles.
The theme includes styles for the spacer block for the front which appears to be unnecessary:
* It adds `display: block` even though that is the default.
* It removes top and bottom margin, even though this is not needed in the post content because of collapsing margins between blocks.
* It uses a custom CSS property to force a specific height on mobile. This affects the patterns in the theme negatively.

It also causes styling problems:
* When the spacer block has a height set to `0` in the navigation block, as the theme forces this to be larger on smaller screens.
* When the block is horizontal. Horizontal was not an option when this style was added.

Consequences of removal:
* Removing the use of the custom CSS property will cause a style change for websites that have adjusted the spacing property.

Follow-up to [49216], [49574].

Props poena, mukesh27.
Fixes #56222.
Built from https://develop.svn.wordpress.org/trunk@54103


git-svn-id: http://core.svn.wordpress.org/trunk@53662 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 15:48:08 +00:00
Sergey Biryukov
ffaf3da76f KSES: Allow more layout-related CSS properties.
Adds support for the following CSS properties considered safe for inline CSS:
* `flex-wrap`
* `gap`
* `column-gap`
* `row-gap`

Extends support for `margin` and `padding` to include logical properties:
* `margin-block-start`
* `margin-block-end`
* `margin-inline-start`
* `margin-inline-end`
* `padding-block-start`
* `padding-block-end`
* `padding-inline-start`
* `padding-inline-end`

Follow-up to [46235].

Props andrewserong, peterwilsoncc, ramonopoly, bernhard-reiter.
Fixes #56122.
Built from https://develop.svn.wordpress.org/trunk@54102


git-svn-id: http://core.svn.wordpress.org/trunk@53661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 15:06:09 +00:00
Sergey Biryukov
f6c2690313 Editor: Update duotone block supports to allow unset for preset colors.
This add the ability to unset duotone in themes with default duotone set.

This commit backports the original PRs from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/39564 #39564: Add ability to unset duotone in themes with default duotone set]
* [https://github.com/WordPress/gutenberg/pull/42020 #42020: Remove: Unrequired regex search on duotone supports]

Follow-up to [50929], [52757].

Props ajlende, jorgefilipecosta, Joen, cbravobernal.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54101


git-svn-id: http://core.svn.wordpress.org/trunk@53660 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 14:34:11 +00:00
Sergey Biryukov
b65fba9742 KSES: Allow min(), max(), minmax(), and clamp() values to be used in inline CSS.
Additionally, this commit updates `safecss_filter_attr()` to add support for nested `var()` functions, so that a fallback value can be another CSS variable.

Follow-up to [50923].

Props johnregan3, noisysocks, cbravobernal, uxl, isabel_brison, andrewserong, ramonopoly, joyously, bernhard-reiter, peterwilsoncc.
Fixes #55966.
Built from https://develop.svn.wordpress.org/trunk@54100


git-svn-id: http://core.svn.wordpress.org/trunk@53659 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 13:26:14 +00:00
spacedmonkey
6542de4220 Posts, Post Types: Call update_post_author_caches function in WP_Posts_List_Table class.
Call the `update_post_author_caches` function in the `WP_Posts_List_Table` class to prime post author caches in a single database request.

Props spacedmonkey, thakkarhardik, desrosj. 
Fixes #56100.
Built from https://develop.svn.wordpress.org/trunk@54099


git-svn-id: http://core.svn.wordpress.org/trunk@53658 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 10:17:12 +00:00
spacedmonkey
6d882a5dd9 Media: Call update_post_parent_caches function in WP_Media_List_Table class.
Call the `update_post_parent_caches` in `WP_Media_List_Table` class to prime parent caches in a single database request.

Props spacedmonkey, antpb, hellofromTonya, jeawhanlee, peterwilsoncc, alaca. 
Fixes #56036.
Built from https://develop.svn.wordpress.org/trunk@54098


git-svn-id: http://core.svn.wordpress.org/trunk@53657 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-08 09:37:17 +00:00
Felix Arntz
610d2d6a44 Media: Generate WebP only for certain registered image sizes.
The existing filter `image_editor_output_format` receives an additional parameter `$size_name` which is populated whenever it controls the output format for a specific registered image size to create. Otherwise, it remains empty. In order to achieve this, a low level change has been added in bringing a new `$size_name` class property to the `WP_Image_Editor` base class, which is introduced in a backward compatible way that will not cause conflicts with custom implementations.

This parameter is then used in new logic inside the `wp_default_image_output_mapping()` callback function for the filter, controlling whether `image/jpeg` should map to `image/webp` output or not. By default, this is enabled for all WordPress core image sizes by default, and this list can be modified using a new `wp_image_sizes_with_additional_mime_type_support` filter, e.g. to remove core sizes or add custom sizes.

The customization per image size may be further enhanced by providing a more declarative API via a new parameter on the `add_image_size()` function.

Props eugenemanuilov, flixos90, adamsilverstein, joegrainger.

Fixes #56526.
See #55443, #56288.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53656 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-07 21:45:14 +00:00
John Blackbourn
fa8f9ebd85 Build/Test Tools: Always use the amd64 images for MariaDB and MySQL on the local development environment.
The `amd64/mysql` and `amd64/mariadb` official images from Docker are also compatible with an x64 host machine which means they can be used by default instead of only when the host uses ARM64.

Props bernhard-reiter, czapla, gmovr, withinboredom

Fixes #56528

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


git-svn-id: http://core.svn.wordpress.org/trunk@53655 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-07 17:15:15 +00:00
Sergey Biryukov
b4331c7914 Tests: Correct magic methods in Basic_Object.
This is a test fixture (dummy class only used in a test context), which incorrectly implements the magic methods.

With the deprecation of dynamic properties in PHP 8.2, this needs to be fixed.

The new implementation represents a “proper” implementation of the magic methods for a class without non-`public` or typed properties.

Notes:

* Instead of relying on dynamic properties, the magic methods now store properties in a `private` `$arbitrary_props` array and retrieve them from there as well.
* The original `$foo` property, even though declared as `private`, was never `private` in practice due to the way the magic methods were originally implemented. In effect, it was fully publicly retrievable and modifiable without any (type) restrictions. With that in mind, the `foo` property has been moved into the `$arbitrary_props` array to keep the implementation of the magic methods as clean and straightforward as possible. With the adjusted magic methods, access to and modification of `$foo` will (on the surface) continue to work in the same way as before, while under the hood, it is no longer affected by the dynamic properties deprecation.
* Take note of the use of `array_key_exists()` instead of `isset()` in the `__get()` method. This is intentional and allows for `null` values to be stored and retrieved.
*  Also take note of `__set()` method no longer returning. `__set()` is supposed to be a `void` method. In practice, the return value would always be ignored due to how PHP handles magic methods, so in effect, this change will not make any difference and does not constitute a backward compatibility break.[[BR]][[BR]]
 > The return value of `__set()` is ignored because of the way PHP processes the assignment operator.

Alternatives considered:

* Instead of fixing the magic methods, they could have been removed instead and the class be made to `extend` `stdClass`. It has been chosen not to do so for two reasons:
 1. It’s kind of nice to have at least ''one'' correct implementation of magic methods in WP, which can be used as an example to point to as well.
 2. Extending `stdClass` would change the class hierarchy, which ''may'' or ''may not'' affect the tests using this fixture (depending on what’s being done with the class). Extending `stdClass` would also obfuscate what’s going on in the class and would require extensive documentation to prevent the extension being inadvertently removed at a future point in time.
* Instead of fixing the magic methods, the test fixture could have been deprecated and/or removed, with the few tests which use the fixture being updated to use `stdClass` for their test fixture instead. It has been chosen not to do so as there may well be external (plugin/theme) tests relying on this test fixture and evaluating whether that is so would be hard, as WP Directory cannot be used, since test code is normally not included in the code published on wp.org. Also note, there is still a (deprecated) `Basic_Subclass` fixture in the test suite, which extends this class.

These magic methods and the `Basic_Object` test fixture were originally introduced in [28480] and [28523]. The fixture was deprecated in [42381] and undeprecated again in [45807].

At this time, the test fixture is used in the `WP_Test_REST_Post_Meta_Fields` and the `Tests_REST_API` test classes.

References:
* [https://www.php.net/manual/en/language.oop5.overloading.php#object.set PHP Manual: Overloading: __set()]
* [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties]
* [https://github.com/php/php-src/issues/7786 php-src: #7786 PHP 8.2: unexpected deprecation for dynamic property set via magic method]

Follow-up to [28480], [28493], [28523], [42381], [45807].

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


git-svn-id: http://core.svn.wordpress.org/trunk@53654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-07 16:01:08 +00:00
Felix Arntz
42416cf392 Media: Move wp_default_image_output_mapping() filter callback to frontend scope.
While the `image_editor_output_format` filter is primarily used in WP Admin, it can also be executed in frontend scope, as the related `WP_Image_Editor` class and `wp_unique_filename()` function are being loaded in that scope.

Follow up to [54086].

See #55443, #56526.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53653 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-07 15:41:15 +00:00
Sergey Biryukov
ca1a756ff2 KSES: Revert [54092] for now to address unit test failures.
See #55966.
Built from https://develop.svn.wordpress.org/trunk@54093


git-svn-id: http://core.svn.wordpress.org/trunk@53652 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-07 15:24:13 +00:00
Sergey Biryukov
a15d6fd15b KSES: Allow min(), max(), minmax(), and clamp() values to be used in inline CSS.
Follow-up to [50923].

Props johnregan3, uxl, isabel_brison, andrewserong, ramonopoly, noisysocks, joyously.
See #55966.
Built from https://develop.svn.wordpress.org/trunk@54092


git-svn-id: http://core.svn.wordpress.org/trunk@53651 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-07 14:40:10 +00:00
Sergey Biryukov
96dd426d21 Tests: Remove redundant function_exists() check in a term_is_ancestor_of() test.
The function is available as of WordPress 3.4.

Follow-up to [19678], [493/tests].

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


git-svn-id: http://core.svn.wordpress.org/trunk@53650 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-07 14:07:12 +00:00
Sergey Biryukov
f00690c4a6 Tests: Use the factory method instead of the property.
This replaces all references to the `WP_UnitTestCase_Base::$factory` property with static function calls to the `WP_UnitTestCase_Base::factory()` method.

This is a consistency improvement for the test suite.

Follow up to [35225], [35242], [49603], [54087], [54088].

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


git-svn-id: http://core.svn.wordpress.org/trunk@53649 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 22:11:10 +00:00
Clorith
6bf326e967 Site Health: Fix TypeError when copying debug information.
In [53164] the `clipboard.js` library was updated to from version 2.0.8 to 2.0.10, and in doing so caused a TypeError JavaScript error to be thrown when the copy button for debug information was used.

With the update, the `clipboard.js` library introduced an enhancement to its `.copy()` API, which now removes the fake DOM element used for copying content, which Site Health previously had to remove manually.

As this fake DOM element is now removed automatically, the copy function within the debug information screen can rely on the library performing the removal, instead of WordPress needing to do so manually.

Props hiren1094, costdev.
Fixes #56515.
Built from https://develop.svn.wordpress.org/trunk@54089


git-svn-id: http://core.svn.wordpress.org/trunk@53648 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 22:06:19 +00:00
Sergey Biryukov
b245a374b8 Tests: Correctly use the factory method.
This replaces all non-static calls to the `WP_UnitTestCase_Base::factory()` method with static function calls, since the method is declared as static.

This is a consistency improvement for the test suite.

Follow up to [35225], [35242], [49603], [54087].

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


git-svn-id: http://core.svn.wordpress.org/trunk@53647 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 22:05:10 +00:00
Sergey Biryukov
1f506d3211 Build/Test Tools: Remove magic methods from WP_UnitTestCase_Base (without a backward compatibility break).
These magic methods were introduced to prevent a backward compatibility break, but in actual fact:

1. ''Caused'' a backward compatibility break. The original `$factory` property was a `static` property and this declared property was replaced by the magic methods. Unfortunately, it was not realized at the time that these magic methods **''are not called for static property access''**.[[BR]][[BR]]
 > Property overloading only works in object context. These magic methods will not be triggered in static context.
 And as approaching a static property in a non-static manner is [https://3v4l.org/93HQL not supported in PHP], this effectively created a backward compatibility break instead of preventing it.

2. Were hiding errors in tests, as the magic methods would be invoked for non-existent properties and would return `null` (get) or `false` (isset). See [54040], [54041], and [54077] for bug fixes related to this.

3. Are problematic in relation to PHP 8.2, as the implementation is incomplete, does not protect against dynamic properties and hides PHP notices about undefined properties.

Now, there were several options to mitigate this:

1. Revert the original commit. This would be problematic, as the ''non-static'' version of these properties has now been supported for 7 years, so this would create a new backward compatibility break.

2. Improve the magic methods. With all the issues with magic methods (see the discussion in the [https://www.youtube.com/watch?v=vDZWepDQQVE livestream from August 16, 2022], this would probably cause more problems than it’s worth and would make for a much more complex implementation, which is over the top for this relatively simple functionality, especially in the context of a test suite.

3. Remove the magic methods without adding the property. This would again cause a backward compatibility break, though one for which the mitigation solution would be relatively straightforward, i.e. to replace property access using `$this->factory` with a function call `$this->factory()` (or `self::factory()`, as the method is declared as static).    While we can (and have in a subsequent commit) mitigate this for the WP Core test suite, mitigating this for plugin or theme integration tests is outside of our purview and they would still need to deal with this backward compatibility break.

4. The current solution: removing the magic methods, explicitly declaring the (non-static) property and setting it in the `set_up()` method. This does not constitute a backward compatibility break with the functionality as it was over the past 7 years. Setting the property in `set_up()` may be “late”, but that is the earliest place in which the property can be set as non-static. If the factory would be needed prior to `set_up()`, the (static) `WP_UnitTestCase_Base::factory()` method should be called directly. This is no different from how this functionality behaved over the past 7 years.

Note: The property is straight away marked as “deprecated”, since the method should be favored over the use of the property.

Reference: [https://www.php.net/manual/en/language.oop5.overloading.php#object.get PHP Manual: Property overloading: __get()]

Follow-up to [35225], [35242].

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


git-svn-id: http://core.svn.wordpress.org/trunk@53646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 22:02:09 +00:00
Adam Silverstein
897a9743be Media: Output WebP by default when uploading JPEGs.
Uploaded JPEGs will automatically be converted to WebP sub-sizes instead of JPEG, saving space and making sites faster.

The original JPEG upload is always retained and can be accessed by calling `wp_get_original_image_url`.

Props azaozz, flixos90.
Fixes #55443.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53645 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 21:15:08 +00:00
Adam Silverstein
4b5968aa9b 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.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53644 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 21:13:12 +00:00
Sergey Biryukov
32b92a213a 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.
Built from https://develop.svn.wordpress.org/trunk@54084


git-svn-id: http://core.svn.wordpress.org/trunk@53643 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 16:18:11 +00:00
Sergey Biryukov
6e26f8f8c7 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.
Built from https://develop.svn.wordpress.org/trunk@54083


git-svn-id: http://core.svn.wordpress.org/trunk@53642 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 14:43:09 +00:00
Sergey Biryukov
5b2c18d295 Docs: Add a @since note for the update_network_meta_cache parameter of WP_Network_Query::__construct().
Follow-up to [54080].

See #55646.
Built from https://develop.svn.wordpress.org/trunk@54082


git-svn-id: http://core.svn.wordpress.org/trunk@53641 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 14:21:10 +00:00
Sergey Biryukov
df56131c6a 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.
Built from https://develop.svn.wordpress.org/trunk@54081


git-svn-id: http://core.svn.wordpress.org/trunk@53640 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 13:59:13 +00:00
spacedmonkey
8d1156f066 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
Built from https://develop.svn.wordpress.org/trunk@54080


git-svn-id: http://core.svn.wordpress.org/trunk@53639 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 11:28:13 +00:00
noisysocks
4a5f783888 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.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53638 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 02:52:11 +00:00
Sergey Biryukov
50493b7405 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.
Built from https://develop.svn.wordpress.org/trunk@54078


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


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


git-svn-id: http://core.svn.wordpress.org/trunk@53635 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 00:13:11 +00:00
Sergey Biryukov
dd176ecba4 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.
Built from https://develop.svn.wordpress.org/trunk@54075


git-svn-id: http://core.svn.wordpress.org/trunk@53634 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 22:27:08 +00:00
Sergey Biryukov
5d9ccf7fd1 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.
Built from https://develop.svn.wordpress.org/trunk@54074


git-svn-id: http://core.svn.wordpress.org/trunk@53633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 21:16:10 +00:00
Sergey Biryukov
7f92613e06 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.
Built from https://develop.svn.wordpress.org/trunk@54073


git-svn-id: http://core.svn.wordpress.org/trunk@53632 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 19:24:11 +00:00
Sergey Biryukov
24050652e5 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.
Built from https://develop.svn.wordpress.org/trunk@54072


git-svn-id: http://core.svn.wordpress.org/trunk@53631 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 18:57:13 +00:00
Sergey Biryukov
c54960342b 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.
Built from https://develop.svn.wordpress.org/trunk@54071


git-svn-id: http://core.svn.wordpress.org/trunk@53630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 17:19:09 +00:00
Sergey Biryukov
cdfb7d7ef0 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.
Built from https://develop.svn.wordpress.org/trunk@54070


git-svn-id: http://core.svn.wordpress.org/trunk@53629 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 16:02:09 +00:00
Sergey Biryukov
b43dcea01e 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.
Built from https://develop.svn.wordpress.org/trunk@54069


git-svn-id: http://core.svn.wordpress.org/trunk@53628 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 15:20:09 +00:00
Sergey Biryukov
c6c02c9dc6 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.
Built from https://develop.svn.wordpress.org/trunk@54068


git-svn-id: http://core.svn.wordpress.org/trunk@53627 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 14:33:08 +00:00
Sergey Biryukov
1949a52d9a 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.
Built from https://develop.svn.wordpress.org/trunk@54067


git-svn-id: http://core.svn.wordpress.org/trunk@53626 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 14:06:12 +00:00
Peter Wilson
0301c933d4 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.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53625 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 05:45:14 +00:00
Sergey Biryukov
e5fd46da70 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.
Built from https://develop.svn.wordpress.org/trunk@54065


git-svn-id: http://core.svn.wordpress.org/trunk@53624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-04 14:40:14 +00:00
Sergey Biryukov
0eae4e0074 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.
Built from https://develop.svn.wordpress.org/trunk@54064


git-svn-id: http://core.svn.wordpress.org/trunk@53623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-03 14:47:13 +00:00
audrasjb
ac9f6594c4 Docs: Use third-person singular verbs for various function descriptions, as per docblocks standards.
This addresses various files modified in changeset [54062].

See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-02 06:58:09 +00:00
audrasjb
16bc8d38a6 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.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53621 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-02 06:51:13 +00:00
Sergey Biryukov
ae709d1d31 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.
Built from https://develop.svn.wordpress.org/trunk@54061


git-svn-id: http://core.svn.wordpress.org/trunk@53620 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-02 01:16:10 +00:00
Sergey Biryukov
f44ab3ab48 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.
Built from https://develop.svn.wordpress.org/trunk@54060


git-svn-id: http://core.svn.wordpress.org/trunk@53619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-02 00:13:10 +00:00
Sergey Biryukov
999c97dfda 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.
Built from https://develop.svn.wordpress.org/trunk@54059


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


git-svn-id: http://core.svn.wordpress.org/trunk@53617 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 22:56:14 +00:00
Sergey Biryukov
fe35bf7222 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.
Built from https://develop.svn.wordpress.org/trunk@54057


git-svn-id: http://core.svn.wordpress.org/trunk@53616 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 19:08:11 +00:00
Sergey Biryukov
46472cc493 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.
Built from https://develop.svn.wordpress.org/trunk@54056


git-svn-id: http://core.svn.wordpress.org/trunk@53615 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 18:59:09 +00:00
Sergey Biryukov
bed8ddc138 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.
Built from https://develop.svn.wordpress.org/trunk@54055


git-svn-id: http://core.svn.wordpress.org/trunk@53614 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 18:44:12 +00:00
Felix Arntz
7f4f1ead61 Site Health: Ensure persistent object cache check short-circuit filter also short-circuits multisite.
Follow up to [54053].

See #56040.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 17:47:09 +00:00
Felix Arntz
83e6ad6c9a 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.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-01 17:06:10 +00:00
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