50139 Commits

Author SHA1 Message Date
Greg Ziółkowski
7d0e751ffb Editor: Default attribute value not used with get_block_wrapper_attributes
Ensures that the default values defined in the schema for block attributes are used when rendering the output of the block with `get_block_wrapper_attributes` helper.

Props gziolo, jonsurrell, youknowriad, ryelle.
Fixes #62114.



git-svn-id: https://develop.svn.wordpress.org/trunk@59093 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-26 12:45:41 +00:00
Andrew Ozz
b071c28f8b Administration: Fix increasing of the frequency of Heartbeat API requests.
Props peterwilsoncc, azaozz.
Fixes #61960.

git-svn-id: https://develop.svn.wordpress.org/trunk@59092 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-25 20:49:21 +00:00
Tonya Mork
9e290835d6 Canonical: Redirect when front page's paginated states not found.
Perform a canonical redirect for an invalid pagination request of a static front page.

When a site has a static front page assigned and that page has a `<!--nextpage-->` within its content, previously accessing non-existing pages (e.g. `example.com/page/3/`) did not redirect or return a 404 or 301. This changeset resolves that issue by performing a canonical redirect.

Unit tests are also included for this specific use case and to ensure the fix does not affect a blog listing home page.

Follow-up to [47738], [47727], [34492].

Props dd32, audrasjb, chaion07, hellofromTonya, joemcgill, lukecarbis, Mte90, mukesh27, peterwilsoncc, rajinsharwar, SergeyBiryukov. 
Fixes #50163.
See meta#5184.

git-svn-id: https://develop.svn.wordpress.org/trunk@59091 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-25 19:35:20 +00:00
Sergey Biryukov
b275b38768 Twenty Nineteen: Add missing documentation for helper function parameters.
Follow-up to [43808], [44149], [47214], [47242].

Props pitamdey.
Fixes #62112.

git-svn-id: https://develop.svn.wordpress.org/trunk@59090 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-25 18:06:27 +00:00
Michal Czaplinski
34c861b6a5 Script Loader: Add @wordpress/a11y as a Script Module.
The Script Module has the same API as the `wp-a11y` WP Script.

Key changes:
- Add `@wordpress/a11y` to the list of Script and Module dual packages.
- Update `script-modules-packages.min.php` to include the a11y module.
- Modify `WP_Script_Modules` class to track and handle a11y module availability.
- Add method to print required HTML markup for a11y `speak()` functionality.

See #60647.
Props jonsurrell, gziolo, czapla.


git-svn-id: https://develop.svn.wordpress.org/trunk@59089 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-25 16:49:01 +00:00
Michal Czaplinski
9fc6fa134d Revert [59087] due to empty commit message
git-svn-id: https://develop.svn.wordpress.org/trunk@59088 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-25 16:32:23 +00:00
Michal Czaplinski
6df7ce67ca git-svn-id: https://develop.svn.wordpress.org/trunk@59087 602fd350-edb4-49c9-b593-d223f7449a82 2024-09-25 15:55:56 +00:00
Sergey Biryukov
7f4fd30dff Build/Test Tools: Only require the WordPress Importer plugin when running core tests.
This allows other users of the WordPress unit test suite framework to run their own unit tests without needing the WordPress Importer plugin, which should only be a requirement if running core tests.

Follow-up to [59085].

Props bjorsch.
Fixes #62106.

git-svn-id: https://develop.svn.wordpress.org/trunk@59086 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-24 19:15:33 +00:00
Sergey Biryukov
60a66de6ec Build/Test Tools: Check if the WordPress Importer plugin is installed in test bootstrap.
If a hard requirement for the test suite is not fulfilled, running the tests should be blocked from the test bootstrap. A test should only fail when it doesn't produce the expected result.

Since the WordPress Importer plugin is considered a hard requirement for the test suite at this time, this commit moves the check whether the plugin is installed from individual tests to the test bootstrap.

Includes defining a global constant for the path to the file for reuse in the tests.

