This affects:
* `register_block_script_handle()`
* `register_block_style_handle()`
Both functions set a variable with this code:
{{{
$wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) );
}}}
That value never changes during page load, so we can save it to a static variable. By doing so, we can avoid ~200 calls to `realpath()` and `wp_normalize_path()`, or even more if third-party plugins register scripts or styles.
Follow-up to [52291], [52939], [54290], [54291], [54309], [54327].
Props aristath, mukesh27, SergeyBiryukov.
Fixes#56758.
Built from https://develop.svn.wordpress.org/trunk@54415
git-svn-id: http://core.svn.wordpress.org/trunk@53974 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When initially defaulting the screen `$id` in `WP_Screen::get()`, if the `$hook_name` parameter is not supplied, an `else` fallback uses `$GLOBALS['hook_suffix']`. However, in some cases, `hook_suffix` doesn't exist in the global scope. This produces an "Undefined index" notice on < PHP 8, and a warning in >= PHP 8.
This change ensures `$GLOBALS['hook_suffix']` has a value before using it as a fallback for the screen ID.
Props splendorstudio, SergeyBiryukov, htdat, mukesh27, dd32, costdev.
Fixes#49089.
Built from https://develop.svn.wordpress.org/trunk@54414
git-svn-id: http://core.svn.wordpress.org/trunk@53973 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset updates the blocks origin name from core to blocks and adds it to the list of valid origins for `theme.json`.
(See the original fix in [https://github.com//pull/3319 Gutenberg's PR 44363]).
Why?
- This new origin was missing from the list.
- The `core` name is not reflective of what it does, as this data origin is related to block styles, whether they come with WordPress or third-party blocks.
- The existing filter for this piece of data is called `theme_json_blocks`, to reflect it filters "block" data.
- Though `core` origin was used in the past for `default`, this commit reverts it. Why? It was confusing. The goal is to use names that communicate what part of the pipeline are processing (`default > blocks > theme > custom`).
How?
- Renames the string, from `core` to `blocks`.
- Adds `blocks` to the list of valid origins.
- Verifies that the `$theme_json->get_stylesheet()` call uses the proper `$origins` at all times.
Follow-up to [54162], [54251].
Props oandregal, czapla, jorgefilipecosta, scruffian, bernhard-reiter hellofromTonya.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54408
git-svn-id: http://core.svn.wordpress.org/trunk@53967 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `sync-stable-blocks.js` file is used to compile the contents of `require-dynamic-blocks.php`, which includes the PHP files required for dynamic Core blocks.
Since these files define PHP functions, `require_once` should be used instead of `require` to guard against fatal errors.
Follow up to [53688].
Props aristath, SergeyBiryukov, desrosj.
Fixes#56738. See #56179.
Built from https://develop.svn.wordpress.org/trunk@54406
git-svn-id: http://core.svn.wordpress.org/trunk@53965 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Includes:
* Adjusting test method descriptions and comments per the documentation standards.
* Creating image editor class instances directly, instead of calling `wp_get_image_editor()`.
* Cleaning up temporary files before performing assertions, where possible.
* Using more consistent variable names for image editor class instances.
* Reordering some test methods.
Follow-up to [1182/tests], [1188/tests], [27794], [30549], [30990], [31040], [39580], [40123], [49230], [49488], [49542], [49751].
See #55652.
Built from https://develop.svn.wordpress.org/trunk@54401
git-svn-id: http://core.svn.wordpress.org/trunk@53960 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This updates the following `devDependencies`:
- `chalk` from `5.0.1` to `5.1.0`
- `dotenv` from `16.0.2` to `16.0.3`
- `sinon` from `14.0.0` to `14.0.1`
- `uglify-js` from `3.17.1` to `3.17.3`
This is the final dependency bump for 6.1.
See #56641.
Built from https://develop.svn.wordpress.org/trunk@54400
git-svn-id: http://core.svn.wordpress.org/trunk@53959 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This change removes the caching of theme data in `WP_Theme_JSON_Resolver::get_theme_data()`, instead freshly compiling theme data on each call.
Also, to prevent any performance degradation by the removal, the file contents of `theme.json` files are now cached in `WP_Theme_JSON_Resolver::read_json_file()`, preventing multiple filesystem reads.
Follow-up to [54385].
Props ndiego, bph, mikachan, andrewserong, oandregal, cbravobernal, bernhard-reiter, aristath.
Fixes#56736.
Built from https://develop.svn.wordpress.org/trunk@54399
git-svn-id: http://core.svn.wordpress.org/trunk@53958 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When loading a page on the frontend using Xdebug & Webgrind, with the Twenty Twenty-Three theme and no plugins activated, the biggest performance bottleneck currently (on the PHP side) is `WP_Theme_JSON::merge()`. Analysing the data a bit more, it became evident that `WP_Theme_JSON::get_default_slugs()` is the part of that method which takes most of the resources and time.
Further analysis of the method revealed that `array_map()` was the call that slowed it down.
This commit replaces the `array_map()` call with a simple `foreach` loop, improving page load speed significantly.
Follow-up to [52275], [52364].
Props aristath.
Fixes#56745.
Built from https://develop.svn.wordpress.org/trunk@54398
git-svn-id: http://core.svn.wordpress.org/trunk@53957 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Authenticated users should only be allowed to read password protected content if they have the `edit_post` meta capability for the post. In other words, the content of a password protected post created by an Editor should not be viewable by a Contributor.
This commit aims to clarify the usage of a negative assertion `assertStringNotContainsString()` and describe the intention behind the test to avoid confusion.
Follow-up to [50717].
Fixes#56681.
Built from https://develop.svn.wordpress.org/trunk@54396
git-svn-id: http://core.svn.wordpress.org/trunk@53955 1a063a9b-81f0-0310-95a4-ce76da25c4cd
If a theme includes a `theme.json` file and sets a specific `font-style` on links, the font-style also changes the links in the WordPress admin bar, when the admin bar is visible on front-end. For example, this happens with the `pitch` style variation of Twenty Twenty-Three.
Using a default value for the `font-style` property prevents `theme.json` files from overriding it.
Props audrasjb, poena.
Fixes#56737.
Built from https://develop.svn.wordpress.org/trunk@54395
git-svn-id: http://core.svn.wordpress.org/trunk@53954 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Unix vs. Windows EOL style mismatches can cause misleading failures in tests using the heredoc syntax (`<<<`) or multiline strings as the expected result.
This resolves two failures when running the test suite on Windows along the lines of:
{{{
1) Tests_Style_Engine_wpStyleEngineCSSRule::test_should_prettify_css_rule_output
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
#Warning: Strings contain different line endings!
-'.baptiste {
- margin-left: 0;
- font-family: Detective Sans;
+'.baptiste {
+ margin-left: 0;
+ font-family: Detective Sans;
}'
/var/www/tests/phpunit/tests/style-engine/wpStyleEngineCssRule.php:159
}}}
Follow-up to [46612], [48443], [48466], [49691], [51135], [53282], [53319], [54156].
See #56467, #55652.
Built from https://develop.svn.wordpress.org/trunk@54394
git-svn-id: http://core.svn.wordpress.org/trunk@53953 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset fixes overlapping glitches discovered in WordPress Admin menu behavior when used on small screens.
Props turtlepod, collieit, chaion07, hilayt24, mehedi890, markparnell, webcommsat, mehedi890, ryokuhi, sabernhardt, ironprogrammer, audrasjb, costdev, ugyensupport.
Fixes#32747.
Built from https://develop.svn.wordpress.org/trunk@54392
git-svn-id: http://core.svn.wordpress.org/trunk@53951 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Ensures the `fontFamily` attribute is registered for block types on the server side. This change resolves a `400` error when attempting to change the font family for a server-side rendered block in the editor.
Props aaronrobertshaw, mamaduka, wildworks, upadalavipul.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54387
git-svn-id: http://core.svn.wordpress.org/trunk@53946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This change ensures that user-supplied global styles settings for blocks aren't lost due to sanitization. This could previously occur due to outdated blocks metadata that did not include all registered blocks.
Props jorgefilipecosta, andrewserong, oandregal, talldanwp, cbravobernal, bernhard-reiter, hellofromTonya.
Fixes#56644.
Built from https://develop.svn.wordpress.org/trunk@54385
git-svn-id: http://core.svn.wordpress.org/trunk@53944 1a063a9b-81f0-0310-95a4-ce76da25c4cd
MariaDB version is reported differently between PHP versions:
* PHP 8.0.16 or later: `10.6.8-MariaDB`
* PHP 8.0.15 or earlier: `5.5.5-10.6.8-MariaDB`
The latter includes PHP 7.4.x and PHP 5.6.x as well, where the version is also reported with the `5.5.5-` prefix.
This commit makes an adjustment to `wpdb::has_cap()` to check for the correct MariaDB version.
This resolves an issue where the `utf8mb4_unicode_520_ci` collation, which is available in MariaDB since version 10.2, was previously not detected correctly.
References:
* [https://github.com/php/php-src/issues/7972 php-src: #7972: MariaDB version prefix 5.5.5- is not stripped]
* [https://github.com/php/php-src/pull/7963 php-src: PR #7963 Fix GH-7932: MariaDB version prefix not always stripped]
* [https://mariadb.com/docs/reference/mdb/collations/utf8mb4_unicode_520_ci/ MariaDB Documentation: utf8mb4_unicode_520_ci]
Follow-up to [37523], [53919].
Props jamieburchell, SergeyBiryukov.
Fixes#54841.
Built from https://develop.svn.wordpress.org/trunk@54384
git-svn-id: http://core.svn.wordpress.org/trunk@53943 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This corrects the docblock for `get_block_file_template()` and the filters it contains: `pre_get_block_file_template` and `get_block_file_template`.
Prior to this change they were incorrectly documented with the docblocks for `get_block_template()` and its associated filters.
Props felipeelia.
Fixes#55929.
Built from https://develop.svn.wordpress.org/trunk@54380
git-svn-id: http://core.svn.wordpress.org/trunk@53939 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Translate the default salt value "put your unique phrase here" in additional locations in which it is used. This further ensures that the default phrase is considered an error in non-english translations of `wp-config.php`.
Follow-up to [54249].
Props peterwilsoncc, audrasjb, JeffPaul.
Fixes#55937.
Built from https://develop.svn.wordpress.org/trunk@54379
git-svn-id: http://core.svn.wordpress.org/trunk@53938 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Remove the private delegation from the following classes and function:
* `WP_List_Table`
* `WP_Application_Passwords_List_Table`
* `WP_Comments_List_Table`
* `WP_Links_List_Table`
* `WP_Media_List_Table`
* `WP_MS_Sites_List_Table`
* `WP_MS_Themes_List_Table`
* `WP_MS_Users_List_Table`
* `WP_Plugin_Install_List_Table`
* `WP_Plugins_List_Table`
* `WP_Post_Comments_List_Table`
* `WP_Posts_List_Table`
* `WP_Terms_List_Table`
* `WP_Theme_Install_List_Table`
* `WP_Themes_List_Table`
* `WP_Users_List_Table`
* `_get_list_table()`
This change is to reflect the reality that list tables are very, very, very widely used by extenders and backward compatibility therefore needs to be maintained.
Introduces the filter `wp_list_table_class_name` within `_get_list_table()` to allow extenders to modify the list table returned for custom screens.
Props audrasjb, birgire, costdev, desrosj, faison, johnbillion, jrbeilke, kurtpayne, milana_cap, miqrogroove, nacin, peterwilsoncc, scribu, sergeybiryukov, sirzooro, westonruter, wonderboymusic.
Fixes#18449.
Built from https://develop.svn.wordpress.org/trunk@54378
git-svn-id: http://core.svn.wordpress.org/trunk@53937 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In `get_page_by_title()` access the populated `WP_Query::posts` property directly rather than via the `WP_Query::get_posts()` method. This removes unnecessary reprocessing of the query.
Follow up to [54234].
Props david.binda, mukesh27, spacedmonkey.
Fixes#56721.
Built from https://develop.svn.wordpress.org/trunk@54377
git-svn-id: http://core.svn.wordpress.org/trunk@53936 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This adds a note to the Getting Started section of the `README.md` file mentioning that NodeJS `14.x` and npm `6.x` is currently required to spin up a development environment.
Props elpanda13gmailcom, robinwpwebdeveloper, jakariaistauk, hztyfoon, seakashdiu, rudlinkon, fuadragib.
Fixes#55903.
Built from https://develop.svn.wordpress.org/trunk@54375
git-svn-id: http://core.svn.wordpress.org/trunk@53934 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The latest version of the `actions/github-script` action fixes an issue where passing options to the action would remove any default values not passed (see https://github.com/actions/github-script/pull/293).
This also includes updates to other third-party actions, bringing all third-party versions in Core workflows to their latest versions:
- `actions/cache`
- `actions/setup-node`
- `codecov/codecov-action`
See #55652.
Built from https://develop.svn.wordpress.org/trunk@54373
git-svn-id: http://core.svn.wordpress.org/trunk@53932 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This brings over the latest bug fixes and improvements ahead of WordPress 6.1 beta 3.
For a full list of changes being included, see the `twentytwentythree` repository on GitHub: ac96e8d545...ca662828b7.
Props mikachan, poena, madhudollu, beafialho, colorful-tones, scruffian, tahmidulkarim, joen, taskotr, zoonini, mayuge, ndiego, collet.
See #56383.
Built from https://develop.svn.wordpress.org/trunk@54372
git-svn-id: http://core.svn.wordpress.org/trunk@53931 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When running PHPCS scans (both for checking coding standards and PHP version compatibility), the results are currently only returned silently in a format that GitHub can consume for contextually annotating any code being flagged.
This changes workflows using PHPCS to also display the results of each scan in the GitHub Action log, making it easier to find and understand what is causing failures.
Props jrf.
See #55652.
Built from https://develop.svn.wordpress.org/trunk@54371
git-svn-id: http://core.svn.wordpress.org/trunk@53930 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In the lead up to 6.1 Beta 2, dynamic titles and descriptions for site editor templates was deemed "feature incomplete" and [54280] was reverted. After further consideration, this code is being re-merged in preparation for Beta 3, reverting the revert in [54333].
Follow-up to [54280] and [54333].
Props bernie, ntsekouras, jorgefilipecosta, jameskoster, cbravobernal.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54370
git-svn-id: http://core.svn.wordpress.org/trunk@53929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
With all known unit test failures now addressed, WordPress 6.1 aims to support PHP 8.1 and 8.2 as much as possible.
While full compatibility with PHP 8.1 and 8.2 is still a work in progress, this commit aims to actively prevent new PHP issues from being introduced in WordPress core.
All remaining known issues are deprecation notices. Please note, a deprecation notice is not an error, but rather an indicator of where additional work is needed for compatibility before PHP 9 (i.e. when the notices become fatal errors). With a deprecation notice, the PHP code will continue to work and nothing is broken.
Follow-up to [49077], [49162], [50299], [51588], [51604], [53922], [54072].
Props jrf, desrosj.
See #55652, #55656, #56009, #56681.
Built from https://develop.svn.wordpress.org/trunk@54369
git-svn-id: http://core.svn.wordpress.org/trunk@53928 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This affects the following parameters subsequently passed to `wp_new_comment()`:
* `comment_author`
* `comment_author_email`
* `comment_author_url`
* `comment_content`
The default values for these parameters were previously set to `null`, causing PHP 8.1 "null to non-nullable" deprecation notices when running sanitization filters on them via `wp_filter_comment()`.
While the deprecation notices were temporarily silenced in the unit test suite, that caused an unexpected issue in a test for [source:tags/6.0.2/tests/phpunit/tests/comment-submission.php#L202 submitting a comment to a password protected post], where the `$_COOKIE[ 'wp-postpass_' . COOKIEHASH ]` value was no longer unset, as the test stopped any further execution once the deprecation notice was triggered.
Due to how WordPress handles password protected posts, once that value is set, it affects all posts protected with the same password, so this resulted in unintentionally affecting [source:tags/6.0.2/tests/phpunit/tests/rest-api/rest-posts-controller.php#L1866 another test] which happened to use the same password.
These values are all documented to be a string in various related filters, and core also expects them to be a string, so there is no reason for these defaults to be set to `null`. Setting them to an empty string instead resolves the issues.
This commit includes:
* Setting the defaults in `wp_handle_comment_submission()` to an empty string.
* Adding a dedicated unit test to verify the type of these default values.
* Removing the deprecation notice silencing as no longer needed.
Follow-up to [34799], [34801], [51968].
Props jrf, desrosj, mukesh27, SergeyBiryukov.
Fixes#56712. See #56681, #55656.
Built from https://develop.svn.wordpress.org/trunk@54368
git-svn-id: http://core.svn.wordpress.org/trunk@53927 1a063a9b-81f0-0310-95a4-ce76da25c4cd
As of [35186] and [51568], there are two sets of methods used for setup/teardown in the test suite before and after a test class is run:
* `set_up_before_class()` / `tear_down_after_class()`
* `wpSetUpBeforeClass()` / `wpTearDownAfterClass()`. (Note the `wp` prefix, these are WordPress' own methods and are not the same as the native PHPUnit `setUpBeforeClass()` / `tearDownAfterClass()` methods.)
The main difference is that `wpSetUpBeforeClass()` receives the `$factory` argument for ease of use, and both `wpSetUpBeforeClass()` and `wpTearDownAfterClass()` don't need to call `self::commit_transaction()`.
Many tests use the `wpTearDownAfterClass()` method to clean up posts, users, roles, etc. created via `wpSetUpBeforeClass()`. However, due to [source:tags/6.0/tests/phpunit/includes/abstract-testcase.php?marks=88-95#L82 how the method was previously called], this cleanup happened after all data is **already deleted** from the database.
This could cause some confusion when refactoring tests. For example:
{{{
public static function wpTearDownAfterClass() {
$GLOBALS['_wp_additional_image_sizes'] = self::$_sizes;
}
public static function tear_down_after_class() {
wp_delete_attachment( self::$large_id, true );
parent::tear_down_after_class();
}
}}}
At a glance, it seems like these two methods can be combined:
{{{
public static function wpTearDownAfterClass() {
wp_delete_attachment( self::$large_id, true );
$GLOBALS['_wp_additional_image_sizes'] = self::$_sizes;
}
}}}
However, that would not work as expected: by the time `wp_delete_attachment()` runs, the attachment ID is no longer in the database, so it returns early, leaving some files in the `uploads` directory.
By calling `wpTearDownAfterClass()` in `WP_UnitTestCase_Base::tear_down_after_class()` before deleting all data, instead of after, we ensure that both of these methods have access to the same data and can be used interchangeably to perform cleanup as necessary.
Additionally, this commit moves the calls to parent methods in `WP_UnitTestCase_Base`:
* `parent::set_up_before_class()` to be the first thing called in `::set_up_before_class()`
* `parent::tear_down_after_class()` to be the last thing called in `::tear_down_after_class()`
This does not have any effect in practice, but brings consistency with how these methods are called in the test suite.
Follow-up to [35186], [35225], [35242], [38398], [39626], [49001], [51568].
Props ironprogrammer, SergeyBiryukov.
Fixes#55918. See #55652.
Built from https://develop.svn.wordpress.org/trunk@54366
git-svn-id: http://core.svn.wordpress.org/trunk@53925 1a063a9b-81f0-0310-95a4-ce76da25c4cd