Commit Graph

6141 Commits

Author SHA1 Message Date
bcd25b14ec Introduce Token Map: An optimized static translation class.
This patch introduces a new class: `WP_Token_Map`, designed for efficient
lookup and translation of static mappings between string keys or tokens, and
string replacements (for example, HTML character references).

The Token Map imposes certain restrictions on the byte length of the lookup
tokens and their replacements, but is a highly-optimized data structure for
mappings with a very high number of tokens.

Developed in https://github.com/WordPress/wordpress-develop/pull/5373
Discussed in https://core.trac.wordpress.org/ticket/60698

Fixes #60698.
Props: dmsnell, gziolo, jonsurrell, jorbin.


git-svn-id: https://develop.svn.wordpress.org/trunk@58188 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-23 19:54:17 +00:00
932895b827 Editor: Update npm packages.
Updates the editor npm packages to latest versions.

See https://github.com/WordPress/wordpress-develop/pull/6612.

Props ellatrix, mukesh27, youknowriad, mamaduka.



git-svn-id: https://develop.svn.wordpress.org/trunk@58187 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-23 19:37:08 +00:00
b815a36260 Block Hooks API: Insert metadata at the same time as hooked blocks.
The Block Hooks UI relies on the `ignoredHookedBlocks` metadata when determining whether to show the toggle in the Site Editor. The problem is that for uncustomized templates we don't add this metadata.

Currently the visitor functions have a default callback of `insert_hooked_blocks` and we only add the metadata when we're writing to the database via an available filter in the template controller.

This changeset creates a new callback which both inserts the hooked blocks and adds the `ignoredHookedBlocks` metadata to the anchor block, and uses this new callback explicitly in the visitor functions that are run upon reading from the database.

We continue to set the `ignoredHookedBlocks` metadata when writing to the database, i.e. this operation happens twice. Although not ideal, this is necessary to cover the following scenarios:

* When the user adds an anchor block within the editor, we still need to add the `ignoredHookedBlocks` meta to it to prevent hooked blocks hooking on to it unexpectedly on the frontend. This is required to keep parity between the frontend and editor.
* When a user writes template data to the database directly through the API (instead of the editor), we need to again ensure we're not inserting hooked blocks unexpectedly.

It is worth noting that with this change, the first hooked block to insert relative to its anchor block will be accepted. Any additional blocks of the same type (e.g. a second `core/loginout` block) trying to hook onto the same anchor block will be ignored, irrespective of the position.

Props tomjcafferkey, bernhard-reiter, gziolo.
Fixes #59574.

git-svn-id: https://develop.svn.wordpress.org/trunk@58186 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-23 18:33:11 +00:00
e085371f09 Tests: Use assertSame() in navigation fallback tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Follow-up to [56052].

See #60705.

git-svn-id: https://develop.svn.wordpress.org/trunk@58183 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-22 15:39:51 +00:00
6662cb0bef Options, Meta APIs: Introduce wp_prime_network_option_caches() to load multiple network options with a single database request.
WordPress's `get_network_option` function generally makes individual database requests for each network option. While some options are preloaded in `wp_load_core_site_options`, many still require single database calls to the network options table.

Building on the work done in [56445], [56990], and [57013], which introduced the `wp_prime_option_caches` function, this commit adds two new functions: `wp_prime_network_option_caches` and `wp_prime_site_option_caches`. These functions enable developers to pass an array of option names, allowing caches for these options to be primed in a single object cache or database request. If an option is not found, the notoptions cache key is refreshed, preventing unnecessary repeated requests.

The function `wp_prime_site_option_caches` is similar to `get_site_option`, enabling developers to retrieve network options on the current network without needing to know the current network ID. If these functions are called in a non-multisite environment, they fall back to using wp_prime_option_caches.

These functions have been implemented in `wp_load_core_site_options`, `get_site_transient`, and `set_site_transient`.

Props to spacedmonkey, peterwilsoncc, mukesh27, joemcgill.
Fixes #61053.

