5702 Commits

Author SHA1 Message Date
Isabel Brison
d1faee936d REST API: check parent and revision ids match before retrieving revision.
Adds a condition to check that parent id matches revision parent id in `WP_REST_Revisions_Controller` `get_item` method.

Props ramonopoly, adamsilverstein, danielbachhuber, spacedmonkey, andrewserong.
Fixes #59875.


git-svn-id: https://develop.svn.wordpress.org/trunk@57222 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-22 02:10:18 +00:00
Joe McGill
77dcb1771a Themes: Improve the performance of _get_block_templates_paths.
This avoids redundant recursive lookups for block template paths in the same base directory by implementing a static cache. It also replaces an potentially expensive `file_exists` call in favor of doing recursive iteration of files inside a try/catch block. 

Props thekt12, spacedmonkey, flixos90, mukesh27, joemcgill.
Fixes #58196.


git-svn-id: https://develop.svn.wordpress.org/trunk@57215 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-20 20:00:04 +00:00
bernhard-reiter
c6773eeffd HTML API: Avoid processing incomplete tokens.
Currently the Tag Processor assumes that an input document is a ''full'' HTML document. Because of this, if there's lingering content after the last tag match it will treat that content as plaintext and skip over it. This is fine for the Tag Processor because if there is lingering content that isn't a valid tag then there's nothing for `next_tag()` to match.

However, in order to support a number of feature expansions it is important to recognize that the remaining content ''may'' involve partial syntax elements, such as incomplete tags, attributes, or comments.

In this patch we're adding a mode inside the Tag Processor which will flip when we start parsing HTML syntax but the document finishes before the token does. This will provide the ability to:

- extend the input document,
- avoid misinterpreting syntax as text, and
- guess if we have a complete document, know if we have an incomplete document.

In the process of building this patch a few fixes were identified and fixed in the Tag Processor, namely in the handling of incomplete syntax elements.

Props dmsnell, jonsurrell.
Fixes #60122, #60108.

git-svn-id: https://develop.svn.wordpress.org/trunk@57211 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-20 17:50:04 +00:00
Sergey Biryukov
1bca32e30e Tests: Correct the @group annotation for _wp_mysql_week() tests.
Includes updating the data provider name for consistency.

Follow-up to [57207].

See #59931.

git-svn-id: https://develop.svn.wordpress.org/trunk@57208 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-20 10:01:17 +00:00
Aaron Jorbin
3c6680b657 Build/Test: Add Tests for _wp_mysql_week.
Props pbearne.
Fixes #59931.


git-svn-id: https://develop.svn.wordpress.org/trunk@57207 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-19 23:11:11 +00:00
Aaron Jorbin
144d098ac5 Build/Test: Update name of test to show its breadth.
The test covers multiple libraries, not just lodash.

Follow up to [57185].

Props TobiasBg.
Fixes #60048.


git-svn-id: https://develop.svn.wordpress.org/trunk@57187 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-13 20:00:49 +00:00
bernhard-reiter
32dd59bb9a HTML API: Add support for H1-H6 elements in the HTML Processor.
Previously these have been unsupported, but in this patch, support is added for the tags so that the HTML Processor can process documents containing them.

There was a design discussion about introducing a constant to communicate "any of the H1 - H6 elements" but this posed a number of challenges that don't need to be answered in this patch. For the time being, because the HTML specification treats H1 - H6 specially as a single kind of element, the HTML Processor uses an internal hard-coded string to indicate this. By using a hard-coded string it's possible to avoid introducing a class constant which cannot be made private due to PHP's class design. In the future, this will probably appear as a special constant in a new constant-containing class.

Props dmsnell, jonsurrell.
Fixes #60060.

git-svn-id: https://develop.svn.wordpress.org/trunk@57186 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-13 17:51:42 +00:00
Aaron Jorbin
edb416c9b2 External Libraries: For Lodash, sync the declared version number with the one that is loaded.
In [50941] the version of lodash was updated, however the version inside `wp_default_packages_vendor` was not updated at the same time. This updates the version to correctly reflect the version that is loaded.

Also adds some basic tests for the scripts in `wp_default_packages_vendor` that match the name of the package from package.json to help prevent errors like this in the future.

Props jadpm, jorbin, swissspidy.
Fixes #60048. See #52991.




