5469 Commits

Author SHA1 Message Date
Tonya Mork
c362c2ad99 Code Modernization: Deprecate dynamic properties in WP_List_Table magic methods.
The unknown use of unknown dynamic property within the `WP_List_Table` property magic methods is now deprecated. A descriptive deprecation notice is provided to alert developers to declare the property on the child class extending `WP_List_Table`.

Changes in this commit:
* Adds a deprecation notice to the `__get()`, `__set()`, `__isset()`, `__unset()` magic methods, i.e. to alert and inform developers when attempting to get/set/isset/unset a dynamic property.
* Fixes `__get()` to explicitly returns `null` when attempting to get a dynamic property.
* Removes returning the value when setting a declared property, as (a) unnecessary and (b) `__set()` should return `void` [https://www.php.net/manual/en/language.oop5.overloading.php#object.set per the PHP handbook].
* Adds unit tests for happy and unhappy paths.

For backward compatibility, no changes are made to the internal declared properties listed in `$compat_fields` and accessed through the magic methods. 

For example:
A child class uses a property named `$data` that is not declared / defined as a property on the child class. When getting its value, e.g. `$list_table->data`, the `WP_List_Table::__get()` magic method is invoked, the following deprecation notice thrown, and `null` returned:

>The property `data` is not defined. Setting a dynamic (undefined) property is deprecated since version 6.4.0! Instead, define the property on the class.

=== Why not remove the magic methods, remove the `$compat_fields` property, and restore the properties `public`?

tl;dr Backward compatibility.

Several plugins, one of which has over 5M installs, add a property to the `$compat_fields` array. Removing the property would cause an `Undefined property` `Warning` (PHP 8) | `Notice` (PHP 7) to be thrown. Removing the associated code would change the functionality.

=== Why not limit the deprecation for PHP versions >= 8.2?

tl;dr original design intent and inform

The magic methods and `$compat_fields` property were added for one purpose: to continue providing external access to internal properties declared on `WP_List_Table`. They were not intended to be used for dynamic properties.

Deprecating that unintended usage both alerts developers a change is needed in their child class and informs them what to change.

References: 
* Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.
* A [https://www.youtube.com/live/vDZWepDQQVE?feature=share&t=10097 live open public working session] where these changes were discussed and agreed to.
* [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties.]

Related to #14579, #22234, #30891.

Follow-up to [15491], [28493], [28521], [28524], [31146].

Props antonvlasenko, jrf, markjaquith, hellofromTonya, SergeyBiryukov, desrosj, peterwilsoncc, audrasjb, costdev, oglekler, jeffpaul.
Fixes #58896.
See #56034.

git-svn-id: https://develop.svn.wordpress.org/trunk@56349 602fd350-edb4-49c9-b593-d223f7449a82
2023-08-02 18:35:24 +00:00
Tonya Mork
88570fd5b3 Tests: Fix leakage in WP_List_Table tests.
Fixes `WP_List_table` tests leaking into other tests by:

* Restores the original `$hook_suffix` global value.
Rather than modifying the global for all tests, it now restores the original value between tests. Why? To ensure each test starts at a known state.

* Uses a new instance of `WP_List_Table` for each test.
A test may modify the `$list_table` object. If it does, it could impact tests yet to run. By instantiating a new instance in the `set_up()` test fixture, each test is isolated from the others.

Follow-up to [53868], [54215].

Props hellofromTonya, antonvlasenko.
See #58955, #58896.

git-svn-id: https://develop.svn.wordpress.org/trunk@56348 602fd350-edb4-49c9-b593-d223f7449a82
2023-08-02 17:58:18 +00:00
Felix Arntz
02f9f1ea95 Media: Simplify logic in wp_get_loading_optimization_attributes().
While the `wp_get_loading_optimization_attributes()` function was only recently introduced in 6.3, its code was mostly ported over from the now deprecated `wp_get_loading_attr_default()` function introduced in 5.5.

That function started out in a simple way, but over time was expanded with more and more conditionals on when to avoid lazy-loading, which ended up making the logic extremely complex and hard to follow.

This changeset refactors the logic to simplify it, in a way that allows to follow it more sequentially, and without making any functional changes, ensuring that the extensive existing unit test coverage still passes. This will facilitate future enhancements to the function to be less error-prone and make it more accessible to new contributors.

Props flixos90, joemcgill.
Fixes #58891.


git-svn-id: https://develop.svn.wordpress.org/trunk@56347 602fd350-edb4-49c9-b593-d223f7449a82
2023-08-02 17:56:16 +00:00
Bernie Reiter
41bffadb83 HTML API: Add support for SPAN element.
In this patch we're introducing support for the SPAN element, which is the first
in the class of "any other tag" in the "in body" insertion mode.

This patch introduces the mechanisms required to handle that class of tags but
only introduces SPAN to keep the change focused. With the tests and mechanisms
in place it will be possible to follow-up and add another limited set of tags.

It's important that this not use the default catch-all in the switch handling
`step_in_body` because that would catch tags that have specific rules in previous
case statements that aren't yet added. For example, we don't want to treat the
`TABLE` element as "any other tag".

Props dmsnell.
Fixes #58907.

git-svn-id: https://develop.svn.wordpress.org/trunk@56331 602fd350-edb4-49c9-b593-d223f7449a82
2023-08-01 07:54:54 +00:00
Sergey Biryukov
8698238039 Coding Standards: Use correct case for class name in WP_Http tests.
Follow-up to [8516], [54968].

Props jrf.
See #58831.

git-svn-id: https://develop.svn.wordpress.org/trunk@56319 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-27 14:45:09 +00:00
Bernie Reiter
1d112a6b88 HTML API: Change wp infix in test classes to Wp.
In order to comply with the test class naming scheme set forth in #56846, rename the test classes covering the HTML API by changing the `wp` infix to `Wp`.

Props dmsnell, costdev.
Fixes #58899. See #56846.

git-svn-id: https://develop.svn.wordpress.org/trunk@56299 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-25 12:17:28 +00:00
Isabel Brison
1d7554d1b2 Editor: load title on navigation fallback.
Adds raw title property when loading the navigation fallback with an embed context.

Props ramonopoly, get_dave, scruffian, mukesh27, audrasjb.
Fixes #58557.



git-svn-id: https://develop.svn.wordpress.org/trunk@56296 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-25 06:28:28 +00:00
Sergey Biryukov
c3e9e23dcf Coding Standards: Always use parentheses for class instantiation.
This addresses a `new stdClass()` instance in `_get_non_cached_ids()` tests.

Follow-up to [55543].

Props jrf.
See #58831.

git-svn-id: https://develop.svn.wordpress.org/trunk@56281 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-22 12:35:15 +00:00
Bernie Reiter
f4fa4dd1ba HTML-API: Introduce minimal HTML Processor.
This patch introduces the //first// of //many// iterations on the evolution of the HTML API, the HTML Processor, which is built in order to understand HTML structure including nesting, misnesting, and complicated semantic rules.

In the first iteration, the HTML Processor is arbitrarily limited to a minimal subset of functionality so that we can review it, ship it, test it, and collect feedback before moving forward. This means that this patch is more or less an extension to the Tag Processor query language, providing the ability not only to scan for a tag of a given name, but also to find an HTML element in a specific nesting path.

The HTML Processor also aborts any time it encounters:
 - a tag that isn't a `P`, `DIV`, `FIGURE`, `FIGCAPTION`, `IMG`, `STRONG`, `B`, `EM`, `I`, `A`, `BIG`, `CODE`, `FONT`, `SMALL`, `STRIKE`, `TT`, or `U` tag. this limit exists because many HTML elements require specific rules and we are trying to limit the number of rules introduced at once. this work is targeted at existing work in places like the image block.
 - certain misnesting constructs that evoke complicated resolution inside the HTML spec. where possible and where simple to do reliably, certain parse errors are handled. in most cases the HTML Processor aborts.

The structure of the HTML Processor is established in this patch. Further spec-compliance comes through filling out //more of the same// kind and nature of code as is found in this patch. Certain critical HTML algorithms are partially supported, and where support requires more than is present, the HTML Processor acknowledges this and refuses to operate.

In this patch are explorations for how to verify that new HTML support is fully added (instead of allowing for partial updates that leave some code paths non-compliant). Performance is hard to measure since support is so limited at the current time, but it should generally follow the performance of the Tag Processor somewhat close as the overhead is minimized as much as practical.

Props dmsnell, zieladam, costdev.
Fixes #58517.

git-svn-id: https://develop.svn.wordpress.org/trunk@56274 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-20 13:41:21 +00:00
Anthony Burchell
287fd501f2 Media: Adjust PDF upload handling to remove non-opaque alpha channels from previews.
Previously, Imagick uploads of PDF files with non-opaque alpha channels would result in a black background replacing alpha in the generated thumbnail. This patch adds a `remove_pdf_alpha_channel()` function in the Imagick classes to use a white background instead.

Props gitlost, joemcgill, joedolson, launchinteractive, emirpprime, mwtsn, ceer, maysi, madejackson, 6adminit, costdev, oglekler.
Fixes #39216.


git-svn-id: https://develop.svn.wordpress.org/trunk@56271 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-19 22:33:47 +00:00
Bernie Reiter
75caa9c318 Editor: Add test for context setting in Comment Template block.
Test that `commentId` context is correctly set and made available by the Comment Template block to the `render_block_context` filter (at priority 2 and higher), and to the `render_block` filter (important when programmatically inserting child blocks into the Comment Template block).

Furthermore, test that child blocks inserted via the `render_block_data` filter are retained and thus present at `render_block` filter stage.

Props andrewserong, ramonopoly, peterwilsoncc, costdev, mukesh27, flixos90.
Fixes #58839.

git-svn-id: https://develop.svn.wordpress.org/trunk@56262 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-18 16:07:49 +00:00
Felix Arntz
2b931da110 Editor: Fix bug where it was not possible to style custom block elements in theme.json.
This changeset resolves a bug where WordPress would only allow HTML elements within core's own blocks to be styled in `theme.json`. Prior to this change, any `theme.json` rules applying to elements in custom blocks were ignored. With this fix it is now possible to style third-party block elements in `theme.json`.

Props flixos90, azaozz, costdev, glendaviesnz, spacedmonkey, oandregal.
Fixes #57868.


git-svn-id: https://develop.svn.wordpress.org/trunk@56254 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-18 00:00:49 +00:00
Joe McGill
be1cb4583a General: Rename wp_in_development_mode() to wp_is_development_mode().
This changes the function name for the helper function to check whether the current environment is running with the `WP_DEVELOPMENT_MODE` constant set to be more consistent with similar functions in core, like `wp_is_maintenance_mode()` and `wp_is_recover_mode()`.

Props flixos90, swissspidy, costdev, peterwilson, robinwpdeveloper, SergeyBiryukov, joemcgill.
See 57487.


git-svn-id: https://develop.svn.wordpress.org/trunk@56249 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-17 14:48:48 +00:00
Jb Audras
7df1b8366d Editor: Fix a PHP notice appearing when adding a new template part.
This changeset fixes a PHP notice appearing when a template part is created in the site editor. It also adds a unit test case to cover 
`WP_REST_Templates_Controller::prepare_item_for_database`.

Props wildworks, dunhakdis, Rahmohn, oglekler, audrasjb, mukesh27, costdev, dunhakdis.
Fixes #57851.




git-svn-id: https://develop.svn.wordpress.org/trunk@56248 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-17 14:20:42 +00:00
Joe McGill
967abef19e Script Loader: Improve test coverage for wp_print_scripts().
This is a follow-up to [56092], which further improves PHPUnit test coverage and inline docs for ensuring `async` and `defer` attributes are being properly handled for scripts that are printed without being enqueued.

Props peterwilsoncc, azaozz, westonruter, joemcgill.
See #58648.


git-svn-id: https://develop.svn.wordpress.org/trunk@56246 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-17 14:04:00 +00:00
Isabel Brison
2beefda2c0 Editor: trim footnote anchors from post excerpts.
Adds the `excerpt_remove_footnotes` function to trim footnote anchors from post excerpts.

Props: ramonopoly, costdev, mukesh27, mcsf, azaozz.
Fixes #58805.


git-svn-id: https://develop.svn.wordpress.org/trunk@56244 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-17 01:45:24 +00:00
Sergey Biryukov
de6f51823a Tests: Add tests to ensure the contribute Toolbar node is added when appropriate.
Follow-up to [56220].

Props costdev.
See #23348.

git-svn-id: https://develop.svn.wordpress.org/trunk@56227 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-13 12:39:42 +00:00
Jonny Harris
fc538206ec Editor: Lazily load Duotone settings only when needed.
Introduced in [56101] the `WP_Duotone` class, hooks into the `wp_loaded` action to load duotone style data from global styles. Hooking in early in the bootstrap process caused a number of problems. This hook, triggered an error on installing, as this lookup for global styles, would result in a global post trying to be created, even before the table existed. Additionally, this implementation caused a severe performance regression, as duotone styling data was loaded unnecessarily for requests that did not require such data, such as REST API calls or actions within the wp-admin interface.

In this change, refactor the `WP_Duotone` to lazily load the global styles and theme.json data, only when a block that supports duotone is encountered. The method `render_duotone_support` was change to take a third parameter to reuse the existing `WP_Block_Type` object passed to the filter, to save it being looked up again. The code has also got improved type checking and the use of the util function  `block_has_support`. Furthermore, the code's readability has been improved, along with enhancements to the documentation blocks.

Props Chouby, spacedmonkey, SergeyBiryukov, swissspidy, costdev, joemcgill, flixos90, mukesh27, nazmul111, ajlende, isabel_brison.
Fixes #58673.

git-svn-id: https://develop.svn.wordpress.org/trunk@56226 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-13 11:32:19 +00:00
Peter Wilson
65a048fc15 General: Introduce all development mode.
Introduce the development mode `all` as a a cover-all mode for the existing `theme`, `plugin` and `core` development modes. Developers can use the `all` mode if they are developing both themes and plugins, for example.

Introduce the utility function `wp_in_development_mode()` allowing developers to detect the mode via a parameter. If the development mode is set to `all` this function will always return `true`. If the development mode is specific then only the chosen mode will return `true`.

Follow up to [56079,56042].

Props flixos90.
Fixes #57487.



git-svn-id: https://develop.svn.wordpress.org/trunk@56223 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-13 00:27:06 +00:00
Sergey Biryukov
cdf3ac093d Coding Standards: Use single quotes for a string in Tests_Comment.
This resolves a WPCS error:
{{{
Error: String "1" does not require double quotes; use single quotes instead.
}}}

Includes updating a few related comments for clarity.

Follow-up to [56221].

See #57855.

git-svn-id: https://develop.svn.wordpress.org/trunk@56222 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-12 20:59:37 +00:00
Aaron Jorbin
434dd6be91 Tests: Use assertSame() in Tests_Comment
See #57855.


git-svn-id: https://develop.svn.wordpress.org/trunk@56221 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-12 20:04:02 +00:00
Joe McGill
ed174730d3 Media: Optimize images created in shortcodes.
This fixes an issue where images dynamically created during shortcode rendering (e.g., shortcode image galleries), were not getting image optimizations like `loading="lazy"` or `fetchpriority="hight"` applied. Note that even after this commit, shortcodes are processed after the main content images, which can affect the order in which optimizations are applied in content areas.

Follow-up to [56037].

Props spacedmonkey, flixos90, thekt12, swissspidy, joemcgill.
Fixes #58681.


git-svn-id: https://develop.svn.wordpress.org/trunk@56214 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-11 13:56:55 +00:00
Joe McGill
cb54fdb142 Build/Test Tools: Reset main query object after each test.
This resets the main query variable, `$wp_the_query` during the `WP_UnitTestCase_Base::tear_down` method that runs after each PHPUnit test. This ensures any changes to the main query object is reset after each test to avoid cross contamination between tests, similar to how other globals are reset.

Props flixos90, spacedmonkey, joemcgill.
Fixes #58776.


git-svn-id: https://develop.svn.wordpress.org/trunk@56212 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-11 13:31:03 +00:00
Isabel Brison
a02886a868 Editor: opt out of Navigation fallback.
Allows developers to opt out of the auto-creation of the Navigation fallback through a filter.

Props get_dave, spacedmonkey, ramonopoly.
Fixes #58750.


git-svn-id: https://develop.svn.wordpress.org/trunk@56202 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-11 05:39:33 +00:00
Peter Wilson
5e14c430a3 Build/Test Tools: Prevent 404 errors in the E2E tests.
Modifies the cache control headers tests to prevent 404 errors for each of the tests.

Props costdev.
Fixes #58777.


git-svn-id: https://develop.svn.wordpress.org/trunk@56197 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-11 03:39:39 +00:00
Andrew Ozz
8b8afa1299 Filesystem API: Ensure wp_tempnam() does not produce file names longer than 255 characters as this is the limit on most filesystems.
Props: costdev, doems, mikeschroder, oglekler, mrinal013.
Fixes: #35755.

git-svn-id: https://develop.svn.wordpress.org/trunk@56186 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-10 20:31:35 +00:00
Felix Arntz
96c64cd42d Media: Avoid programmatically created images within post content from incorrectly receiving fetchpriority="high".
Follow-up to [56037], as that changeset accidentally did not consider the changes made in [55825]: Images that are programmatically injected into post content (e.g. through a block, or shortcode, or any hook calling a function like `wp_get_attachment_image()`) must be treated as part of the whole post content blob since otherwise the heuristics for applying `fetchpriority="high"` and `loading="lazy"` are skewed by parsing certain images before others rather than sequentially parsing the entire post content. [55825] addressed that for lazy-loading, but when [56037] introduced `fetchpriority` support, the related refactor missed making the same consideration for that attribute.

Props flixos90, spacedmonkey, thekt12, mukesh27.
Fixes #58235.
See #58089.


git-svn-id: https://develop.svn.wordpress.org/trunk@56164 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-07 18:06:49 +00:00
Adam Silverstein
9781ffbca5 Revisions: return existing autosave after saving with unchanged data.
Correctly return the existing autosave when an unchanged autosave is saved, instead of returning an error.

Fix regressions after r55154 where an error and not the original autosave was returned when saving with unchanged data (for example, clicking the preview button repeatedly). Returning the autosave (ID) is the expected behavior for the endpoint.

Follow up to [55154]

Props Mamaduka, jeroenrotty, mrfoxtalbot.
Fixes #58739.



git-svn-id: https://develop.svn.wordpress.org/trunk@56163 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-07 17:51:11 +00:00
Felix Arntz
a3b80f551f Build/Test: Fix incorrect hook being used to separate Server-Timing metrics in performance tests.
The `wp-before-template` and `wp-template` metric intend to separate WordPress core's own bootstrap process from any logic that is part of the eventual template loaded. The appropriate hook for that is the `template_include` filter as that occurs right before the template file is included.

Props mukesh27, joemcgill.
Fixes #58674.


git-svn-id: https://develop.svn.wordpress.org/trunk@56162 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-07 17:39:09 +00:00
Jonny Harris
2fbf610b25 Build/Test: Fix dynamic property deprecation warning in object cache drop-in.
Fix deprecation warning for dynamic property in object cache drop-in used in core unit 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.

Props spacedmonkey, johnbillion.
Fixes #58736. 
See #56034.

git-svn-id: https://develop.svn.wordpress.org/trunk@56161 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-07 11:30:15 +00:00
Isabel Brison
7035b615c4 Editor: rename sync_status and move it to top level.
Renames sync_status to wp_pattern_sync_status and moves it to top level field of wp_block post type.

Props glendaviesnz, aaronrobertshaw, mukesh27, peterwilsoncc.
Fixes 58677.


git-svn-id: https://develop.svn.wordpress.org/trunk@56160 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-07 07:27:53 +00:00
Felix Arntz
21490c6ba4 Media: Ensure that the image widget supports loading optimization attributes.
This changeset adds support for loading optimization attributes such as `loading="lazy"` and `fetchpriority="high"` to the image widget. A new context `widget_media_image` is introduced for that purpose.

Props spacedmonkey, thekt12, mukesh27, westonruter.
Fixes #58704.
See #58235.


git-svn-id: https://develop.svn.wordpress.org/trunk@56154 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-06 16:31:02 +00:00
Isabel Brison
9d141e5a5e Editor: update template titles in browse mode.
Adds more meaningful titles to templates in the browse mode template list.

Props ntsekouras, audrasjb.
Fixes #58713.


git-svn-id: https://develop.svn.wordpress.org/trunk@56145 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-06 03:02:57 +00:00
Felix Arntz
ebd03692e6 Media: Ensure that large images before the main query loop are counted towards lazy-loading threshold.
Following [55318], [55847], and [56142], certain images in the header of the page have received support for potentially receiving `fetchpriority="high"` and having the `loading="lazy"` attribute omitted. However, these images being present did not affect the "content media count" which counts the images towards a certain threshold so that the first ones are not lazy-loaded.

This changeset also increases that count for such header images if they are larger than a certain threshold. The threshold is used to avoid e.g. a header with lots of small images such as icon graphics to skew the lazy-loading behavior.

Props thekt12, spacedmonkey, flixos90.
Fixes #58635.


git-svn-id: https://develop.svn.wordpress.org/trunk@56143 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-05 21:36:23 +00:00
Felix Arntz
aee525ee6f Media: Ensure custom header image tag supports loading optimization attributes.
This changeset is a follow up to [56037] and ensures that the `get_header_image_tag()` function receives the benefits of `wp_get_loading_optimization_attributes()` as well. Prior to `fetchpriority` support, this was not needed since the header image should never be lazy-loaded, but the image certainly is a `fetchpriority` candidate, so therefore it is crucial to have it supported.

Props felipeelia, spacedmonkey, mukesh27, westonruter, flixos90.
Fixes #58680.


git-svn-id: https://develop.svn.wordpress.org/trunk@56142 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-05 19:28:02 +00:00
John Blackbourn
f7dbb2462b General: Increase the minimum supported version of PHP to 7.0.0.
This also removes the random compat library which is no longer necessary, and adjusts unit tests and CI workflows that no longer need to take PHP 5.6 into account.

Thank you for your service, PHP 5. Onwards!

Props SergeyBiryukov, mukesh27, dingo_d, audrasjb, jrf, costdev, azaozz, JavierCasares, hellofromTonya, samiamnot, spacedmonkey, masteradhoc, knutsp, garyjones, chanthaboune

Fixes #57345


git-svn-id: https://develop.svn.wordpress.org/trunk@56141 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-05 17:39:55 +00:00
Sergey Biryukov
c11f70878f General: Compare values as strings in WP_List_Util::filter() and ::sort_callback().
This aims to preserve backward compatibility for code relying on type juggling when using the `wp_list_filter()` function, e.g. comparing a numeric string to an integer.

Follow-up to [55908].

Props azaozz, jeremyfelt, david.binda.
See #57839.

git-svn-id: https://develop.svn.wordpress.org/trunk@56137 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-05 10:44:20 +00:00
John Blackbourn
77c59ac4f1 Administration: Adjust the "No private directive present in cache control when user not logged in" test so the assertions won't fail if the headers don't contain a cache-control key at all.
Props joemcgill

Fixes #21938


git-svn-id: https://develop.svn.wordpress.org/trunk@56134 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-04 23:30:36 +00:00
Andrew Ozz
56af1e4b94 HTML API: Fix a fatal error when processing malformed document with unclosed attribute.
Props: dlh, costdev, dmsnell.
Fixes: #58637.

git-svn-id: https://develop.svn.wordpress.org/trunk@56133 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-04 20:43:43 +00:00
Sergey Biryukov
e834fed6eb Options, Meta APIs: Check if the gmt_offset value is numeric in sanitize_option().
When saving the settings via the admin UI, the default value for any options not passed in the current `$_POST` request is set to `null` in `wp-admin/options.php`. Some options, e.g. `blog_public`, then rely on `null` being passed to `update_option()` to determine whether the value was changed or not.

This commit resolves a PHP 8.1 deprecation notice when saving the `gmt_offset` option without any changes:
{{{
Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
}}}

Includes a similar fix for the `blog_charset` option.

Follow-up to [4112], [4329], [5541], [21849].

Props adi3890, dhrupo, hrdelwar, hasanmisbah, oglekler, mukesh27, SergeyBiryukov.
Fixes #57728.

git-svn-id: https://develop.svn.wordpress.org/trunk@56132 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-04 13:40:55 +00:00
Sergey Biryukov
62b286f9b2 Upgrade/Install: Initialize the local $checkout variable in WP_Automatic_Updater::is_vcs_checkout().
This avoids an `Undefined variable $checkout` PHP warning if all of the directories checked for access are disallowed due to the PHP `open_basedir` restrictions.

Follow-up to [55425].

Props jqz, costdev, audrasjb.
Fixes #58563.

git-svn-id: https://develop.svn.wordpress.org/trunk@56124 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-02 10:33:18 +00:00
Jb Audras
e635540d1c Quick/Bulk Edit: Ensure scheduled posts are published when using Bulk Edit.
This changeset ensures scheduled posts are actually published when changing their status to "Published" using bulk edit. Also adds related unit tests.

Props siobhan, Clorith, webcommsat, cadic, oglekler, audrasjb, pavanpatil1.
Fixes #31635.




git-svn-id: https://develop.svn.wordpress.org/trunk@56123 602fd350-edb4-49c9-b593-d223f7449a82
2023-07-02 08:02:45 +00:00
John Blackbourn
be90d79cb5 General: Ignore invalid types for the '_wp_http_referer' URL query variable.
It's expected that this query variable contains a string when it's set, but it's possible for its type to be something else such as an array. Ignoring non-string values prevents cascading errors when its value is passed through functions that expect a string.

Props xknown, costdev, jrf, azaozz

Fixes #57670


git-svn-id: https://develop.svn.wordpress.org/trunk@56115 602fd350-edb4-49c9-b593-d223f7449a82
2023-06-29 23:25:38 +00:00
Isabel Brison
41277f1f1b REST API: updates test annotations for global styles revisions
Adds `@covers` annotations to tests and fixes incorrect spacing.

Props ramonopoly, mukesh27.
See #58524.


git-svn-id: https://develop.svn.wordpress.org/trunk@56105 602fd350-edb4-49c9-b593-d223f7449a82
2023-06-29 06:47:43 +00:00
Isabel Brison
280f162097 Editor: delete test file from update duotone support.
Deleting the test file that should have been removed in [56101].

See #58555.


git-svn-id: https://develop.svn.wordpress.org/trunk@56103 602fd350-edb4-49c9-b593-d223f7449a82
2023-06-29 06:34:25 +00:00
Isabel Brison
d966798bfc Editor: update duotone support.
Updates duotone support after stabilisation of selectors API and adds a few small code quality and UI improvements.

Props onemaggie, peterwilsoncc, ajlende, audrasjb, mikeschroder, ramonopoly.
Fixes #58555.


git-svn-id: https://develop.svn.wordpress.org/trunk@56101 602fd350-edb4-49c9-b593-d223f7449a82
2023-06-29 06:19:41 +00:00
K. Adam White
68be569925 REST API: Expose current $request object to cors_header filters in WP_REST_SERVER->serve_request().
Allows headers to be more easily set on a per-response basis when more or less security is needed on a specific route.

Props bor0, rachelbaker, spacedmonkey, chaion07, oglekler, SergeyBiryukov.
Fixes #57752.



git-svn-id: https://develop.svn.wordpress.org/trunk@56096 602fd350-edb4-49c9-b593-d223f7449a82
2023-06-28 17:37:52 +00:00
Andrew Ozz
80e424ad55 Script Loader: Fix unintended adding of async to scripts that are printed directly with wp_print_scripts() without enqueueing them beforehand.
Props: joemcgill, westonruter, felixarntz, peterwilsoncc.
See: #58648.

git-svn-id: https://develop.svn.wordpress.org/trunk@56092 602fd350-edb4-49c9-b593-d223f7449a82
2023-06-28 14:14:58 +00:00
Sergey Biryukov
a63be5a890 Quick/Bulk Edit: Add an action hook to bulk_edit_posts() function.
This changeset introduces the `bulk_edit_posts` action hook, triggered after processing the post data for bulk edit and before the function returns its results. For example, it allows developers to save additional data without having to perform any `.ajax()` calls.

Follow-up to [8973].

Props helgatheviking, helen, Mte90, afercia, mrasharirfan, desrosj, itowhid06, pento, mensmaximus, audrasjb, costdev, webcommsat, marybaum, oglekler, mukesh27, SergeyBiryukov.
Fixes #28112.

git-svn-id: https://develop.svn.wordpress.org/trunk@56091 602fd350-edb4-49c9-b593-d223f7449a82
2023-06-28 13:17:49 +00:00
Marius L. J
7bc7fcff52 Build/Test Tools: Switch frame container when testing block editor output.
The initial commit added the frame lookup within the wrong test, this follow-up restores the previous test runner, and adds the container lookup to the correct test.

Follow-up to [56089].

See #58592.

git-svn-id: https://develop.svn.wordpress.org/trunk@56090 602fd350-edb4-49c9-b593-d223f7449a82
2023-06-28 10:57:48 +00:00