git-svn-id: https://develop.svn.wordpress.org/trunk@58182 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-21 21:36:43 +00:00
c7db7886b8 Tests: Use assertSame() in block support tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Includes renaming a few test classes per the naming conventions.

Reference: [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization Writing PHP Tests: Naming and Organization].

Follow-up to [53076], [53085], [54497], [56046], [56614], [57246], [57491].

See #60705.

git-svn-id: https://develop.svn.wordpress.org/trunk@58181 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-21 10:31:51 +00:00
c356242d85 Tests: Correct a number of invalid @covers tags.
This resolves a few warnings when running PHPUnit with the code coverage report:
{{{
"@covers WP_Privacy_Requests_List_Table::get_views" is invalid
"@covers WP_Block_Bindings_Registry::register_block_bindings_source" is invalid
"@covers WP_Block_Patterns_Registry::_register_theme_block_patterns" is invalid
}}}

The two removed `@coversDefaultClass` annotations are redundant, as the class name is already included in the individual `@covers` tags. Removing them allows `@covers ::_register_theme_block_patterns` to work as expected, where `_register_theme_block_patterns` is an standalone function, not a class method.

Follow-up to [54215], [56733], [57373], [57562].

See #60705.

git-svn-id: https://develop.svn.wordpress.org/trunk@58176 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-20 14:38:33 +00:00
ce84e1f5de Posts: Ensure get_sample_permalink returns the right permalink for auto-draft posts.
The post editor uses the permalink_template property from the posts REST API to render the post slug input or not. For auto-drafts or newly created posts, this property was not set properly. This PR solves by fixing the get_sample_permalink function used to compute this property.

Props youknowriad, mcsf, antonvlasenko, azaozz, peterwilsoncc, andrewserong, hellofromTonya, spacedmonkey.
Fixes #59283.

git-svn-id: https://develop.svn.wordpress.org/trunk@58174 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-20 09:47:41 +00:00
a557bae878 Editor: Fix unit tests for fluid typography CSS.
Fixes a unit test to assert that CSS variables are defined in `:root{}` rather than `body{}`. Fixes a couple of docblocks in the same file.

Follow up to [58171].

Props ramonopoly.
See #61118.


git-svn-id: https://develop.svn.wordpress.org/trunk@58173 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-20 05:22:13 +00:00
39ff61ed40 Editor: pass fluid typography theme.json settings to wp_get_typography_font_size_value.
Updates `wp_get_typography_font_size_value` to accept an array of theme.json settings instead of a boolean derived from global state.

Props ramonopoly, audrasjb.
Fixes #61118.


git-svn-id: https://develop.svn.wordpress.org/trunk@58171 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-18 23:16:09 +00:00
2b25b04f93 Editor: add column and row spans to grid children.
Adds support for setting spans using `grid-column` and `grid-row` properties on children of blocks with grid layout.

Props isabel_brison, andrewserong, peterwilsoncc, mukesh27.
Fixes #61111.


git-svn-id: https://develop.svn.wordpress.org/trunk@58170 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-18 20:30:57 +00:00
236a7e0fbf Tests: Remove trailing characters from @ticket annotations.
Follow-up to [44693], [46209], [54230], [54733], [55151].

Props jonsurrell.
See #61238.

git-svn-id: https://develop.svn.wordpress.org/trunk@58164 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-17 13:11:27 +00:00
9614cf5378 Script Loader: Update failing test after [58162].
See #60962.

git-svn-id: https://develop.svn.wordpress.org/trunk@58163 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-16 17:24:30 +00:00
23a455efdb Tests: Use assertSame() in block_has_support() tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Follow-up to [56382].

See #60706.

git-svn-id: https://develop.svn.wordpress.org/trunk@58160 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-16 15:13:43 +00:00
13d5244c43 Improve legibility of JSON-encoded Interactivity API store data.
The Interactivity API has been rendering client data in a SCRIPT element with the
type `application/json` so that it's not executed as a script, but is available
to one. The data runs through `wp_json_encode()` and is encoded with some flags
to ensure that potentially-dangerous characters are escaped.