git-svn-id: https://develop.svn.wordpress.org/trunk@57185 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-13 17:48:09 +00:00
Sergey Biryukov
5eef2bbb2a Tests: Add unit tests for wp_checkdate().
Follow-up to [21922].

Props pbearne, ironprogrammer, antonvlasenko, SergeyBiryukov.
Fixes #59825.

git-svn-id: https://develop.svn.wordpress.org/trunk@57184 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-12 12:19:38 +00:00
Sergey Biryukov
9bfb30462a REST API: Pass correct number of arguments to the comment_text filter.
This ensures that `WP_REST_Comments_Controller::prepare_item_for_response()` passes three arguments to the `comment_text` filter, for consistency with all the other instances in core.

Follow-up to [15957], [16357], [25555], [38832], [40664].

Props sjregan, SergeyBiryukov.
Fixes #58238.

git-svn-id: https://develop.svn.wordpress.org/trunk@57176 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-09 22:11:45 +00:00
bernhard-reiter
d1f73cd80f Block Hooks: Fix @ticket references in tests, add missing ones.
Some tests that were added in [57157] erroneously set their `@ticket` reference to #59646, rather than #60008.
This changeset rectifies that mistake.

Additionally, it adds ticket references to #60008 to tests that were modified by [57157].

Follow-up to [57157].

See #60008.

git-svn-id: https://develop.svn.wordpress.org/trunk@57172 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-08 11:44:54 +00:00
bernhard-reiter
c44432b338 Block Hooks: Store ignored hooked blocks metadata in anchor block.
The biggest tradeoff that was made in the implementation of Block Hooks was that they were limited to layouts (i.e. templates, template parts, and patterns) that ''didn't have any user modifications'' (see #59313 for the reason). This changeset is a preparatory step to remove this limitation, so they’ll eventually also work with user-modified layouts.

The crucial problem to solve is how to acknowledge that a user has opted to remove or persist a hooked block, so that the auto-insertion mechanism won't run again and inject an extraneous hooked block on the frontend when none is solicited.

This is achieved by storing all known blocks hooked to a given anchor block in the `metadata` attribute on that anchor block; specifically in a field called `ignoredHookedBlocks` inside of the `metadata`. Hooked blocks are only rendered on the frontend if they're absent from that field; OTOH, they're injected into that field (via the REST API) when first loaded in the editor.