Reference: [https://make.wordpress.org/core/handbook/contribute/git/#unit-tests Core Contributor Handbook: The Code Repository (Git): Unit Tests].

Follow-up to [40531], [40532], [41090], [41169], [48592], [49535], [49571].

Props jrf, hellofromTonya.
See #61530.

git-svn-id: https://develop.svn.wordpress.org/trunk@59085 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-24 18:09:41 +00:00
Timothy Jacobs
ec80646878 App Passwords: Don't prevent non-unique App Password names.
In [50030] we enforced that Application Passwords have unique names. This was done with the assumption that applications would not connect to a user multiple times. However, in practice we've seen applications run into issues with the unique name constraint. Depending on the app, they may not know if they've been authorized before, or they may intentionally allow connecting multiple times. To prevent friction, App developers need to make their App Name unique, and in doing so often include things like the current date & time, which is already included in the App Passwords list table.

This commit removes this requirement to simplify usage of the Authorize Application flow.

Props mark-k, Boniu91, timothyblynjacobs, peterwilsoncc.
Fixes #54213.


git-svn-id: https://develop.svn.wordpress.org/trunk@59084 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-24 16:38:36 +00:00
Greg Ziółkowski
0b8b80449f Build: Prepare for more Script Modules
This is a companion to https://github.com/WordPress/gutenberg/pull/65460 that requires syncing in WordPress Core. Namely, the block-library changes require registration with their updated script module IDs so that the blocks continue to work correctly.

They key improvement is script modules registration is handled in one central place, and a combined asset file is used to improve the performance by avoiding multiple disk operations for every individual file.

Props jonsurrell, gziolo, wildworks, noisysocks.
See #60647, #59462.



git-svn-id: https://develop.svn.wordpress.org/trunk@59083 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-24 07:33:55 +00:00
Sergey Biryukov
a39079946a Build/Test Tools: Prevent Composer lock file from being created.
Composer 1.10.0 introduced a `lock` config option, which, when set to `false` will prevent a `composer.lock` file from being created and will ignore it when one exists.

This is a useful option for packages like WordPress where the `lock` file has no meaning.

It also makes life more straightforward for contributors as they don't have to remember that for this repo they should use `composer update` instead of `composer install`. Both will now work the same.

Reference: [https://getcomposer.org/doc/06-config.md#lock Composer Documentation: Config: lock].
 
Follow-up to [51543].

Props jrf.
See #61530.

git-svn-id: https://develop.svn.wordpress.org/trunk@59082 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-23 22:15:11 +00:00
Greg Ziółkowski
fd104aed14 Comments: Pass $page as argument to comments functions
Removes query alteration from `build_comment_query_vars_from_block` by introducing a new way to pass the `$page` as argument to functions handling pagination for the comments.

Props cybr, santosguillamot, bernhard-reiter, gziolo.
Fixes #60806.



git-svn-id: https://develop.svn.wordpress.org/trunk@59081 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-23 12:48:32 +00:00
Greg Ziółkowski
805b9333f2 Block Bindings: Adds context needed by sources during its processing
Extends block context during block bindings processing. This implies that the context is extended ONLY for the blocks where bindings are defined and only when rendered on the page.

Props santosguillamot, gziolo, artemiosans, cbravobernal.
Fixes #61642.




git-svn-id: https://develop.svn.wordpress.org/trunk@59080 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-23 12:33:14 +00:00
Robert Anderson
d2f4251fb1 Editor: Update packages for 6.7 Beta 1.
Syncs `@wordpress/*` packages to the `wp-6.7` npm tag.

See #61906.


git-svn-id: https://develop.svn.wordpress.org/trunk@59079 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-23 06:50:27 +00:00
Sergey Biryukov
e2d9ffcf1e Editor: Respect show_avatars option in block editor and Customizer.
This adds checks for the `show_avatars` option before setting the avatar for post lock modals in the block editor and the Customizer.

Follow-up to [41839], [53070].

Props ffffelix.
Fixes #62081.

git-svn-id: https://develop.svn.wordpress.org/trunk@59078 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-22 22:48:04 +00:00
Sergey Biryukov
f49909e972 Editor: Optimize is_callable() checks in traverse_and_serialize_blocks().
This aims to improve performance by reducing the number of function calls.

Follow-up to [56644].

Props welcher, Cybr, mukesh27, aristath.
Fixes #62063.

git-svn-id: https://develop.svn.wordpress.org/trunk@59077 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-21 14:39:52 +00:00
Dennis Snell
03b12dc311 HTML API: Add normalize() to give us the HTML we always wanted.
HTML often appears in ways that are unexpected. It may be missing implicit tags, may have unquoted, single-quoted, or double-quoted attributes, may contain duplicate attributes, may contain unescaped text content, or any number of other possible invalid constructions. The HTML API understands all fo these inputs, but downline parsers may not, and HTML snippets which are safe on their own may introduce problems when joined with other HTML snippets.

This patch introduces the `serialize()` method on the HTML Processor, which prints a fully-normative HTML output, eliminating invalid markup along the way. It produces a string which contains every missing tag, double-quoted attributes, and no duplicates. A `normalize()` static method on the HTML Processor provides a convenient wrapper for constructing a fragment parser and immediately serializing.

Subclasses relying on the `serialize_token()` method may perform structural HTML modifications with as much security as the upcoming `\Dom\HTMLDocument()` parser will, though these are not
able to provide the full safety that will eventually appear with `set_inner_html()`.

Further work may explore serializing to XML (which involves a number of other important transformations) and adding constraints to serialization (such as only allowing inline/flow/formatting elements and text).

Developed in https://github.com/wordpress/wordpress-develop/pull/7331
Discussed in https://core.trac.wordpress.org/ticket/62036

Props dmsnell, jonsurrell, westonruter.
Fixes #62036.


git-svn-id: https://develop.svn.wordpress.org/trunk@59076 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-20 22:30:04 +00:00
Dennis Snell
675a1aa5e5 HTML API: Add get_full_comment_text() method.
Previously, there were a few cases where the modifiable text read from an HTML comment differs slightly from the parsed value of its inner text in a browser. This is due to the specific way that invalid HTML syntax tokens become "bogus comments."

This patch introduces a new method to the Tag Processor to allow differentiating these specific cases, such as when copying or serializing HTML from one source to another. Similar code has already been in use in the html5lib tests, and this patch simplifies the test runner, evidencing the fact that this method was already needed.

Developed in https://github.com/wordpress/wordpress-develop/pull/7342
Discussed in https://core.trac.wordpress.org/ticket/62036

Props dmsnell, jonsurrell.
See #62036.


git-svn-id: https://develop.svn.wordpress.org/trunk@59075 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-20 20:21:59 +00:00
Sergey Biryukov
1eb5f61c9e Editor: Restore the merging of TinyMCE settings in wp_tinymce_inline_scripts().
This ensures that the function applies the `wp_editor_settings` filter and merges the resulting array with the rest of TinyMCE init settings.

Includes a unit test to verify that the settings are merged correctly after adding the assignment of `array_merge()` result that was missed in the initial commit.

Follow-up to [44265], [59033].

Props kkmuffme, akshat2802, davidbaumwald, SergeyBiryukov.
Fixes #61754.

git-svn-id: https://develop.svn.wordpress.org/trunk@59074 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-20 14:07:11 +00:00
Robert Anderson
35907da951 Editor: Add plugin template registration API and improve theme overrides for plugin-registered templates
This commit introduces a new API to allow plugins to easily register block
templates with `wp_register_block_template()` and the
`WP_Block_Templates_Registry` class, addressing the complexity of hooking into
multiple filters. It also ensures plugin-registered templates overridden by
themes fall back to the plugin-provided title and description when the theme
doesn't define them.

See https://github.com/WordPress/gutenberg/pull/61577.
See https://github.com/WordPress/gutenberg/pull/64610.

Fixes #61804.
Props aljullu, peterwilsoncc, antonvlasenko, azaozz, youknowriad, noisysocks.


git-svn-id: https://develop.svn.wordpress.org/trunk@59073 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-20 02:05:50 +00:00
Robert Anderson
1ad25bb143 Editor: Update packages for 6.7 Beta 1.
Syncs `@wordpress/*` packages to the `wp-6.7` npm tag.

Fixes #61906.
Props peterwilsoncc, gziolo, kevin940726.


git-svn-id: https://develop.svn.wordpress.org/trunk@59072 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-20 01:53:52 +00:00
Peter Wilson
d46067a776 External Libraries: Test registered script versions match package.json.
Expands tests to ensure the version number of packages updated via NPM matches the version number used for registering the script in the script loader.

This adds tests for (by their registered name in WordPress):

* backbone
* clipboard
* hoverIntent
* hoverintent-js
* imagesloaded
* jquery-color
* jquery-core
* jquery-form
* masonry
* react-jsx-runtime
* underscore
* wp-polyfill-dom-rect
* wp-polyfill-element-closest
* wp-polyfill-fetch
* wp-polyfill-formdata
* wp-polyfill-inert
* wp-polyfill-node-contains
* wp-polyfill-object-fit
* wp-polyfill-url


This expands on the earlier tests introduced for:

* lodash
* moment
* react
* react-dom
* regenerator-runtime

An additional test is added to ensure that the data provider for these tests is maintained as libraries are added via package.json.

`@wordpress/*` scripts are excluded from these tests as wp-scripts generates a version number automatically based on the file's contents.

Additionally, the version of element-closest listed in package.json is updated to use a fixed version rather than a range. This reflects the current practice of WordPress to define the specific version in core. For the avoidance of doubt, this does not affect the version shipped in WordPress.

Follow up to [57185].

Props peterwilsoncc, jorbin.
Fixes #61855.


git-svn-id: https://develop.svn.wordpress.org/trunk@59071 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-20 00:50:51 +00:00
Tonya Mork
951f887f8a External Libraries: Skip instanceof check when null in Text_Diff::_check().
On the first `foreach` loop in Text_Diff::_check()`, `$prevtype` is `null`. As `instanceof` requires the class name term to be an object or string, a fatal error is thrown:

>Fatal error: Uncaught Error: Class name must be a valid object or a string on line 279

This change:
* Adds a simple test for the `Text_Diff::_check()` method, which is how the bug was discovered as the test could never pass with the code as-is.

* Adds a defensive guard to protect against the fatal. It checks if `$prevtype` is not `null` as a pre-condition to for checking the instance. This bugfix also resolves the failing test.

Follow-up to [49194], [7747].

Props jrf, hellofromTonya.
See #62083.

git-svn-id: https://develop.svn.wordpress.org/trunk@59070 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-19 20:20:30 +00:00
Tonya Mork
1e608149f9 Code Modernization: handle mysqli_ping() deprecation in wpdb::check_connection().
The `mysqli_ping()` function is deprecated as of PHP 8.4, though, in reality, the function wasn't working according to spec anymore since PHP 8.2 when the `libmysql` driver was dropped in favour of `libmysqlnd`, which was already the default (and recommended) driver since PHP 5.4.

The `mysqli_ping()` method was also not really correctly named as its functionality was to reconnect to the database, not just ping.

The alternative is to "manually" ping the database by sending a `DO 1` query (the cheapest possible SQL query).

Adding a PHP version based toggle was considered, but as mentioned above, the default driver has been `libmysqlnd` since PHP 5.4 and in that case, the function never worked anyway, so in reality `mysqli_ping()` was only really functional for the odd custom PHP compilation where `mysqli` was build against `libmysql` AND `reconnect` was not disabled.

With this in mind, this change replaces the call to `mysqli_ping()` with the `DO 1` query completely. If that query succeeds, it concludes the database connection is still alive. This solution should be the most stable as it will work for both PHP 7.2 <= 8.1, independently of which driver `mysqli` was compiled with, as well as for PHP 8.2+.

Note: It could also be considered to remove the function call to `mysqli_ping()` completely and rely on standard error handling in case the connection would have dropped, as after all, the fact that the connection existed at the moment the "ping" happened, is no guarantee that the connection will still exist when the next query is send.... this approach was not chosen so as WP has custom error handling and does not use the PHP native mysqli exceptions for this, which would make implementing this more awkward.

Includes a test to verify that the connection check works when there is a valid connection (this was previously not covered by tests).

Refs:
* https://wiki.php.net/rfc/deprecations_php_8_4#mysqli_ping_and_mysqliping
* https://github.com/php/php-src/pull/11912#issuecomment-1671762583
* https://stackoverflow.com/questions/2546868/cheapest-way-to-determine-if-a-mysql-connection-is-still-alive/2546922#2546922
* php/php-src#11945
* https://wiki.php.net/rfc/mysqli_support_for_libmysql
* https://www.php.net/mysqli_ping

Follow-up to [56475], [27250], [27075].

Props jrf, hellofromTonya.
See #62061.

git-svn-id: https://develop.svn.wordpress.org/trunk@59069 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-19 18:55:00 +00:00
Tonya Mork
de346c606d Tests: Remove use of E_STRICT.
The `E_STRICT` constant is deprecated as of PHP 8.4 and will be removed in PHP 9.0.

The error level hasn't been in use since PHP 8.0 anyway, so removing the exclusion from the `error_reporting()` setting in the `install.php` script used in the tests should make no difference in practice.

Ref:
* https://wiki.php.net/rfc/deprecations_php_8_4#remove_e_strict_error_level_and_deprecate_e_strict_constant

Follow-up to [25002].

Props jrf.
See #62061.

git-svn-id: https://develop.svn.wordpress.org/trunk@59068 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-19 18:12:36 +00:00
Sergey Biryukov
ceedcb5ae9 Coding Standards: Update PHPCS to version 3.10.3.
PHPCS has seen several new releases since the last update, which means more bugs have been fixed, syntax support for PHP 8.3 was added, more sniff documentation is available, performance improvements, a new Help screen, etc.

References:
* [https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/tag/3.10.3 PHP_CodeSniffer 3.10.3 release notes]
* [https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/tag/3.10.2 PHP_CodeSniffer 3.10.2 release notes]
* [https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/tag/3.10.1 PHP_CodeSniffer 3.10.1 release notes]
* [https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/tag/3.10.0 PHP_CodeSniffer 3.10.0 release notes]
* [https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/tag/3.9.2 PHP_CodeSniffer 3.9.2 release notes]
* [https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/tag/3.9.1 PHP_CodeSniffer 3.9.1 release notes]

Follow-up to [56695], [56799], [57378], [57986].

Props jrf.
Fixes #62076.

git-svn-id: https://develop.svn.wordpress.org/trunk@59067 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-19 12:38:35 +00:00
Sergey Biryukov
e060ee3eb7 Coding Standards: Remove unused return value for WP_Object_Cache::__set().
This resolves a WPCS warning:
{{{
Assignments must be the first block of code on a line
}}}

Note: This is enforced by PHPCS 3.10.3.

Follow-up to [28521], [29146].

Props jrf.
See #62076, #61607.

git-svn-id: https://develop.svn.wordpress.org/trunk@59066 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-19 12:10:19 +00:00
Carolina Nymark
b36055bef3 Bundled Themes: Make text strings translatable.
This changeset updates Twenty Twenty-Three and Twenty Twenty-Four and replaces text strings in HTML files with patterns to make the strings translatable.

Follow-up to [58459].

Props sabernhardt, karmatosed, iflairwebtechnologies, poena.
Fixes #61951.

git-svn-id: https://develop.svn.wordpress.org/trunk@59065 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-19 10:32:34 +00:00
Peter Wilson
bf09fe5066 Date/Time, PHP Compat: Prevent type errors using GMT offset option.
Prevents a potential type errors when making use of the `gmt_offset` option by casting the value to a float prior to performing calculations with the value.

This mainly accounts for incorrect storage of values, such as an empty string or city name.

Follow up to [58923].

Props chaion07, hellofromtonya, kirasong, mhshohel, mukesh27, nicolefurlan, nihar007, nurielmeni, oglekler, peterwilsoncc, prionkor, rajinsharwar, rarst, rleeson, sabernhardt, SergeyBiryukov, swissspidy, toastercookie, verygoode.
Fixes #56358, #58986, #60629.


git-svn-id: https://develop.svn.wordpress.org/trunk@59064 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 22:35:35 +00:00
Tonya Mork
3b24863861 Code Modernization: Remove xml_set_object() in MagpieRSS::__construct().
The XML Parser extension still supports a quite dated mechanism for method based callbacks, where the object is first set via `xml_set_object()` and the callbacks are then set by passing only the name of the method to the relevant parameters on any of the `xml_set_*_handler()` functions.

{{{
xml_set_object( $parser, $my_obj );
xml_set_character_data_handler( $parser, 'method_name_on_my_obj' );
}}}

Passing proper callables to the `xml_set_*_handler()` functions has been supported for the longest time and is cross-version compatible. So the above code is 100% equivalent to:

{{{
xml_set_character_data_handler( $parser, [$my_obj, 'method_name_on_my_obj'] );
}}}

The mechanism of setting the callbacks with `xml_set_object()` has now been deprecated as of PHP 8.4, in favour of passing proper callables to the `xml_set_*_handler()` functions. This is also means that calling the `xml_set_object()` function is deprecated as well.

This commit fixes this deprecation for the `MagpieRSS::__construct()` method.

The change has not been not covered by tests. This class has been deprecated since WP 3.0.0 and is not covered by tests at all. Adding those now seems superfluous, all the more as the principle of the fix is no different than for the other files, so we can be sure it works anyway.

Note: Though this is "officially" an external library, this package is no longer externally maintained. The code style of the fix in the source file is in line with the existing code style for the file.

Refs:
* https://wiki.php.net/rfc/deprecations_php_8_4#xml_set_object_and_xml_set_handler_with_string_method_names
* https://www.php.net/manual/en/function.xml-set-object.php
* https://www.php.net/manual/en/ref.xml.php

Follow-up to [4399].

Props jrf.
See #62061.

git-svn-id: https://develop.svn.wordpress.org/trunk@59063 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 21:38:32 +00:00
Tonya Mork
ce571018a9 Code Modernization: Remove xml_set_object() in AtomParser::parse().
The XML Parser extension still supports a quite dated mechanism for method based callbacks, where the object is first set via `xml_set_object()` and the callbacks are then set by passing only the name of the method to the relevant parameters on any of the `xml_set_*_handler()` functions.

{{{
xml_set_object( $parser, $my_obj );
xml_set_character_data_handler( $parser, 'method_name_on_my_obj' );
}}}

Passing proper callables to the `xml_set_*_handler()` functions has been supported for the longest time and is cross-version compatible. So the above code is 100% equivalent to:

{{{
xml_set_character_data_handler( $parser, [$my_obj, 'method_name_on_my_obj'] );
}}}

The mechanism of setting the callbacks with `xml_set_object()` has now been deprecated as of PHP 8.4, in favour of passing proper callables to the `xml_set_*_handler()` functions. This is also means that calling the `xml_set_object()` function is deprecated as well.

This commit fixes this deprecation for the `AtomParser::parse()` method.

This change is safeguarded via the new `AtomParser_Parse_Test` class.

Notes:
* Though this is "officially" an external library, this package is no longer externally maintained. The code style of the fix in the source file is in line with the existing code style for the file.
* It appears that this class is not actually used by WP Core itself, so it could be considered to deprecate the class. However, as the class is not currently deprecated, safeguarding the change with a test seemed prudent.
* The fixture used for the test reuses a fixture from the original package: https://code.google.com/archive/p/phpatomlib/source/default/source
* The new test class follows the recommended test format (naming convention of the class, `@covers` tag at class level, only testing one method) as per Trac tickets 62004 / 53010.

Refs:
* https://wiki.php.net/rfc/deprecations_php_8_4#xml_set_object_and_xml_set_handler_with_string_method_names
* https://www.php.net/manual/en/function.xml-set-object.php
* https://www.php.net/manual/en/ref.xml.php

Follow-up to [5951].

Props jrf.
See #62061.

git-svn-id: https://develop.svn.wordpress.org/trunk@59062 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 21:18:54 +00:00
Tonya Mork
f9f19c7e77 Tests: Use file paths independent of OS-specifics assertion or helper.
Use `WP_UnitTestCase_Base::assertSamePathIgnoringDirectorySeparators()` and `WP_UnitTestCase_Base::normalizeDirectorySeparatorsInPath()` in existing tests.

Follow-up to [59057], [57753], [57215], [56635], [48937], [25002].

Props jrf.
See #61530.

git-svn-id: https://develop.svn.wordpress.org/trunk@59061 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 21:04:48 +00:00
Dennis Snell
5168e1933a WP_Debug_Data: Extract wp-media data into separate method.
This is the sixth part in a larger modularization of the data in `WP_Debug_Data`. Previously this was a single massive method drawing in debug data from various groups of related data, where the groups were independent from each other.

This patch separates the sixth of twelve groups, the `wp-media` info, into a separate method focused on that data.

This work precedes changes to make the `WP_Debug_Data` class more extensible for better use by plugin and theme code.

Developed in https://github.com/wordpress/wordpress-develop/pull/7356
Discussed in https://core.trac.wordpress.org/ticket/61648

Props apermo, dmsnell.
See #61648.


git-svn-id: https://develop.svn.wordpress.org/trunk@59060 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 19:10:56 +00:00
Drew Jaynes
a543c31a1d Docs: The $feedname parameter in add_feed() should not start with an underscore.
Props snehapatil02, hellofromtonya, narenin.
Fixes #59945.


git-svn-id: https://develop.svn.wordpress.org/trunk@59059 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 19:06:45 +00:00
Tonya Mork
55aa76aa25 Code Modernization: Explicitly declare all properties in AtomParser.
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's 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 build 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 property added are explicitly referenced in this class, so fall in the "known property" category.

Refs:
* https://wiki.php.net/rfc/deprecate_dynamic_properties

Props jrf.
See #56034.

git-svn-id: https://develop.svn.wordpress.org/trunk@59058 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 18:44:15 +00:00
Tonya Mork
e6a8fdd754 Tests: Introduce assertion for comparing file paths independent of OS-specifics.
Introduces `WP_UnitTestCase_Base::assertSamePathIgnoringDirectorySeparators()` and an associated helper method `WP_UnitTestCase_Base::normalizeDirectorySeparatorsInPath()` to allow for comparing two file path strings independently of OS-specific differences.

The normalization is done in a separate method to also allow this method to be used for path normalization within test methods themselves, like for normalizing a group of paths in an array.

The pretty specific method name for the helper (`normalizeDirectorySeparatorsInPath()`) is an attempt to prevent naming conflicts with methods which may exist in plugin test suites build on top of the WP Core test suite.

Props jrf, hellofromTonya.
See #61530.

git-svn-id: https://develop.svn.wordpress.org/trunk@59057 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 18:20:43 +00:00
Tonya Mork
baff405508 Code Modernization: Remove xml_set_object() in IXR_Message::parse().
The XML Parser extension still supports a quite dated mechanism for method based callbacks, where the object is first set via `xml_set_object()` and the callbacks are then set by passing only the name of the method to the relevant parameters on any of the `xml_set_*_handler()` functions.

{{{
xml_set_object( $parser, $my_obj );
xml_set_character_data_handler( $parser, 'method_name_on_my_obj' );
}}}

Passing proper callables to the `xml_set_*_handler()` functions has been supported for the longest time and is cross-version compatible. So the above code is 100% equivalent to:

{{{
xml_set_character_data_handler( $parser, [$my_obj, 'method_name_on_my_obj'] );
}}}

The mechanism of setting the callbacks with `xml_set_object()` has now been deprecated as of PHP 8.4, in favour of passing proper callables to the `xml_set_*_handler()` functions. This is also means that calling the `xml_set_object()` function is deprecated as well.

This commit fixes this deprecation for the `IXR_Message::parse()` method.

This change is safeguarded via the new`Tests_XMLRPC_Message::test_parse_sets_handlers()` test method.

Note: Though this is "officially" an external library, this package is no longer externally maintained. The code style of the fix in the source file is in line with the existing code style for the file.

Refs:
* https://wiki.php.net/rfc/deprecations_php_8_4#xml_set_object_and_xml_set_handler_with_string_method_names
* https://www.php.net/manual/en/function.xml-set-object.php
* https://www.php.net/manual/en/ref.xml.php

Follow-up to [15612], [1346].

Props jrf, hellofromTonya.
See #62061.

git-svn-id: https://develop.svn.wordpress.org/trunk@59056 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 18:02:43 +00:00
Tonya Mork
224e2c17b2 Tests: Remove use of xml_set_object() in TestXMLParser.
The XML Parser extension still supports a quite dated mechanism for method based callbacks, where the object is first set via `xml_set_object()` and the callbacks are then set by passing only the name of the method to the relevant parameters on any of the `xml_set_*_handler()` functions.

{{{
xml_set_object( $parser, $my_obj );
xml_set_character_data_handler( $parser, 'method_name_on_my_obj' );
}}}

Passing proper callables to the `xml_set_*_handler()` functions has been supported for the longest time and is cross-version compatible. So the above code is 100% equivalent to:

{{{
xml_set_character_data_handler( $parser, [$my_obj, 'method_name_on_my_obj'] );
}}}

The mechanism of setting the callbacks with `xml_set_object()` has now been deprecated as of PHP 8.4, in favour of passing proper callables to the `xml_set_*_handler()` functions. This is also means that calling the `xml_set_object()` function is deprecated as well.

This commit fixes this deprecation for the `TestXMLParser` helper utility. In this case, the callbacks were already using the recommended format and the call to `xml_set_object()` was completely redundant.

As this is a test utility and was already causing pre-existing tests using the utility to fail, there is no need for dedicated tests to cover this change.

Refs:
* https://wiki.php.net/rfc/deprecations_php_8_4#xml_set_object_and_xml_set_handler_with_string_method_names
* https://www.php.net/manual/en/function.xml-set-object.php
* https://www.php.net/manual/en/ref.xml.php

Follow-up to [25002].

Props jrf.
See #62061.

git-svn-id: https://develop.svn.wordpress.org/trunk@59055 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 17:24:30 +00:00
Tonya Mork
1324176d51 Tests: Fix Tests_Theme tests to run (and pass) cross-OS.
Uses `DIRECTORY_SEPARATOR` in closures for cross-OS differences.

Follow-up to [56635].

Props jrf.
See #61530.

git-svn-id: https://develop.svn.wordpress.org/trunk@59054 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 16:16:19 +00:00
Tonya Mork
82171f5036 Code Modernization: Fix implicitly nullable parameter in WP_HTML_Processor.
PHP 8.4 deprecates implicitly nullable parameters, i.e. typed parameters with a `null` default value, which are not explicitly declared as nullable.

This commit the one instance of this in the `WP_HTML_Processor` class.

Fixed by adding the nullability operator to the type, which is supported since PHP 7.1, so we can use it now the minimum supported PHP version is PHP 7.2.

As this deprecation is thrown at compile time, it can be seen at the top of the test output when running on PHP 8.4 (which will be gone once this change has been committed). It is not possible to write a test to cover this.

Ref: https://wiki.php.net/rfc/deprecate-implicitly-nullable-types

Follow-up to [58867], [58769], [58304], [58192].

Props jrf.
See #62061.

git-svn-id: https://develop.svn.wordpress.org/trunk@59053 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 15:02:14 +00:00
Tonya Mork
8fc4a000fc Tests: Fix implicitly nullable parameters in Tests_HtmlApi_WpHtmlProcessorComments.
PHP 8.4 deprecates implicitly nullable parameters, i.e. typed parameters with a `null` default value, which are not explicitly declared as nullable.

The `Tests_HtmlApi_WpHtmlProcessorComments` test class contains one problematic parameter in the `test_comment_processing()` method declaration.

While this could be fixed by adding the nullability operator, the type declarations in the test method is removed instead, including other type declarations for this method and the second test method, which were not affected by the deprecation.

The reason for this is quite straight-forward: using type declarations in tests is bad practice and inhibits defense-in-depth type testing.

Using type declarations in tests prevents being able to test the "code under test" with unexpected input types as the values with unexpected (scalar) types will be juggled to the expected type between the data provider and the test method and the _real_ data value would therefore never reach the method under test.

The knock-on effects of this are:
* That the input handling of the "code under test" can not be safeguarded, whether this input handling is done via in-function type checking or via a type declaration in the "code under test".
* That if such "unexpected data type" tests are added to the data provider, they will silently pass (due to the type being juggled before reaching the "code under test"), giving a false sense of security, while in actual fact, these data sets would not be testing anything at all and if, for instance, the type declaration in the "code under test" would be removed, these tests would still pass, while by rights they should start failing.

Also note that this problem would only be exacerbated if the file would be put under `strict_types`.

Ref: https://wiki.php.net/rfc/deprecate-implicitly-nullable-types

Follow-up to [58734].

Props jrf.
See #62061.

git-svn-id: https://develop.svn.wordpress.org/trunk@59052 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 14:53:32 +00:00
Sergey Biryukov
91f8e77b3e Script Loader: Restore user-profile.js dependencies after an accidental revert.
Follow-up to [59033], [59046], [59047].

Props TobiasBg.
See #61754.

git-svn-id: https://develop.svn.wordpress.org/trunk@59051 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 14:22:27 +00:00
Drew Jaynes
d8e05446b7 Docs: Add missing @since and @param annotations for the edit_post_{$field} hook doc.
Props mukesh27
See #50654


git-svn-id: https://develop.svn.wordpress.org/trunk@59050 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 06:02:15 +00:00
Jonathan Desrosiers
a6166f1434 Build/Test Tools: Submit host test results for each PHP version.
The WordPress Hosting Test Results now supports multiple reports for the same commit from the same test bot. This updates the PHPUnit test workflow to submit results for each version of PHP running the tests.

Props swissspidy, jorbin, crixu, kirasong, desrosj.
See #61564.

git-svn-id: https://develop.svn.wordpress.org/trunk@59049 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 05:42:16 +00:00
ramonopoly
52d46a9cb3 Global Styles: allow read access to users with edit_posts capabilities
This patch any role that can edit a post, including custom post types, or edit theme options to read global styles from the API. This enables read-only access to global styles in the post editor. Test coverage in included.

Props ramonopoly, peterwilsoncc, mukesh27, aaronrobertshaw, mamaduka, spacedmonkey, talldanwp, timothyblynjacobs.
Fixes #62042.




git-svn-id: https://develop.svn.wordpress.org/trunk@59048 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 05:17:05 +00:00
David Baumwald
6693c25c8a Script Loader: Revert removing unused array_merge.
Code is poetry, until it isn’t.

Unprops davidbaumwald.
See #61754.

git-svn-id: https://develop.svn.wordpress.org/trunk@59047 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 00:46:43 +00:00
Jeremy Felt
5d0753bb6e Application Passwords: Add copy button when adding new password.
Props circlecube, dhruvang21, ironprogrammer, desrosj.
Fixes #62019.


git-svn-id: https://develop.svn.wordpress.org/trunk@59046 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 00:12:52 +00:00
Drew Jaynes
b0809808e2 Docs: Add possible filter names to the hook docs for the following filters in sanitize_post_field():
- `edit_{$field}`
- `{$field_no_prefix}_edit_pre`
- `edit_post_{$field}`
- `pre_{$field}`
- `{$field_no_prefix}_save_pre`
- `pre_post_{$field}`
- `{$field}_pre`
- `{$field}`
- `post_{$field}`

Props johnbillion, DrewAPicture.
Fixes #50654


git-svn-id: https://develop.svn.wordpress.org/trunk@59045 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-18 00:00:08 +00:00
Aaron Jorbin
e9bb88d8c2 Bootstrap/Load: Add documentation warning about updating $table_prefix.
Props bjerke-johannessen, swissspidy, SergeyBiryukov, morganestes, stevenlinx, jorbin.
Fixes #34189.


git-svn-id: https://develop.svn.wordpress.org/trunk@59044 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-17 23:56:10 +00:00