However, this can lead to some challenges. Eagerly escaping when not necessary
can make the data difficult to comprehend when reading the output HTML. For example,
all non-ASCII Unicode characters are escaped with their code point equivalent.
This results in `\ud83c\udd70` instead of `🅰`.

In this patch, the flags for JSON encoding are refined to ensure what's necessary
while relaxing other rules (leaving in those Unicode characters if the blog charset
is UTF-8). This makes for Interactivity API data that's quicker as a human reader
to decipher and diagnose.

In summary:

 - This data is JSON encoded and printed in a `<script type="application/json">` tag.

 - If we ensure that `<` is never printed inside the data, it should be impossible to
   break out of the script tag and the browser treats everything as the element's `textContent`.

 - All other escaping becomes unnecessary at that point, including unicode escaping 
   if the page uses the UTF-8 charset (the same encoding as JSON).

See https://github.com/WordPress/wordpress-develop/pull/6433#pullrequestreview-2043218338

Developed in https://github.com/WordPress/wordpress-develop/pull/6520
Discussed in https://core.trac.wordpress.org/ticket/61170

Fixes: #61170
Follow-up to: [57563].
Props: bjorsch, dmsnell, jonsurrell, sabernhardt, westonruter.


git-svn-id: https://develop.svn.wordpress.org/trunk@58159 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-15 17:40:44 +00:00
560d18d65c Tests: Use assertSame() in absint() tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Includes correcting a few erroneously duplicated test cases to match their intended purpose.

Follow-up to [57724].

See #60706.

git-svn-id: https://develop.svn.wordpress.org/trunk@58150 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-15 01:07:35 +00:00
d4967a3619 Normalize UTF-8 charset slug detection.
There are several exist places in Core that attempt to detect if a blog charset
is UTF-8. Each place attempts to perform the same check, except the logic is
spread throughout and there's no single method provided to make this
determination in a consistent way. The `_canonical_charset()` method exists,
but is marked private for use.

In this patch the new `unicode` module provides `is_utf8_charset()` as a method
taking an optional charset slug and indicating if it represents UTF-8,
examining all of the allowable variants of that slug. Associated code is
updated to use this new function, including `_canonical_charset()`. If no slug
is provided, it will look up the current `get_option( 'blog_charset' )`.

Finally, the test functions governing `_canonical_charset()` have been
rewritten as a single test with a data provider instead of as separate test
functions.

Developed in https://github.com/WordPress/wordpress-develop/pull/6535
Discussed in https://core.trac.wordpress.org/ticket/61182

Fixes #61182.
Props dmsnell, jonsurrell.


git-svn-id: https://develop.svn.wordpress.org/trunk@58147 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-14 18:03:43 +00:00
b4889e474c Embeds: Enable lazy-loading of post embeds and fix keyboard a11y for hidden iframes.
Chrome unreliably loads a lazy-loaded iframe when it is hidden using `clip: rect(1px, 1px, 1px, 1px)`. Instead of using `clip`, a lazy-loaded iframe can also be hidden with `visibility:hidden` which results in it loading not only in Chrome but all other browsers. With this change applied, the hard-coded check to prevent lazy-loading post embeds is now removed. An added benefit to using `visibility:hidden` is that the entire iframe in this case is not interactable, meaning that users navigating the document with the keyboard will not unexpectedly encounter tab stops inside of the hidden iframe, as can happen now with `clip` when the JS fails to reveal the loaded iframe. Note also that the `clip` property is deprecated.

Lastly, when such a post embed iframe is rendered in an RSS feed, the `style` attribute is now removed using the HTML Tag Processor as opposed to using string replacement.

Fixes #58773.
Props westonruter, joemcgill, swissspidy, joedolson, adamsilverstein.


git-svn-id: https://develop.svn.wordpress.org/trunk@58143 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-13 22:37:38 +00:00
5584f649ae Tests: Move add_settings_section() tests to a more appropriate place.
Follow-up to [54247].

See #60705.