This simple logic guarantees that once a user modifies a given layout, those changes are respected on the frontend; yet if a plugin that includes a hooked block is activated after those modifications have taken place, the hooked block will be rendered on the frontend. This new technique supplants the one previously used (i.e. rendering hooked blocks on the frontend only if a layout doesn't have any modifications) in a rather direct way.

Note that this changeset only introduces the new metadata field and relevant logic; it does not yet enable hooked block insertion into modified layouts. That will be done in a subsequent step (see #59646).

Props gziolo.
Closes #60008.

git-svn-id: https://develop.svn.wordpress.org/trunk@57157 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-04 20:24:33 +00:00
Felix Arntz
7ce1281349 Themes: Avoid autoloading the previous theme's theme mods when switching to another theme.
This reduces unnecessarily autoloaded data from inactive themes, which can contribute to slow database performance as part of excessive autoloading.

Props mukesh27, rajinsharwar, igmoweb, joemcgill, swissspidy, westonruter, flixos90.
Fixes #59537.
See #59975.


git-svn-id: https://develop.svn.wordpress.org/trunk@57153 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-04 19:36:27 +00:00
Sergey Biryukov
76ab1b8891 Build/Test Tools: Allow overriding the WP_UnitTestCase_Base::factory() method.
This allows third-party plugins to write their own factory extending `WP_UnitTest_Factory` for testing purposes, as well as benefit from `WP_UnitTestCase_Base` features.

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

Props hugod.
Fixes #59999.

git-svn-id: https://develop.svn.wordpress.org/trunk@57149 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-02 11:56:31 +00:00
Tonya Mork
4d19f6c23f REST API: Restore site logo and icon in index.
Restores setting the site's logo, icon, and wp-admin's back button image (which defaults to W).

Prior to [56566], the site logo and icon were unconditionally added to the index. [56566] changed this by conditionally adding them if either the `_links` or `_embedded` fields were included. However, these fields are not included when using the Site Logo block, as it uses the `site_logo`, `site_icon`, and `site_icon_url` fields instead.

This changeset restores the functionality by checking specifically for the `site_*` fields when neither of the `_links` or `_embedded` fields are present.

Follow up to [56566].

Props antonvlasenko, hellofromTonya, ironprogrammer, priethor, wildworks.
Fixes #59935.

git-svn-id: https://develop.svn.wordpress.org/trunk@57147 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-30 14:52:52 +00:00
Sergey Biryukov
36a7c6ca40 Tests: Update _wp_timezone_choice_usort_callback() tests for consistency.
* Use the same `@group` annotation as the other tests.
* Use `assertSame()` to verify the type of the result.
* Use `data_` prefix for the data provider.
* Use named data set in the data provider. This makes the output when using the `--testdox` option more descriptive and is helpful when trying to debug which data set from a data provider failed the test.
* Other minor corrections.

Reference: [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#repetitive-tests Core Handbook: Writing PHP Tests: Repetitive Tests].

Follow-up to [57145].

See #59953, #59647.

git-svn-id: https://develop.svn.wordpress.org/trunk@57146 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-30 11:15:34 +00:00
Aaron Jorbin
4cee935825 Add automated tests for _wp_timezone_choice_usort_callback
Props pbearne.
Fixes #59953.


git-svn-id: https://develop.svn.wordpress.org/trunk@57145 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-29 17:31:44 +00:00
Sergey Biryukov
09a2050fca Tests: Avoid an infinite loop in Spy_REST_Server if a non-existing method is called.
Follow-up to [34928].

Props xknown, joemcgill.
Fixes #59601.

git-svn-id: https://develop.svn.wordpress.org/trunk@57133 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-23 14:39:16 +00:00
Joe McGill
b6bf3553d9 Themes: Remove memoization from stylesheet and theme directories.
This fixes bugs introduced in [56635] whereby the template or stylesheet path could be memoized incorrectly if `get_template_directory()` or `get_stylesheet_directory()` were called before the theme has been fully initialized.

Props partyfrikadelle, coreyw, kdowns, rebasaurus, meta4, flixos90, mukesh27, joemcgill.
Fixes #59847.


git-svn-id: https://develop.svn.wordpress.org/trunk@57129 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-20 22:27:17 +00:00
Bernie Reiter
3d06660c63 HTML API: Add support for containers elements, including ARTICLE.
There are a handful of elements which behave similarly and are generically container elements. These are the following elements:

    ADDRESS, ARTICLE, ASIDE, BLOCKQUOTE, CENTER, DETAILS, DIALOG, DIR,
    DL, DIV, FIELDSET, FIGCAPTION, FIGURE, FOOTER, HEADER, HGROUP, MAIN,
    MENU, NAV, SEARCH, SECTION, SUMMARY

This patch adds support to the HTML Processor for handling these elements. They do not require any additional logic in the rest of the class, and carry no specific semantic rules for parsing beyond what is listed in their group in the IN BODY section of the HTML5 specification.

Props dmsnell.
Fixes #59914.

git-svn-id: https://develop.svn.wordpress.org/trunk@57115 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-17 06:11:31 +00:00
Sergey Biryukov
cfecc5cde5 Docs: Replace miscellaneous incorrect PHPDoc tags.
* `@contrib` is not a valid tag.
* `@origin` is not a valid tag.
* `@ref` is not a valid tag.
* `@blessed` is not a valid tag and doesn't convey any meaningful information.
* `@issue` is not a valid tag.

Reference: [https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#phpdoc-tags PHP Documentation Standards: PHPDoc Tags].

Follow-up to [8852], [34754], [38832], [43808].

Props jrf.
See #59651.

git-svn-id: https://develop.svn.wordpress.org/trunk@57108 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-13 11:11:54 +00:00
Sergey Biryukov
00791300b3 Docs: Fix incorrect property doc in WP_Theme::get_allowed() tests.
The `@array` tag does not exist. This should be `@var array`.

Reference: [https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#2-1-class-members PHP Documentation Standards: Class Members].

Follow-up to [36350].

Props jrf.
See #59651.

git-svn-id: https://develop.svn.wordpress.org/trunk@57107 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-12 09:19:20 +00:00
Sergey Biryukov
db071f729c Docs: Fix broken @covers tag in _wp_post_thumbnail_context_filter() tests.
Without the space between the tag and the "description", the tag will not be recognized and the test will not record coverage correctly.

Reference: [https://docs.phpunit.de/en/9.6/annotations.html#covers PHPUnit Manual: Annotations].

Follow-up to [55821].

Props jrf.
See #59651.

git-svn-id: https://develop.svn.wordpress.org/trunk@57105 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-10 22:52:06 +00:00
Felix Arntz
9df9e28f65 Tests: Fix incorrect check for block themes in legacy PHPUnit test for themes.
Props mukesh27.
Fixes #59881.


git-svn-id: https://develop.svn.wordpress.org/trunk@57104 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-10 18:59:59 +00:00
Sergey Biryukov
1b5ab7ad0c Docs: Fix incorrect @return tag in wp_check_filetype() tests.
`@return[]` is not a valid tag. Fixed now, though without further specification.

Reference: [https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#phpdoc-tags PHP Documentation Standards: PHPDoc Tags].

Follow-up to [55456].

Props jrf.
See #59651.

git-svn-id: https://develop.svn.wordpress.org/trunk@57101 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-10 10:47:55 +00:00
Peter Wilson
a4a4f3a1dc Coding Standards: Replace CRLF line breaks with LF.
Run `npm run grunt format:php:error` to correct the EOL sequence for:

* `tests/phpunit/tests/functions/wpAdminNotice.php`
* `tests/phpunit/tests/functions/wpGetAdminNotice.php`

See #59650.



git-svn-id: https://develop.svn.wordpress.org/trunk@57100 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-10 00:07:59 +00:00
Sergey Biryukov
7287ff5263 Docs: Fix various incorrect WP-flavored array specifications.
Tags like `@string` or `@array` do not exist and are not supported. The way these were used here, also meant duplicate information being documented.

Fixed now by using the `@type` tag as per the WP flavor of array documentation.

Includes some fixes to the documentation formatting.

Reference: [https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#1-1-parameters-that-are-arrays PHP Documentation Standards: Parameters That Are Arrays].

Follow-up to [33322], [42880], [42971], [44786].

Props jrf.
See #59651.

git-svn-id: https://develop.svn.wordpress.org/trunk@57099 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-09 09:49:41 +00:00
Tonya Mork
8c2c762e23 Database: Reinstate wpdb::$use_mysqli property.
Partial revert of [56475] to reinstate the private `wpdb::$use_mysqli` property and set to its default to `true`. This private property was / is accessible through the magic methods. Though Core's usage of this property was removed by [56475], plugins are using the property. Reinstating it resolves the BC break.

Follow up to [56475].

Props jason_the_adams, joemcgill, johnbillion, johnjamesjacoby, jrf, rajinsharwar, renehermi.
Fixes #59846.

git-svn-id: https://develop.svn.wordpress.org/trunk@57089 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-08 20:31:34 +00:00
Pascal Birchler
74e0604508 Build/Test Tools: Expand performance test scenarios.
Adds new tests for localized sites as well as the dashboard.
Also amends Server-Timing output to measure memory usage in all scenarios.

Props swissspidy, joemcgill, flixos90, mukesh27, mamaduka.
See #59656.
Fixes #59815.

git-svn-id: https://develop.svn.wordpress.org/trunk@57083 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-08 10:30:21 +00:00
Bernie Reiter
2a93cafb52 Block Types: Add metadata global attribute.
Add a new global attribute (i.e. an attribute that can be added to all and any blocks) called `metadata`. This is required for use cases such as allowing the user to assign custom names to blocks, or for making Block Hooks work with user-modified templates/parts/patterns (#59646).

Props Mamaduka, gziolo, get_dave.
Fixes #59797.

git-svn-id: https://develop.svn.wordpress.org/trunk@57068 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-06 14:45:28 +00:00
Sergey Biryukov
57d8eef46b Docs: Fix typo in a function DocBlock in WP_Duotone tests.
Follow-up to [56101], [56981].

See #59651.

git-svn-id: https://develop.svn.wordpress.org/trunk@57062 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-05 16:20:40 +00:00
Peter Wilson
75796f5e92 Build/Test Tools: Introduce tests for wp_cache_set_last_changed().
Props pbearne.
Fixes #59737.



git-svn-id: https://develop.svn.wordpress.org/trunk@57060 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-03 23:27:35 +00:00
Peter Wilson
e408533070 Build/Test Tools: Fix group for wp_unique_prefixed_id() tests.
Change the group from `functions.php` to `functions` to match other tests.

See #59647.



git-svn-id: https://develop.svn.wordpress.org/trunk@57057 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-03 21:53:01 +00:00
Tonya Mork
f6905ebced Taxonomy: Set "public" to "false" for user pattern categories.
Changes the `'wp_pattern_category'` taxonomy's `'public'` argument to `false`.

Follow-up to [56642].

Props vrajadas, glendaviesnz, hellofromTonya, ramonopoly.
Fixes #59569.

git-svn-id: https://develop.svn.wordpress.org/trunk@57044 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-01 14:48:50 +00:00
Tammie Lister
5dff9238b9 Update editor related npm packages for 6.4 RC3.
The npm packages needed update for 6.4 RC3.

Patch: https://github.com/WordPress/wordpress-develop/pull/5587.
This PR includes the following changes:

- Regression: [https://github.com/WordPress/gutenberg/pull/55553 Patterns: fix bug with authors and contributors not seeing user pattern categories].
- Bugfix: [https://github.com/WordPress/gutenberg/pull/55539 Query Loop:Disallow "enhanced pagination" with core blocks that may contain third-party blocks].
- Regression: [https://github.com/WordPress/gutenberg/pull/55667 File: Fix embedded PDF files in Safari].
- Regression: [https://github.com/WordPress/gutenberg/pull/55669 Ensure Term Description block is registered in core]

Props DAreRodz, luisherranz, poena, afercia, danieldudzic, hellofromtonya, siobhyb, mikachan, get_dave, scruffian, wildworks, glendaviesnz, ramonopoly, aaronrobertshaw.

See #59411.


git-svn-id: https://develop.svn.wordpress.org/trunk@57034 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-31 15:11:42 +00:00
Sergey Biryukov
3d86a763a6 Docs: Update some reusable block references to synced patterns.
In WordPress 6.3, [https://wordpress.org/documentation/article/reusable-blocks/ Reusable Blocks were renamed to Patterns]. A synced pattern will behave in exactly the same way as a reusable block.

This commit updates some references in DocBlocks and inline comments to use the new name.

Follow-up to [56030].

Props benjaminknox, oglekler, hellofromTonya, marybaum, nicolefurlan.
Fixes #59388.

git-svn-id: https://develop.svn.wordpress.org/trunk@57032 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-31 12:56:16 +00:00
Peter Wilson
17a01ed185 Options, Meta APIs: Fast follow fixes for option cache priming functions.
A collection of fixes for `wp_prime_option_caches()`:

* cache arrays and objects in their serialized form for consistency with `get_option()` and `wp_load_alloptions()`
* prevent repeat database queries for falsey and known non-existent options (notoptions)

Additional tests for `wp_prime_option_caches()` to ensure:

* additional database queries are not made repriming options (known, known-unknown and alloptions)
* cache is primed consistently
* `get_option()` returns a consistent value regardless of how it is primed
* database queries do not contain earlier primed options
* `get_option` does not prime the cache when testing the cache has been successfully primed

Fixes a test for `wp_prime_option_caches_by_group()` to ensure `get_option` does not prime the cache when testing the cache has been successfully primed.

Follow up to [56445],[56990],[57013].

Props peterwilsoncc, costdev, flixos90, hellofromTonya, mikeschroder, joemcgill.
Fixes #59738. See #58962.


git-svn-id: https://develop.svn.wordpress.org/trunk@57029 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-30 22:56:25 +00:00
Sergey Biryukov
63a4ae98ee Editor: Correctly load RTL stylesheets in register_core_block_style_handles().
When setting an RTL language under Settings → General, some RTL stylesheets were not loaded, with LTR stylesheets being loaded instead, meaning that some blocks were not displayed correctly.

This commit ensures that all appropriate RTL stylesheets are loaded when selecting an RTL language.

Follow-up to [56524].

Props mukesh27, maahrokh, hellofromTonya, joemcgill, huzaifaalmesbah, rajinsharwar, devmuhib, swissspidy.
Fixes #59715.

git-svn-id: https://develop.svn.wordpress.org/trunk@57028 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-30 12:52:44 +00:00
Sergey Biryukov
cc2133fc34 Blocks: Parse the arguments earlier in register_block_type_from_metadata().
This makes it possible to register a block by passing an array of arguments, without the presence of a `block.json` file.

Follow-up to [48141], [49948].

Props aristath, spacedmonkey, mukesh27, costdev, audrasjb, oglekler, felipeelia, hellofromTonya.
Fixes #56865.

git-svn-id: https://develop.svn.wordpress.org/trunk@57026 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-28 01:00:14 +00:00
Joe McGill
ea30b5d8eb Upgrade/Install: Skip registering theme block patterns during the upgrade process.
This fixes a bug during the database upgrade process where a theme's `functions.php` file may not be loaded, leading to potential exceptions if the theme's pattern files use symbols (classes, functions, constants, etc.) that are declared only when the `functions.php` file is loaded. To do so, a check for `wp_get_active_and_valid_themes()` is added early to `_register_theme_block_patterns()`, which returns early if no active or valid themes are returned.

Props fabiankaegy, rajinsharwar, pbiron, huzaifaalmesbah, hellofromTonya, peterwilsoncc, joemcgill.
Fixes #59723.


git-svn-id: https://develop.svn.wordpress.org/trunk@57021 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-27 19:02:54 +00:00
Felix Arntz
22e32d8993 Themes: Skip wrapping block template for singular content with a main query loop when the template was injected from outside the current theme.
As a follow up to [56507], this fixes a bug that could occur for instance when plugins hijack the block template detection process to inject their own block template with entirely custom logic.

Props afragen, hellofromTonya, costdev, mukesh27, huzaifaalmesbah, flixos90.
Fixes #59736.
See #58154.


git-svn-id: https://develop.svn.wordpress.org/trunk@57019 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-27 18:16:05 +00:00
Peter Wilson
fc3aae3a08 Options, Meta APIs: Rename option cache priming functions.
Rename the option cache priming functions to more closely follow the naming convention used by other cache priming functions.

* `wp_load_options()` becomes `wp_prime_option_caches()`
* `wp_load_options_by_group()` becomes `wp_prime_option_caches_by_group()`

The unit test files and classes are renamed accordingly.

Unlike the existing cache priming functions, these functions were introduced with the intention of being public so use the `wp_` prefix rather than the `_` prefix used by the functions initially introduced as private functions but since made public.

Follow up to [56445],[56990].

Props flixos90, peterwilsoncc, joemcgill, SergeyBiryukov, desrosj.
Fixes #58962.



git-svn-id: https://develop.svn.wordpress.org/trunk@57013 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-26 22:54:15 +00:00
Sergey Biryukov
64b1726c44 Tests: Use a @requires annotation for readonly() function test.
The function is only defined by WordPress core on PHP < 8.1.

Follow-up to [51586].

See #59647.

git-svn-id: https://develop.svn.wordpress.org/trunk@57011 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-26 20:31:45 +00:00
Felix Arntz
33069c3c6b Themes: Fix block theme supports being added too early, leading to Customizer live preview bugs in 6.4.
The Customizer live preview broke because of [56635], however the root cause for the bug was a lower-level problem that had been present since WordPress 5.8: The block theme specific functions `_add_default_theme_supports()` and `wp_enable_block_templates()` were being hooked into the `setup_theme` action, which fires too early to initialize theme features. Because of that, theme functionality would be initialized before the current theme setup being completed. In the case of the Customizer, that includes overriding which theme is the current theme entirely, thus leading to an inconsistent experience.

This changeset fixes the bug by moving those two callbacks to the `after_setup_theme` action, which is the appropriate action to initialize theme features.

Props karl94, hellofromTonya, joemcgill, flixos90.
Fixes #59732.
See #18298, #53397, #54597.


git-svn-id: https://develop.svn.wordpress.org/trunk@57009 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-26 18:42:46 +00:00
Sergey Biryukov
0133fc5441 Tests: Remove some unnecessary multisite test skipping.
These checks are redundant, as the skipping already handled by the `ms-required` and `ms-excluded` groups.

Follow-up to [36740], [36741], [38705], [40520], [51415].

Props johnbillion.
See #59647.

git-svn-id: https://develop.svn.wordpress.org/trunk@57008 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-25 11:20:23 +00:00
Sergey Biryukov
c438bebad1 Tests: Correct the WP_Test_Stream::mkdir() method.
The method attempted to check if there is already a file with the same name, however the conditional used an undefined variable.

This commit prevents directory creation if a file or directory with the same name already exists, bringing consistency with the PHP `mkdir()` implementation.

Includes adding missing documentation for the method.

Reference: [https://www.php.net/manual/en/streamwrapper.mkdir.php PHP Manual: streamWrapper::mkdir()].

Follow-up to [49230].

Props david.binda, sadizaman, rajinsharwar, SergeyBiryukov.
Fixes #59406.

git-svn-id: https://develop.svn.wordpress.org/trunk@56998 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-24 11:32:42 +00:00
Tonya Mork
88ab0a2c57 Tests: Fix static property handling in r56991.
Fixes static property handling for `WP_Duotone::$block_css_declarations` in the `Tests_Block_Supports_Duotone::test_css_declarations_are_generated_even_with_empty_block_content()`:

* Fixes `ReflectionProperty::setValue()` to use an instance of `WP_Duotone`.
* Adds an inline comment to explain why a static class (i.e. a class that is not intended to be an object by design as it only contains static properties and methods) needs an instance, i.e. needed for PHP 8.3 and higher.
* Resets the static property's value to its original value, i.e. before the test started.

Follow-up to [56991].

Props costdev.
See #59694.

git-svn-id: https://develop.svn.wordpress.org/trunk@56996 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-24 10:57:03 +00:00
Bernie Reiter
ac8bca4fdf Blocks: Fix layout support to be compatible with enhanced pagination.
Make layout support compatible with enhanced pagination by ensuring that generated class names are stable across pagination, even when the number of rendered posts is different.

With the previous implementation of enhanced pagination, the CSS corresponding to each block was not detected. Therefore, for enhanced pagination to work correctly, the CSS of the blocks present in the Post Template must be stable on all pages.

The number of posts rendered by the Query block is always the same, except in the last page, where it can be only a fraction. If any of the blocks rendered by the Post Template used the `wp_unique_id` function, the ID (which is incremental) would have been different than in the previous pages and the class names would have varied.

This is remediated by this changeset by replacing the usage of `wp_unique_id` in the layout support (which is used by the Query block) with an implementation that uses IDs that are incremental only for that block. That way, the generated class names are never affected by the number of times `wp_unique_id` runs.

Props luisherranz, andrewserong, isabel_brison, costdev, mukesh27, cbravobernal, hellofromTonya, jorbin.
Fixes #59681.

git-svn-id: https://develop.svn.wordpress.org/trunk@56994 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-24 08:49:38 +00:00
Peter Wilson
b5392cc28c Build/Test tools: Introduce partial unit tests for WP_Upgrader.
Props jipmoors, karlijnbk, chaion07, cu121, martin.krcho, costdev, mukesh27, hellofromTonya, SergeyBiryukov, audrasjb, jrf.
Fixes #54245.



git-svn-id: https://develop.svn.wordpress.org/trunk@56992 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-24 01:38:16 +00:00
Tonya Mork
ee631556b4 Editor: Fix render_duotone_support() to be compatible with enhanced pagination.
Some blocks do not have content. For duotone support, blocks without content still need to run through the `render_duotone_support()` to render their duotone CSS.

This fix makes the duotone compatible with the enhanced pagination (introduced in 6.4.0) by making sure that the CSS is always on the page, even when the posts have no featured image. It also prevents the duotone from interfering with other blocks using `wp_unique_id()`.


References:
* [https://github.com/WordPress/gutenberg/pull/55415 Gutenberg PR 55415]

Follow-up to [56226].

Props cbravobernal, luisherranz, hellofromTonya, isabel_brison, jorbin.
Fixes #59694.

git-svn-id: https://develop.svn.wordpress.org/trunk@56991 602fd350-edb4-49c9-b593-d223f7449a82
2023-10-23 23:37:55 +00:00