git-svn-id: https://develop.svn.wordpress.org/trunk@58136 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-12 15:54:33 +00:00
ea8bc973b4 Options, Meta APIs: Prime transient options prior to use.
Reduce the number of queries getting and setting transients on sites without a persistent cache. 

Transients are stored in two options: one each for the transient value and timeout. Priming the cache reduces the database queries for getting a transient from two to one.

Props peterwilsoncc, swissspidy.
Fixes #61193.



git-svn-id: https://develop.svn.wordpress.org/trunk@58134 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-11 23:51:55 +00:00
4304be07f3 REST API: Ensure attachments are uploaded to the post's year/month folder.
If organizing uploads into month- and year-based folders, uploading an attachment to an existing post should store the file in `wp-content/uploads/<year>/<month>` based on the post's publish date. This is in line with the behavior in classic editor / the media modal.

Props swissspidy, adamsilverstein, timothyblynjacobs, skithund, sergeybiryukov, patricia70.
Fixes #61189.

git-svn-id: https://develop.svn.wordpress.org/trunk@58130 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-10 18:57:53 +00:00
3f3a4f96dd Posts, Post Types: Use a consistent plural form of “status” in variable names.
Follow-up to [5575], [6796], [6993], [7638], [12162], [12719], [15578], [16652], [31046], [34515], [49472].

Props Presskopp, sabernhardt, manfcarlo, SergeyBiryukov.
Fixes #58134.

git-svn-id: https://develop.svn.wordpress.org/trunk@58129 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-10 18:07:17 +00:00
08b4dd3b8b Editor: move global CSS custom properties to :root selector.
Changes the rules outputting global styles CSS custom properties to use `:root` instead of `body`, and cleans up some unused variables.

Props ramonopoly, isabel_brison.
Fixes #61135.


git-svn-id: https://develop.svn.wordpress.org/trunk@58123 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-09 04:07:53 +00:00
3a6cca9ff7 Query: Improve cache key generation.
Query caching in `WP_Query` was added in [53941]. When this functionality was added to the `WP_Query` class, a number of edge cases were missed that would result in redundant duplicate queries. It was possible to pass parameters to `WP_Query` that would be different but would result in the same database query being generated. As the cache key is generated from a mixture of query arguments and the SQL query, this resulted in different cache keys for the same database query, resulting in unnecessary duplicate queries. In this change, the logic in the `generate_cache_key` method has been improved to ensure reuse of existing caches. The following edge cases have been considered:

- Passing `post_type` as an empty string.
- Passing `post_type` as the string `any`.
- Passing `post_type` as array vs. string.
- Passing `post_type` as an array in a different order.
- Not passing `orderby`.
- Passing `post_status` as an array vs. string.
- Passing `post_status` as an array in a different order.

This change also fixes an issue where the old SQL query would not match, as the queries had different whitespaces. 

Props spacedmonkey, joemcgill, pbearne, peterwilsoncc, rajinsharwar, mukesh27, thekt12, huzaifaalmesbah, rodionov201.
Fixes #59442.

git-svn-id: https://develop.svn.wordpress.org/trunk@58122 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-08 22:49:46 +00:00
06627e8acd Cron API: Add tests for associative and indexed array arguments when rescheduling a cron event.
Props johnbillion, peterwilsoncc

See #57271


git-svn-id: https://develop.svn.wordpress.org/trunk@58109 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-06 18:47:42 +00:00
f08a369445 Build/Test Tools: Standardise the assertions for remote HTTP request tests.
This ensures that as much information as possible is shown when an HTTP request fails during an external HTTP test.

Fixes #61148


git-svn-id: https://develop.svn.wordpress.org/trunk@58108 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-06 18:39:15 +00:00
7750458133 Bootstrap/Load: Add support for custom ports in multisite site addresses.
This allows a Multisite network to use an address that includes a port name, such as `example.com:1234`, and adds support for this to the local development environment too. You can now run a Multisite installation on the local development environment, for example at `localhost:8889`.

This also fixes some bugs with running a single site installation on a port, and updates the testing infrastructure so that the whole test suite runs both with and without a port number.

Props djzone, scribu, nacin, ipstenu, F J Kaiser, jeremyfelt, johnjamesjacoby, spacedmonkey, PerS, Clorith, Blackbam, enrico.sorcinelli, Jules Colle, obliviousharmony, desrosj, johnbillion

Fixes #21077, #52088

git-svn-id: https://develop.svn.wordpress.org/trunk@58097 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-04 19:23:31 +00:00
6b328e6915 Editor: add Style Engine support for nested CSS rules.
Adds support for passing a `$rules_group` string to wp_style_engine_get_stylesheet_from_css_rules(), so rules can be nested under a media query, layer or other rule.

Props isabel_brison, ramonopoly.
Fixes #61099.


git-svn-id: https://develop.svn.wordpress.org/trunk@58089 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-03 04:45:20 +00:00
91c546d47a REST API: Return empty object when no fallback templates are found (wp/v2/templates/lookup)
This prevents a number of php notices that are surfaced due to the endpoint being called on load of the post editor even when there are no templates.

Props grantmkin, CookiesForDevo, britner, wildworks, jorbin.
Fixes #60909.


git-svn-id: https://develop.svn.wordpress.org/trunk@58079 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-02 16:01:29 +00:00
cc3055e5c4 Editor: Merge element style and classname generation to single filter.
Fixes element classnames not being output when block attributes are filtered with `render_block_data`.

Props aaronrobertshaw, isabel_brison, jorbin.
Fixes #60681.



git-svn-id: https://develop.svn.wordpress.org/trunk@58074 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-02 06:59:30 +00:00
ec1110c719 Docs: Various docblock corrections.
See #60699


git-svn-id: https://develop.svn.wordpress.org/trunk@58073 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-01 23:59:03 +00:00
a8d5879867 HTML API: Fix context reset in html5lib test suite.
The html5lib-tests suite parses tests from a number of files with a specific
data format. It uses a dataProvider in a loop that yields test information.
This relies on some variables being reset on each iteration. The context
element has not properly reset on each iteration.

The test specification describes the context element as follows:
a9f44960a9/tree-construction/README.md

> Then there *may* be a line that says "#document-fragment", which must be
> followed by a newline (LF), followed by a string of characters that indicates
> the context element, followed by a newline (LF). If the string of characters
> starts with "svg ", the context element is in the SVG namespace and the
> substring after "svg " is the local name. If the string of characters starts
> with "math ", the context element is in the MathML namespace and the
> substring after "math " is the local name. Otherwise, the context element is
> in the HTML namespace and the string is the local name. If this line is
> present the "#data" must be parsed using the HTML fragment parsing algorithm
> with the context element as context.

Without the proper reset of this value, a single context element would change
subsequent tests, breaking the test suite.

This patch adds the reset to ensure that the test suite works properly.

Developed in https://github.com/WordPress/wordpress-develop/pull/6464
Discussed in https://core.trac.wordpress.org/ticket/61102

Fixes #61102.
Props costdev, dmsnell, jonsurrell.


git-svn-id: https://develop.svn.wordpress.org/trunk@58072 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-01 23:43:11 +00:00
ebc66bb9a1 Tests: Use assertSame() in wp_validate_redirect() tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Follow-up to [36444].

Props costdev.
See #60706.

git-svn-id: https://develop.svn.wordpress.org/trunk@58070 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-01 18:54:36 +00:00
816ff687eb Script Loader: Ensure wp_localize_script() works when called early.
Before, `wp_localize_script()` did not work when the `$wp_scripts` global was not already set (for example because of a script registration happening elsewhere) and even emitted a warning in that case. Due to side effects such as block registration early in the load process, this usually never happened. However, the absence of these side effects in 6.5 caused the `wp_localize_script()` to no longer work in places such as the `login_enqueue_scripts`.

By calling `wp_scripts()` in `wp_localize_script()`, the `$wp_scripts` global is automatically set if needed, restoring previous behavior. Adds both a PHP unit test and an e2e test to verify this use case. Hat tip: jorbin.

Happy birthday, Aaron!

Props salcode, aslamdoctor, jorbin, swissspidy.
Fixes #60862.

git-svn-id: https://develop.svn.wordpress.org/trunk@58068 602fd350-edb4-49c9-b593-d223f7449a82
2024-05-01 15:40:02 +00:00
f9e5c6fb22 REST API: allow overriding excerpt length.
This can be used by the excerpt block in the editor to change the excerpt length without filtering `excerpt_length` in a conflicting way. This enhancement still needs a corresponding change on the Gutenberg side.

Props swissspidy, antonvlasenko, mukesh27, azaozz, andraganescu, timothyblynjacobs.
Fixes #59043.

git-svn-id: https://develop.svn.wordpress.org/trunk@58065 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-30 09:31:41 +00:00
2f0d2dec4c I18N: Actually add all the files for [58061], not just the test fixtures.
Improve support for using only PHP translation files.

This builds on top of the PHP translation file support added in WordPress 6.5, improving the behavior for projects using solely `.l10n.php` translation files and no `.mo.` and `.po` files.

Updates `wp_get_installed_translations()`, which is used when updating language packs and when uninstalling plugins/themes (to remove the translations again), to look for PHP translation files and read metadata from them. Additionally, the file lookup is now cached thanks to using `WP_Textdomain_Registry`.

Updates `Language_Pack_Upgrader::check_package()` to allow language packs that only contain PHP translation files. While WordPress.org continues to serve `.mo` and `.po` files, third-party services might want to only use the PHP file format.

See #60554.

git-svn-id: https://develop.svn.wordpress.org/trunk@58062 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-30 08:37:25 +00:00
22796f5869 I18N: Improve support for using only PHP translation files.
This builds on top of the PHP translation file support added in WordPress 6.5, improving the behavior for projects using solely `.l10n.php` translation files and no `.mo.` and `.po` files.

Updates `wp_get_installed_translations()`, which is used when updating language packs and when uninstalling plugins/themes (to remove the translations again), to look for PHP translation files and read metadata from them. Additionally, the file lookup is now cached thanks to using `WP_Textdomain_Registry`.

Updates `Language_Pack_Upgrader::check_package()` to allow language packs that only contain PHP translation files. While WordPress.org continues to serve `.mo` and `.po` files, third-party services might want to only use the PHP file format.

Props swissspidy.
Fixes #60554.

git-svn-id: https://develop.svn.wordpress.org/trunk@58061 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-30 08:34:50 +00:00
ca58a0583e Editor: add ticket number to test after string update.
Follow-up to [58028]; adds ticket number to the updated test.

Props jorbin, isabel_brison.
See #60981.


git-svn-id: https://develop.svn.wordpress.org/trunk@58059 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-30 03:58:59 +00:00
d1e0a6241d Tests: Use assertSame() in WP_Comment::get_instance() tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Follow-up to [38381].

Props costdev.
See #60706.

git-svn-id: https://develop.svn.wordpress.org/trunk@58054 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-29 15:38:39 +00:00
66b5d25be2 Tests: Use assertSame() in wp_handle_comment_submission() tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Follow-up to [38778], [46829].

Props costdev.
See #60706.

git-svn-id: https://develop.svn.wordpress.org/trunk@58052 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-28 18:55:25 +00:00
179789fab3 Tests: Add more specific messages for a custom assertion in WP_Test_REST_TestCase.
All assertions in PHPUnit have a `$message` parameter. Setting this parameter allows to distinguish which assertion is failing when a test runs multiple assertions, making debugging of the tests easier.

Follow-up to [34928], [51478], [58039].

See #60426.

git-svn-id: https://develop.svn.wordpress.org/trunk@58051 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-26 15:49:19 +00:00
2074392c5c Media: fix potential error in class-avif-info.php::get_item_features().
Import upstream fix from libavifinfo, correcting a potential fatal error.

Props yguyon.
Fixes #60980.



git-svn-id: https://develop.svn.wordpress.org/trunk@58049 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-26 15:00:03 +00:00
7de15eb4b0 HTML API: Tests should use expectedIncorrectUsage phpunit annotation
Some tests in the HTML API test suite use `setExpectedIncorrectUsage`.
The annotation `@expectedIncorrectUsage` can be used to simplify the tests.

Developed in https://github.com/WordPress/wordpress-develop/pull/6449
Discussed in https://core.trac.wordpress.org/ticket/61080

Fixes #61080.
Props dmsnell, jonsurrell.


git-svn-id: https://develop.svn.wordpress.org/trunk@58048 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-26 13:51:06 +00:00
7159243c09 Tests: Use assertSame() in WP_oEmbed_Controller tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Follow-up to [41047].

Props costdev.
See #60706.

git-svn-id: https://develop.svn.wordpress.org/trunk@58044 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-24 22:03:06 +00:00
d898a25d1a Block Hooks: Fix @since and deprecated versions.
Two `@since` PHPDoc fields, and the version argument to one `_deprecated_argument()` incorrectly stated 6.5.1 as the relevant WordPress version where a change was introduced.

This changeset fixes them by setting them to 6.5.3 instead.

Follow-up to [57919].
See #60754.

git-svn-id: https://develop.svn.wordpress.org/trunk@58042 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-24 12:09:30 +00:00
10c3dd9cfb HTML API: Fix detection of single-length funky comments.
Since [60428] the Tag Processor has been misidentifying single-character
funky comments. It has been asserting that the full token-length for a
funky comment must be at least three characters after the opening (e.g.
`</1>`), but it has been starting to look for the closing `>` after
those same three characters. This means that it has been skipping the
actual close of these funky comments and swallowing up the next syntax
until it finds a `>`, often consuming the next tag in the process.

This patch fixes the detector and restores finding the following token.

Developed in https://github.com/WordPress/wordpress-develop/pull/6412
Discussed in https://core.trac.wordpress.org/ticket/60170

Follow-up to [60428].
Fixes #60170.
Props dmsnell, gziolo, jonsurrell.


git-svn-id: https://develop.svn.wordpress.org/trunk@58040 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-24 07:43:02 +00:00
25b9f8b156 Tests: Add a $message parameter for a custom assertion in WP_Test_REST_TestCase.
All assertions in PHPUnit have a `$message` parameter. Setting this parameter allows to distinguish which assertion is failing when a test runs multiple assertions, making debugging of the tests easier.

This optional parameter is now added for `WP_Test_REST_TestCase::assertErrorResponse()`.

Follow-up to [34928], [51478].

Props mykolashlyakhtun, antonvlasenko, swissspidy, SergeyBiryukov.
Fixes #60426.

git-svn-id: https://develop.svn.wordpress.org/trunk@58039 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-23 18:55:26 +00:00
bce4d573ae Editor: limit layout rules on themes without theme.json.
Removes output of base rules for flow and constrained layout types on themes without theme.json.

Props evanltd, poena, isabel_brison, andrewserong, oandregal.
See #60981.


git-svn-id: https://develop.svn.wordpress.org/trunk@58028 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-22 05:28:50 +00:00
22ad614ba5 Themes: Cache block theme patterns in a transient.
This extends the benefits of persistent caching added in [56978] for block theme patterns to sites that are not using a persistent object cache. By default, these caches expire using the value of the `WP_Theme::cache_expiration` property. The transient cache TTL can be overridden using the newly introduced `wp_theme_files_cache_ttl` filter.

Props thekt12, joemcgill, flixos90, peterwilsoncc, spacedmonkey.
See #59600, #59719.


git-svn-id: https://develop.svn.wordpress.org/trunk@58025 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-19 17:57:43 +00:00
5ae18c46d2 Upgrade/Install: Validate source & destination values in WP_Ugrader.
Adds a missing string and some additional validation of paths in the upgrader class.

Follow up to [56992].

Props costdev, jipmoors, karlijnbok, swissspidy, afragen, mukesh27.
Fixes #59712.



git-svn-id: https://develop.svn.wordpress.org/trunk@58022 602fd350-edb4-49c9-b593-d223f7449a82
2024-04-18 03:15:50 +00:00