Commit Graph

33408 Commits

Author SHA1 Message Date
Sergey Biryukov
2699a5fd2e Tests: Correct MariaDB version check in database charset tests.
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 the `Tests_DB_Charset` class to check for the correct version.

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]

Follow-up to [53918].

Fixes #53623.
Built from https://develop.svn.wordpress.org/trunk@53919


git-svn-id: http://core.svn.wordpress.org/trunk@53478 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-22 16:42:11 +00:00
Sergey Biryukov
fab7d60c64 Database: Account for utf8 being renamed to utf8mb3 in newer MariaDB and MySQL versions.
From [https://mariadb.com/kb/en/mariadb-1061-release-notes/ MariaDB 10.6.1 release notes]:
> The `utf8` [https://mariadb.com/kb/en/character-sets/ character set] (and related collations) is now by default an alias for `utf8mb3` rather than the other way around. It can be set to imply `utf8mb4` by changing the value of the [https://mariadb.com/kb/en/server-system-variables/#old_mode old_mode] system variable ([https://jira.mariadb.org/browse/MDEV-8334 MDEV-8334]).
From [https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-30.html#mysqld-8-0-30-charset MySQL 8.0.30 release notes]:
> **Important Change:** A previous change renamed character sets having deprecated names prefixed with `utf8_` to use `utf8mb3_` instead. In this release, we rename the `utf8_` collations as well, using the `utf8mb3_` prefix; this is to make the collation names consistent with those of the character sets, not to rely any longer on the deprecated collation names, and to clarify the distinction between `utf8mb3` and `utf8mb4`. The names using the `utf8mb3_` prefix are now used exclusively for these collations in the output of `SHOW` statements such as `SHOW CREATE TABLE`, as well as in the values displayed in the columns of Information Schema tables including the `COLLATIONS` and `COLUMNS` tables.

This commit adds `utf8mb3_bin` and `utf8mb3_general_ci` to the list of safe collations recognized by `wpdb::check_safe_collation()`. The full list is now as follows:
* `utf8_bin`
* `utf8_general_ci`
* `utf8mb3_bin`
* `utf8mb3_general_ci`
* `utf8mb4_bin`
* `utf8mb4_general_ci`

The change is covered by existing database charset unit tests: six tests which previously failed on MariaDB 10.6.1+ or MySQL 8.0.30+ now pass.

Includes:
* Adjusting the expected test results based on MariaDB and MySQL version.
* Using named data providers for the affected tests to make test output more descriptive.
* Adding a failure message to each assertion when multiple assertions are used in the test.

References:
* [https://mariadb.com/kb/en/mariadb-1061-release-notes/ MariaDB 10.6.1 release notes]
* [https://jira.mariadb.org/browse/MDEV-8334 MDEV-8334 Rename utf8 to utf8mb3]
* [https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-30.html#mysqld-8-0-30-charset MySQL 8.0.30 release notes]
* [https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8mb3.html The utf8mb3 Character Set (3-Byte UTF-8 Unicode Encoding)]

Follow-up to [30345], [32162], [37320].

Props skithund, ayeshrajans, JavierCasares, SergeyBiryukov.
Fixes #53623.
Built from https://develop.svn.wordpress.org/trunk@53918


git-svn-id: http://core.svn.wordpress.org/trunk@53477 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-22 15:39:13 +00:00
Sergey Biryukov
eb822d7fef External Libraries: Upgrade PHPMailer to version 6.6.4.
This is a maintenance release with minor changes:

* Add `text/csv` MIME type.
* Fix DKIM when sending to anonymous group via `mail()`.

Release notes:
https://github.com/PHPMailer/PHPMailer/releases/tag/v6.6.4

For a full list of changes in this update, see the PHPMailer GitHub:
https://github.com/PHPMailer/PHPMailer/compare/v6.6.3...v6.6.4

Follow-up to [50628], [50799], [51169], [51634], [51635], [52252], [52749], [52811], [53500], [53535].

Props jrf, Synchro.
Fixes #56016.
Built from https://develop.svn.wordpress.org/trunk@53917


git-svn-id: http://core.svn.wordpress.org/trunk@53476 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-22 12:26:12 +00:00
Sergey Biryukov
9f48903eec Code Modernization: Remove dynamic properties in theme tests.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this particular group of test files, the test classes contain a `set_up()` method which sets a few dynamic (not explicitly declared) properties.

For those properties which were set using a function call or variable access, the property has been explicitly declared on the class now.

For those properties which were set using a constant scalar expression and for which the value is not changed by any of the tests, the property setting has been removed in favor of declaring a class constant.

Includes removing one unused dynamic property declaration: `$this->queries` in `Test_Block_Supports_Layout`, which appears to be a copy/paste from `Tests_Theme_wpThemeJsonResolver`.

Follow-up to [40/tests], [260/tests], [598/tests], [50960], [52675], [53085], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53916


git-svn-id: http://core.svn.wordpress.org/trunk@53475 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-21 16:57:13 +00:00
Sergey Biryukov
107f660a7e Coding Standards: Simplify the logic in wp_not_installed().
The function to check whether WordPress is not installed has evolved over time, ending up with duplicate conditionals.

This commit combines two conditionals into a single one and includes an early return.

Follow-up to [672], [676], [725], [1184], [1401], [1980], [2171], [2467], [2468], [2486], [2703], [3011], [3670], [12688], [12732], [12762], [13253], [29599], [30581], [34828].

See #55647.
Built from https://develop.svn.wordpress.org/trunk@53915


git-svn-id: http://core.svn.wordpress.org/trunk@53474 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-20 00:32:10 +00:00
Sergey Biryukov
6ceef39b2d Coding Standards: Check for deprecated options before wp_installing().
This is a micro-optimization that makes the conditional several times faster for non-deprecated options by avoiding an unnecessary function call.

Functions affected:
* `get_option()`
* `update_option()`
* `add_option()`

Follow-up to [48575].

See #55647.
Built from https://develop.svn.wordpress.org/trunk@53914


git-svn-id: http://core.svn.wordpress.org/trunk@53473 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-20 00:27:12 +00:00
joedolson
806336ce27 Taxonomy: Associate field descriptions with fields.
Use `aria-describedby` to associate the field descriptions and instructions with the form fields when creating or editing taxonomy terms.

Props afercia.
Fixes #55651.
Built from https://develop.svn.wordpress.org/trunk@53913


git-svn-id: http://core.svn.wordpress.org/trunk@53472 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-19 23:06:09 +00:00
joedolson
82f3535083 Embeds: Fix missing labels and duplicate IDs.
Add `aria-label` and `aria-describedby` to provide embed form fields with accessible names and ensure each embed has a unique ID attribute to prevent duplicate IDs.

Props afercia, swissspidy.
Fixes #55664.
Built from https://develop.svn.wordpress.org/trunk@53912


git-svn-id: http://core.svn.wordpress.org/trunk@53471 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-19 22:06:09 +00:00
joedolson
f5ca26cd24 Permalinks: Fix aria-live text when removing custom structure.
Change the notification announced when a custom structure is removed. Previously, the notification incorrectly indicated that the structure was added for both actions. This changes the notification to correctly announce removals when structures are removed.

Props joedolson, kebbet, SergeyBiryukov.
Fixes #56230.
Built from https://develop.svn.wordpress.org/trunk@53911


git-svn-id: http://core.svn.wordpress.org/trunk@53470 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-19 21:00:09 +00:00
desrosj
594f5ae8c1 Docs: Remove incorrect default value for $path argument of admin_url().
Props joyously, costdev.
See #55646.
Built from https://develop.svn.wordpress.org/trunk@53910


git-svn-id: http://core.svn.wordpress.org/trunk@53469 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-19 19:48:15 +00:00
Sergey Biryukov
15fe8be299 Tests: Assign created fixtures to the dedicated class properties in some test classes.
This affects:
* `WP_Test_REST_Categories_Controller`
* `WP_Test_REST_Comments_Controller`
* `WP_Test_REST_Tags_Controller`

and brings consistency with:
* `WP_Test_REST_Posts_Controller`
* `WP_Test_REST_Users_Controller`

These test classes were previously updated to improve performance by creating less fixtures and reusing them where possible. While the pagination tests for categories and comments still passed due to enough items being created, the pagination test for tags did not work as expected and did not perform any assertions due to trying to iterate over an empty array of results.

This is now corrected by assigning the properties as intended and adding more assertions to the affected test.

Follow-up to [46657].

Props johnregan3, costdev, johnbillion.
See #54662.
Built from https://develop.svn.wordpress.org/trunk@53909


git-svn-id: http://core.svn.wordpress.org/trunk@53468 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-19 16:15:09 +00:00
Sergey Biryukov
9c95525ad8 Themes: Include a hyphen in the Block Themes tab key on Add Themes screen.
This better matches the tab name and changes the associated action hooks to:

* `install_themes_pre_block-themes` (fires before the tab is rendered)
* `install_themes_block-themes` (fires at the top the tab)

While including a mix of underscores and hyphens in a hook name is not quite typical for core, it does have a precedent and brings more consistency with similar filters on Add Plugin screen:

* `install_plugins_pre_plugin-information`
* `install_plugins_plugin-information`

Follow-up to [53906], [53907].

Fixes #56283.
Built from https://develop.svn.wordpress.org/trunk@53908


git-svn-id: http://core.svn.wordpress.org/trunk@53467 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-19 13:11:14 +00:00
Sergey Biryukov
cd2cb1e306 Coding Standards: Remove a one-time variable in themes.view.Installer.browse.
Alphabetize the list of possible hook name in `install_themes_pre_*` and `install_themes_*` filters.

Follow-up to [53906].

See #56283.
Built from https://develop.svn.wordpress.org/trunk@53907


git-svn-id: http://core.svn.wordpress.org/trunk@53466 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-18 14:09:15 +00:00
audrasjb
1b50325a5b Themes: Add a Block Themes filter in Theme Install Screen.
The Theme Directory on wordpress.org recently got updated to show a shortcut for filtering block themes. This changeset adds a "Block Themes" filter when adding a new theme from WordPress administration.

It also introduces two new action hooks: `install_themes_pre_blockthemes` (fires before the tab is rendered) and `install_themes_blockthemes` (fires at the top the tab).

Follow-up to [meta11963].

Props luminuu, audrasjb, SergeyBiryukov, rafiahmedd.
Fixes #56283.
See #meta6330.

Built from https://develop.svn.wordpress.org/trunk@53906


git-svn-id: http://core.svn.wordpress.org/trunk@53465 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-18 11:45:12 +00:00
audrasjb
37cc6aacc1 Docs: Use third-person singular verbs for function descriptions in WP_Tax_Query class, as per docblocks standards.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53905


git-svn-id: http://core.svn.wordpress.org/trunk@53464 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-18 11:28:12 +00:00
audrasjb
183165304f Script Loader: Remove default DNS prefetch entry for s.w.org.
A default DNS prefetch entry for s.w.org was previously included to save a few ms in case an emoji is used that is not supported by the browser. It appears this use case doesn't justify a prefetch to s.w.org on every WordPress website.

This changesets removes `emoji_svg_url` prefetch from `wp_resource_hints()`. It also updates unit tests in `Tests_General_wpResourceHints` by removing `test_should_have_defaults_on_frontend()` entirely and removing s.w.org prefetch from expected output of ten other test functions.

Plugin authors can use the `wp_resource_hints` filter if they need to re-add the DNS prefetch entry for s.w.org.

Follow-up to [37920], [38122].

Props joelhardi, superpoincare, jhabdas, garrett-eclipse, sabernhardt, SergeyBiryukov.
Fixes #40426.
See #37387.

Built from https://develop.svn.wordpress.org/trunk@53904


git-svn-id: http://core.svn.wordpress.org/trunk@53463 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-18 08:45:12 +00:00
Sergey Biryukov
431a8d5414 Build/Test Tools: Only define WP_PLUGIN_DIR when running core tests.
This takes into account plugin or theme test suites that rely on `WP_PLUGIN_DIR` being set to a custom path.

Follow-up to [49236], [49269], [49566], [53874].

Props aaemnnosttv, flixos90.
Fixes #39210.
Built from https://develop.svn.wordpress.org/trunk@53902


git-svn-id: http://core.svn.wordpress.org/trunk@53461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-17 21:05:12 +00:00
Sergey Biryukov
d89482b22d Query: Cast the meta key to BINARY for case-sensitive key comparisons in WP_Meta_Query.
This addresses an error on MySQL 8.0.22 or later:
{{{
Character set 'utf8mb4_unicode_520_ci' cannot be used in conjunction with 'binary' in call to regexp_like
}}}

From the [https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-22.html MySQL 8.0.22 changelog]:
> Regular expression functions such as `REGEXP_LIKE()` yielded inconsistent results with binary string arguments. These functions now reject binary strings with an error. ([https://bugs.mysql.com/bug.php?id=98951 Bug #98951], [https://bugs.mysql.com/bug.php?id=98950 Bug #98950])

WordPress meta queries use the `BINARY` data type for case-sensitive meta key comparisons using regular expressions. By explicitly casting the meta key to `BINARY`, we can make sure the values being compared use the same character set and produce consistent results.

The change is covered by existing meta query unit tests: three tests which previously failed on MySQL 8.0.22 or later now pass.

References:
* [https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-22.html MySQL 8.0.22 changelog]
* [https://bugs.mysql.com/bug.php?id=104387 Bug #104387 CHARACTER_SET_MISMATCH issue with regex comparisons]

Follow-up to [46188].

Fixes #51740.
Built from https://develop.svn.wordpress.org/trunk@53901


git-svn-id: http://core.svn.wordpress.org/trunk@53460 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-17 14:00:13 +00:00
desrosj
fa9c62915f Mail: Prevent the last character of names in “From” headers from being trimmed.
When extracting the email and name from a “From” header, the last character of the name is incorrectly trimmed when a space is not included between the name and the opening `<`.

Though the space is required for the header to be compliant with RFC5322 (see https://www.rfc-editor.org/rfc/rfc5322#section-3.4), the absence of a space can be ignored here. PHPMailer accepts the name and email as separate parameters and constructs the header correctly later on.

Props hakanca, mikehansenme, SergeyBiryukov, kovshenin, mattyrob, drewapicture, desrosj.
Fixes #19847.
Built from https://develop.svn.wordpress.org/trunk@53900


git-svn-id: http://core.svn.wordpress.org/trunk@53459 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-16 18:18:14 +00:00
desrosj
01f73a3bd7 Build/Test Tools: Increase the Dependabot pull request limit for GitHub Actions.
This ensures updates for all 3rd party actions will be flagged when updates exist simultaneously.

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53899


git-svn-id: http://core.svn.wordpress.org/trunk@53458 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-16 17:24:12 +00:00
Sergey Biryukov
f8c9068b79 Upgrade/Install: Make WP_Filesystem_FTPext::size() return false on failure.
While `WP_Filesystem_Base::size()` is documented to return `false` on failure, `ftp_size()` returns -1, and the method documentation was recently updated to reflect that.

This commit restores the previous `@return` tag and corrects the actual return value instead, to bring consistency with all the other `WP_Filesystem_*::size()` methods:
* `WP_Filesystem_Base::size()`
* `WP_Filesystem_Direct::size()`
* `WP_Filesystem_ftpsockets::size()`
* `WP_Filesystem_SSH2::size()`
{{{
@return int|false Size of the file in bytes on success, false on failure.
}}}

This better matches the purpose of the API to provide a consistent interface for various filesystem implementations.

Follow-up to [6779], [30678], [45226], [53860], [53862].

Fixes #51170.
Built from https://develop.svn.wordpress.org/trunk@53898


git-svn-id: http://core.svn.wordpress.org/trunk@53457 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-16 13:41:14 +00:00
Sergey Biryukov
b90c2adb7f Database: Ignore display width for integer data types in dbDelta() on MySQL 8.0.17 or later.
MySQL 8.0.17 deprecated the display width attribute for integer data types:
> As of MySQL 8.0.17, the `ZEROFILL` attribute is deprecated for numeric data types, as is the display width attribute for integer data types. You should expect support for `ZEROFILL` and display widths for integer data types to be removed in a future version of MySQL. Consider using an alternative means of producing the effect of these attributes. For example, applications can use the `LPAD()` function to zero-pad numbers up to the desired width, or they can store the formatted numbers in `CHAR` columns.

In practice, this means that display width is removed for integer types when creating a table:
* `BIGINT(20)` → `BIGINT`
* `INT(11)` → `INT`
* `MEDIUMINT(9)` → `MEDIUMINT`
* `SMALLINT(6)` → `SMALLINT`
* `TINYINT(4)` → `TINYINT`

Note: This only applies specifically to MySQL 8.0.17 or later. In MariaDB, display width for integer types is still available and expected.

This commit ensures that `dbDelta()`, which relies on the `DESCRIBE` SQL command to get the existing table structure and field types, when running on MySQL 8.0.17 or later, does not unnecessarily attempt to convert `BIGINT` fields back to `BIGINT(20)`, `INT` back to `INT(11)`, etc. When comparing the field type in the query with the existing field type, if display width is the only difference, it can be safely ignored to match MySQL behavior.

The change is covered by existing `dbDelta()` unit tests:
* A test for not altering `wp_get_db_schema()` queries on an existing install using MySQL 8.0.17+ now passes.
* More than twenty tests which previously failed on PHP 8.0.x + MariaDB due to incorrect expectations, caused by MariaDB version reporting not being consistent between PHP versions, now pass.

References:
* [https://dev.mysql.com/doc/refman/8.0/en/numeric-type-attributes.html MySQL: Nymeric Type Attributes]
* [https://mariadb.com/kb/en/data-types-numeric-data-types/ MariaDB: Numeric Data Types]

Follow-up to [1575], [18899], [37525], [47183], [47184].

Props SergeyBiryukov, pbearne, leewillis77, JavierCasares, desrosj, costdev, johnbillion.
Fixes #49364. See #51740.
Built from https://develop.svn.wordpress.org/trunk@53897


git-svn-id: http://core.svn.wordpress.org/trunk@53456 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-15 13:18:13 +00:00
Sergey Biryukov
0e6a976c0a Coding Standards: Restore correct regex formatting in dbDelta().
An earlier regex for normalizing index definitions disables the PHPCS check for extra padding in order to keep a more readable indentation. However, this was missed for index columns regex.

Follow-up to [37583], [42228], [42249], [42343].

See #55647.
Built from https://develop.svn.wordpress.org/trunk@53896


git-svn-id: http://core.svn.wordpress.org/trunk@53455 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-14 02:14:12 +00:00
John Blackbourn
8a9a20c3ee Build/Test Tools: Move the Memcached container into the Docker Compose config.
This allows a developer to use the persistent Memcached object cache on their local development environment via the `LOCAL_PHP_MEMCACHED` environment variable.

Enable the memcached config via `LOCAL_PHP_MEMCACHED=true` in the `.env` file and then restart the environment with `npm run env:restart`.

Fixes #55700

Built from https://develop.svn.wordpress.org/trunk@53895


git-svn-id: http://core.svn.wordpress.org/trunk@53454 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-13 23:25:08 +00:00
John Blackbourn
b8cfc0b45e Taxonomy: Add a test file that was missed in [53893].
See #56215

Built from https://develop.svn.wordpress.org/trunk@53894


git-svn-id: http://core.svn.wordpress.org/trunk@53453 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-13 22:46:08 +00:00
John Blackbourn
85306e1fd6 Taxonomy: Introduce the is_term_publicly_viewable() function.
This is the taxonomy term counterpart to the `is_post_publicly_viewable()` function. Although the logic for terms is more straight forward this serves the same purpose as introducing the corresponding function for posts -- to centralise and reduce the logic needed to validate a term and determine if it's publicly viewable.

Props peterwilsoncc, costdev, johnbillion

Fixes #56215

Built from https://develop.svn.wordpress.org/trunk@53893


git-svn-id: http://core.svn.wordpress.org/trunk@53452 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-13 22:44:09 +00:00
John Blackbourn
e8a05d5082 Editor: Document the arguments for registering a block style.
See #55646

Built from https://develop.svn.wordpress.org/trunk@53892


git-svn-id: http://core.svn.wordpress.org/trunk@53451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-13 22:38:09 +00:00
John Blackbourn
11a3a91511 Query: Be better at forcing data types for query vars.
Several query vars only accept a scalar value and pass the value through functions that assume a scalar value. Adding extra guard conditions to the types of query vars doesn't affect their functionality but does remove PHP notices and warnings that can otherwise be generated when a non-scalar value such as an array is present in a query var.

Props juliobox, xknown, SergeyBiryukov, dave1010, nacin, tellyworth, dd32, audrasjb, johnregan3

Fixes #17737

Built from https://develop.svn.wordpress.org/trunk@53891


git-svn-id: http://core.svn.wordpress.org/trunk@53450 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-13 22:31:11 +00:00
Sergey Biryukov
fadf5c5fe9 Tests: Bring some consistency to serialization tests.
There were two sets of tests for `is_serialized()`:
* One in the `functions.php` file, based on the same file name in core.
* One in a separate class in the `functions` directory.

To avoid confusion and make it easier to decide where new tests should go in the future, the existing tests are now combined in the latter location.

Includes:
* Moving `is_serialized()` and `maybe_serialize()` tests into their own classes.
* Using named data providers to make test output more descriptive.
* Combining test cases and removing duplicates.

Follow-up to [278/tests], [279/tests], [328/tests], [32631], [45754], [47452], [49382], [53886], [53889].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53890


git-svn-id: http://core.svn.wordpress.org/trunk@53449 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-13 12:11:11 +00:00
Sergey Biryukov
2f1cac50d3 Tests: Use named data provider for is_serialized_string() tests.
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.

Follow-up to [37357], [44478].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53889


git-svn-id: http://core.svn.wordpress.org/trunk@53448 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-12 13:24:10 +00:00
audrasjb
e7d91b8017 General: Add required fields helper functions for better reusability.
This changeset introduces new `wp_required_field_indicator()` and `wp_required_field_message()` helper functions to generate reusable and consistent required field indicator and message. It also implements these functions in various admin screens.

Props sabernhardt, ryokuhi, joedolson, audrasjb, SergeyBiryukov.
Fixes #54394.

Built from https://develop.svn.wordpress.org/trunk@53888


git-svn-id: http://core.svn.wordpress.org/trunk@53447 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-12 12:11:09 +00:00
audrasjb
32879ad1e6 Docs: Use third-person singular verbs for function descriptions in wp-includes/functions.php, as per docblocks standards.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53887


git-svn-id: http://core.svn.wordpress.org/trunk@53446 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-12 09:53:11 +00:00
audrasjb
05f7d32a83 Formatting: Add support for Enums in is_serialized().
This changeset adds support for Enums in `is_serialized()`. It also adds new unit tests for this function.

Props ayeshrajans, konradyoast, peterwilsoncc, costdev, dennisatyoast, mukesh27.
Fixes #53299.

Built from https://develop.svn.wordpress.org/trunk@53886


git-svn-id: http://core.svn.wordpress.org/trunk@53445 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-12 09:26:12 +00:00
Peter Wilson
0161ef8f72 Media: Cache parent posts in query-attachments AJAX endpoint.
Prime the parent post objects `wp_ajax_query_attachments()` to reduce the number of database queries in the query-attachments admin-ajax endpoint.

Props albatross10.
Fixes #56037.


Built from https://develop.svn.wordpress.org/trunk@53885


git-svn-id: http://core.svn.wordpress.org/trunk@53444 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-12 00:17:07 +00:00
Sergey Biryukov
d7f5fe1283 Login and Registration: Introduce is_login_screen() function.
This should help determine whether the current request is for the login screen.

While it does not save a lot of lines of code, including this function in core aims to save developers some time that would otherwise be spent investigating the most reliable way to solve this problem.

Implementation details:
* By checking `wp_login_url()`, the function accounts for custom login locations set via the `login_url` filter.
* By checking `$_SERVER['SCRIPT_NAME']` directly, instead of `did_action( 'login_form_login' )` or `$pagenow` global, the function can work as early as possible, for example in a must-use plugin.

Follow-up to [2481], [6412], [12393], [12732], [15558], [15481], [15746].

Props dcowgill, scribu, donmhico, iandunn, wonderboymusic, nacin, robmiller, kitchin, chriscct7, tazotodua, davidbaumwald, SergeyBiryukov.
Fixes #19898.
Built from https://develop.svn.wordpress.org/trunk@53884


git-svn-id: http://core.svn.wordpress.org/trunk@53443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 21:51:08 +00:00
John Blackbourn
20edeb6e09 Posts, Post Types: Prevent categories from being overwritten when updating a post using wp_insert_post().
This prevents existing category relationships being overridden with the default category when none is provided in the post data.

Props markoheijnen, leewillis77, desrosj

Fixes #19954

Built from https://develop.svn.wordpress.org/trunk@53883


git-svn-id: http://core.svn.wordpress.org/trunk@53442 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 20:00:10 +00:00
John Blackbourn
c1db3198ce Application Passwords: Allow a Super Admin to set an application password on a site they're not a member of.
This removes the requirement that a Super Admin must be a member of the current site when they attempt to set an application password within the admin area of an individual site on the network.

Props TimothyBlynJacobs, ilovecats7, johnbillion, georgestephanis, johnjamesjacoby

Fixes #53224

Built from https://develop.svn.wordpress.org/trunk@53882


git-svn-id: http://core.svn.wordpress.org/trunk@53441 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 18:24:09 +00:00
John Blackbourn
41b3519fbe XML-RPC: Correct the documented arguments for XML-RPC server methods.
See #55646

Built from https://develop.svn.wordpress.org/trunk@53881


git-svn-id: http://core.svn.wordpress.org/trunk@53440 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 15:00:08 +00:00
desrosj
e539bb94dc Bundled Themes: Remove closing PHP tag at the end of files.
To help avoid issues with trailing whitespace, omitting the closing PHP tag at the end of a file is preferred.

Props netweb, dd32, yahil, milindmore22, vishalkakadiya, NomNom99, manishsongirkar36, sabernhardt, audrasjb, desrosj.
See #40039.
Built from https://develop.svn.wordpress.org/trunk@53880


git-svn-id: http://core.svn.wordpress.org/trunk@53439 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 14:46:09 +00:00
John Blackbourn
1cf5a0351f Docs: Revert two changes that need to instead be made upstream in the Gutenberg repo.
Partially reverts [53877].

See #55646

Built from https://develop.svn.wordpress.org/trunk@53879


git-svn-id: http://core.svn.wordpress.org/trunk@53438 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 14:33:10 +00:00
John Blackbourn
77bf28a1b7 Docs: Miscellaneous inline documentation improvements.
See #55646

Built from https://develop.svn.wordpress.org/trunk@53878


git-svn-id: http://core.svn.wordpress.org/trunk@53437 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 14:11:08 +00:00
John Blackbourn
1d4e72c798 Docs: Correct and improve the documented types for various functions and hooks.
See #55646

Built from https://develop.svn.wordpress.org/trunk@53877


git-svn-id: http://core.svn.wordpress.org/trunk@53436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 14:03:09 +00:00
John Blackbourn
bbdc255d50 Docs: Remove code tags from WordPress function names within inline documentation.
Removing these code tags means the function name will be automatically linked on the developer.wordpress.org reference, which is more useful than just seeing the function name.

See #55646

Built from https://develop.svn.wordpress.org/trunk@53876


git-svn-id: http://core.svn.wordpress.org/trunk@53435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 13:55:08 +00:00
desrosj
8f513bba30 Twenty Eleven: Correct inline translator comment.
Props sabernhardt.
See #40039.
Built from https://develop.svn.wordpress.org/trunk@53875


git-svn-id: http://core.svn.wordpress.org/trunk@53434 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 13:06:09 +00:00
Pascal Birchler
bb9f57429a I18N: Introduce WP_Textdomain_Registry to store text domains and their language directory paths.
Previously, when using `switch_to_locale()` all current loaded text domains were unloaded and added to the `$l10n_unloaded` global. This prevented the just-in-time loading for text domains after a switch. The just-in-time loading was also only possible if the translations were stored in `WP_LANG_DIR`. Both issues have been fixed.

* Adds `WP_Textdomain_Registry` to keep track of the language directory paths for all plugins and themes.
* Updates all `load_*_textdomain()`  functions to store the path in `WP_Textdomain_Registry`.
* Adds `$locale` parameter to `load_textdomain()` to specify the locale the translation file is for.
* Adds `$reloadable` parameter to `unload_textdomain()` to define whether a text domain can be loaded just-in-time again. This is used by `WP_Locale_Switcher::load_translations()`.
* Extends `_load_textdomain_just_in_time()` to also support text domains of plugins and themes with custom language directories.
* Fixes the incorrect `test_plugin_translation_after_switching_locale_twice()` test which should have caught this issue earlier.
* Adds a new test plugin and theme to test the loading of translations with a custom language directory.
* Deprecates the now unused and private `_get_path_to_translation()` and `_get_path_to_translation_from_lang_dir()` functions.

Previously added in [49236] and reverted in [49236] to investigate concerns which are now addressed here.

Props yoavf, swissspidy, dd32, ocean90.
See #26511.
Fixes #39210.
Built from https://develop.svn.wordpress.org/trunk@53874


git-svn-id: http://core.svn.wordpress.org/trunk@53433 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 12:39:12 +00:00
audrasjb
50e3e21cb2 Docs: Clarify that register_taxonomy() only accepts lowercase values for the $taxonomy parameter.
This brings consistency with docblock used in `register_post_type()`.

Props audrasjb, bengreeley, dipakparmar443.
Fixes #56352
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53873


git-svn-id: http://core.svn.wordpress.org/trunk@53432 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-10 13:54:12 +00:00
Sergey Biryukov
c3783c9f3a Coding Standards: Rename the $file parameter to $path in some WP_Filesystem_* methods.
This aims to bring more clarity to the code, and applies to methods where the path can be a file or a directory:

* `WP_Filesystem_*::exists()`
* `WP_Filesystem_*::is_writable()`

Follow-up to [6779], [25560].

See #55647.
Built from https://develop.svn.wordpress.org/trunk@53872


git-svn-id: http://core.svn.wordpress.org/trunk@53431 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-09 11:33:10 +00:00
audrasjb
60d0586c27 Docs: Various docblock fixes in Core Taxonomy API, as per docs standards.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53871


git-svn-id: http://core.svn.wordpress.org/trunk@53430 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-09 10:41:10 +00:00
Dominik Schilling
7799eafcd0 Docs: Consistently document the $excluded_terms variable in get_adjacent_post().
The variable `$excluded_terms` is an array of excluded term IDs or empty string if none were provided.

Props grapplerulrich, costdev.
Fixes #56348.
Built from https://develop.svn.wordpress.org/trunk@53870


git-svn-id: http://core.svn.wordpress.org/trunk@53429 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-09 10:31:09 +00:00
audrasjb
f63d34e3e3 Taxonomy: Prevent non string taxonomy names generating warnings or errors.
This changeset adds an `is_string( $taxonomy )` check to the condition in `taxonomy_exists()`, to ensure `false` is returned when the `$taxonomy` is not a string.

Follow-up to [35718].

Props costdev, peterwilsoncc, mukesh27.
Fixes #56338.
See #56336.

Built from https://develop.svn.wordpress.org/trunk@53869


git-svn-id: http://core.svn.wordpress.org/trunk@53428 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-09 10:23:13 +00:00
Peter Wilson
f627535216 Administration: Improve performance of List Tables.
Improve the performance of `WP_List_Table::get_column_info()` by adding the primary column to the cached header values. This reduces the number of calls to the `WP_List_Table::get_primary_column_name()` method to once per table in line with the other header getter functions.

Props bobbingwide, chaion07, costdev, mikeschroder, mukesh27, peterwilsoncc, shetheliving, spacedmonkey.
Fixes #34564.


Built from https://develop.svn.wordpress.org/trunk@53868


git-svn-id: http://core.svn.wordpress.org/trunk@53427 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-09 00:33:11 +00:00
Andrew Ozz
3f12697795 Build/Test Tools: Update @covers tags for the load tests.
Props pbearne, jrf, hellofromTonya, patopaiar, ironprogrammer, antonvlasenko, SergeyBiryukov, costdev.
See #39265.
Built from https://develop.svn.wordpress.org/trunk@53867


git-svn-id: http://core.svn.wordpress.org/trunk@53426 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-08 23:44:12 +00:00
Andrew Ozz
a656ba3f5c Build/Test Tools: Add @covers tags to the l10n and i18n tests.
Props pbearne, jrf, hellofromTonya, patopaiar, ironprogrammer, antonvlasenko, SergeyBiryukov, costdev.
See #39265.
Built from https://develop.svn.wordpress.org/trunk@53866


git-svn-id: http://core.svn.wordpress.org/trunk@53425 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-08 23:41:13 +00:00
Andrew Ozz
46dbe91667 Build/Test Tools: Add @covers tags to the options tests.
Props pbearne, jrf, hellofromTonya, patopaiar, ironprogrammer, antonvlasenko, SergeyBiryukov, costdev.
See #39265.
Built from https://develop.svn.wordpress.org/trunk@53865


git-svn-id: http://core.svn.wordpress.org/trunk@53424 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-08 23:35:09 +00:00
Andrew Ozz
4b5f556d69 Build/Test Tools: Add @covers tags to the import tests.
Props pbearne, jrf, hellofromTonya, patopaiar, ironprogrammer, antonvlasenko, SergeyBiryukov, costdev.
See #39265.
Built from https://develop.svn.wordpress.org/trunk@53864


git-svn-id: http://core.svn.wordpress.org/trunk@53423 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-08 23:24:10 +00:00
Andrew Ozz
8367a96af8 Build/Test Tools: Add @covers tags to the comments tests.
Props pbearne, jrf, hellofromTonya, patopaiar, ironprogrammer, antonvlasenko, SergeyBiryukov, costdev.
See #39265.
Built from https://develop.svn.wordpress.org/trunk@53863


git-svn-id: http://core.svn.wordpress.org/trunk@53422 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-08 23:14:12 +00:00
Sergey Biryukov
7f0fc452b1 Docs: Improve @since notes for some WP_Filesystem_* methods:
* `WP_Filesystem_FTPext::exists()`
* `WP_Filesystem_FTPext::size()`
* `WP_Filesystem_ftpsockets::exists()`

The `::exists()` methods were previously using the FTP `NLST` command, which works for directories, but is not intended to be applied to a file. This only worked most of the time due to many FTP servers being permissive and allowing to execute `NLST` on files, which cannot be guaranteed and appears to not be the case in newer versions of Pure-FTPd (1.0.48 or later).

With a recent change in [53860], both methods were updated for compatibility with RFC 959:

* Both methods check if the path is a directory that can be changed into (and therefore exists).
* `WP_Filesystem_FTPext` uses `ftp_rawlist()` (FTP `LIST` command) to check for file existence.
* `WP_Filesystem_ftpsockets` uses file size to check for file existence.

Reference: [https://www.ietf.org/rfc/rfc959.txt RFC 959: File Transfer Protocol (FTP)]

Follow-up to [6779], [11821], [25274], [33648], [34733], [35944], [35946], [53860].

See #51170.
Built from https://develop.svn.wordpress.org/trunk@53862


git-svn-id: http://core.svn.wordpress.org/trunk@53421 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-08 17:14:13 +00:00
Sergey Biryukov
6e38153854 Tests: Improve the test for not throwing a warning on malformed date queries.
* Make it specifically about `wp_resolve_numeric_slug_conflicts()`, the function that was throwing an `Undefined array key "year"` PHP warning for malformed date requests.
* Move the test under the `rewrite` component and make its name a bit more descriptive.
* Check the return result of the function instead of performing a dummy assertion.
* Use named array keys in the data provider for clarity.
* Add missing `@covers` tag.

Follow-up to [32648], [53857].

Props costdev, peterwilsoncc, 1naveengiri, mukesh27, SergeyBiryukov.
See #52252, #45513.
Built from https://develop.svn.wordpress.org/trunk@53861


git-svn-id: http://core.svn.wordpress.org/trunk@53420 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-08 14:40:10 +00:00
audrasjb
6a5506304e Filesystem: Rewrite FTP/FTP Sockets exists() methods to implement a more stable check.
WordPress FTP file checking was previously based upon `ftp_nlist()`. This function can be problematic at scale with a directory containing a large number of files. The same issue occurred using it with ftpsockets.

This changeset rewrites the FTP `exists()` functions to utilize a more efficient and stable check.

Props giox069, desrosj, mkox, afragen, costdev, pbiron, peterwilsoncc.
Fixes #51170.
See #53318, #39781.

Built from https://develop.svn.wordpress.org/trunk@53860


git-svn-id: http://core.svn.wordpress.org/trunk@53419 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-08 12:41:13 +00:00
audrasjb
af08ed758d Docs: Various docblock fixes in wp-includes/blocks.php, as per docs standards.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53859


git-svn-id: http://core.svn.wordpress.org/trunk@53418 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-08 08:33:09 +00:00
audrasjb
ba7b41113c Editor: Safeguard has_blocks() against fatal errors.
This changeset ensures `has_blocks()` doesn't return a fatal error when `$post` is not a valid post. If the post can't be retrieved, the function now returns `false`.

Props Howdy_McGee, costdev, colonelphantom, audrasjb, dlh, peterwilsoncc.
Fixes #55705.

Built from https://develop.svn.wordpress.org/trunk@53858


git-svn-id: http://core.svn.wordpress.org/trunk@53417 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-08 08:22:12 +00:00
Peter Wilson
51346d566a Rewrite rules: Prevent malformed date requests throwing notices.
Ensure that date queries contain each component before attempting to use them. This prevents http requests triggering notices if a portion of the date is missing. For example a request containing a day and year but no month, a request containing a month bu not year.

Props ovidiul, dd32, peterwilsoncc, costdev, johnbillion, SergeyBiryukov, desrosj, tremidkhar, hellofromTonya.
Fixes #52252.


Built from https://develop.svn.wordpress.org/trunk@53857


git-svn-id: http://core.svn.wordpress.org/trunk@53416 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-07 23:05:10 +00:00
Sergey Biryukov
7b6f526942 Code Modernization: Let MockClass extend stdClass.
This allows for arbitrary properties to be declared on it.

Alternatively, the `MockClass` could be deprecated altogether in favor of directly using `stdClass` where needed.

Follow-up to [53/tests], [65/tests], [53557], [53558], [53850], [53851], [53852], [53853], [53854].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53856


git-svn-id: http://core.svn.wordpress.org/trunk@53415 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-07 16:55:07 +00:00
Sergey Biryukov
bbf21ea549 Code Modernization: Remove unused $undefined property in Tests_WP_Customize_Manager.
This appears to be a copy/paste from the `Tests_WP_Customize_Setting` class, and is not actually used in `WP_Customize_Manager` tests.

Follow-up to [31329], [32658], [53851].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53855


git-svn-id: http://core.svn.wordpress.org/trunk@53414 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-07 16:38:09 +00:00
Sergey Biryukov
cf9f373c8c Code Modernization: Remove dynamic properties in Tests_File.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this case, as the `$badchars` property never changes, declaring this as a class constant is the sensible option.

As for the `$dir` property (which cannot be turned into a constant due to the function call), this is used in multiple tests, so making this property explicit makes sense.

Follow-up to [139/tests], [53557], [53558], [53850], [53851], [53852], [53853].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53854


git-svn-id: http://core.svn.wordpress.org/trunk@53413 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-07 14:50:09 +00:00
Sergey Biryukov
15df935777 Code Modernization: Remove dynamic properties in Tests_Post_Revisions.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this particular case, the test class contains a `set_up()` method that sets the `$post_type` property, which is ''used'' by the tests, but never ''changed'' by the tests.

In other words, setting this property in the `set_up()` is an unnecessary overhead and the property should be changed to a class constant.

Follow-up to [1212/tests], [52389], [53557], [53558], [53850], [53851], [53852].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53853


git-svn-id: http://core.svn.wordpress.org/trunk@53412 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-07 14:43:08 +00:00
Sergey Biryukov
ab15c41a07 Code Modernization: Remove dynamic properties in Tests_Media_GetPostGalleries.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

In this particular case, the test class contains a `set_up()` method that sets the `$img_meta` property, which is ''used'' by the tests, but never ''changed'' by the tests.

In other words, setting this property in the `set_up()` is an unnecessary overhead and the property should be changed to a class constant.

Includes renaming the test class to match the [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization naming conventions].

Follow-up to [52190], [53557], [53558], [53850], [53851].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53852


git-svn-id: http://core.svn.wordpress.org/trunk@53411 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-07 14:34:10 +00:00
Sergey Biryukov
d93e9a04bf Code Modernization: Remove unused dynamic property in Tests_WP_Customize_*.
The dynamically created `$undefined` property appears to be a copy/paste from the `Tests_WP_Customize_Setting` class, and is not actually used in other test classes:

* `Tests_WP_Customize_Manager`
* `Tests_WP_Customize_Panel`
* `Tests_WP_Customize_Section`

Follow-up to [31329], [32658].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53851


git-svn-id: http://core.svn.wordpress.org/trunk@53410 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-07 14:22:10 +00:00
Sergey Biryukov
82373729ee Code Modernization: Remove dynamic properties in Tests_POMO_PO.
In this particular case, the test class contains a `set_up()` method which sets properties only used by select tests, while the fixture method is being run for all tests.

There were a few ways this could be fixed:
* As the values do not change across tests, use `set_up_before_class()` to set (static) properties instead.
* For those values which are set up without a function call or variable interpolation, set the values in class constants.
* Or set these values as local variables for those tests which actually use them.

The implemented solution is a combination of options 2 and 3.

Follow-up to [1106/tests], [53557], [53558].

Props jrf.
See #56033.
Built from https://develop.svn.wordpress.org/trunk@53850


git-svn-id: http://core.svn.wordpress.org/trunk@53409 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-07 13:58:12 +00:00
Sergey Biryukov
f881308496 Tests: Rename the test class for wp_preload_resources() tests.
This matches the name of the function being tested.

Follow-up to [53846].

See #42438.
Built from https://develop.svn.wordpress.org/trunk@53849


git-svn-id: http://core.svn.wordpress.org/trunk@53408 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-06 00:04:10 +00:00
Adam Silverstein
66372143a1 Media: use original image size data for full size secondary mime generation.
Correct an issue where the secondary mime type full size image would not be properly resized (and `-scaled` added to the name) when the original upload is over the `big_image_size_threshold` dimensions.

Props mukesh27.
See #55443.



Built from https://develop.svn.wordpress.org/trunk@53848


git-svn-id: http://core.svn.wordpress.org/trunk@53407 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 22:16:13 +00:00
Adam Silverstein
4b0450af4f Media: correct a misnamed variable when creating sub sizes with multi_resize.
Props mehulkaklotar, mukesh27.
See #55443.


Built from https://develop.svn.wordpress.org/trunk@53847


git-svn-id: http://core.svn.wordpress.org/trunk@53406 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 18:58:12 +00:00
Adam Silverstein
2c7cae5cd9 Script loader: enable resource preloading with rel='preload'.
Add a `wp_preload_resources` filter that developers can use to add resource preloading.

Preloading helps the browser discover and prioritize important resources earlier during the page load. This ensures that they are available earlier and are less likely to block the page's render.

Props nico23, swissspidy, igrigorik, westonruter, azaozz, furi3r, aristath, spacedmonkey, peterwilsoncc, mihai2u, gziolo. 
Fixes #42438.


Built from https://develop.svn.wordpress.org/trunk@53846


git-svn-id: http://core.svn.wordpress.org/trunk@53405 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 18:26:08 +00:00
Adam Silverstein
c1862616c2 Media: remove unused _wp_image_belongs_to_attachment function.
Remove the `_wp_image_belongs_to_attachment` function which was left over from a an unused branch and added inadvertently as part of r53751.

Props mukesh27.
Fixes #56333.


Built from https://develop.svn.wordpress.org/trunk@53845


git-svn-id: http://core.svn.wordpress.org/trunk@53404 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 16:12:13 +00:00
audrasjb
efbd56d13b Plugins: Properly encode query string s parameter in plugin search.
This ensures special characters like `&` are properly encoded when passed as URL parameter.

Props praful2111, audrasjb, costdev.
Fixes #56339.

Built from https://develop.svn.wordpress.org/trunk@53844


git-svn-id: http://core.svn.wordpress.org/trunk@53403 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 14:12:11 +00:00
audrasjb
6996204bab Docs: Various docblock fixes in wp-admin/includes/image.php class, as per docs standards.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53843


git-svn-id: http://core.svn.wordpress.org/trunk@53402 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 14:07:09 +00:00
Sergey Biryukov
5e6acb229d Revisions: Use wp_get_latest_revision_id_and_total_count() where appropriate.
The function executes an optimized query to get the last revision ID and total count. It was originally introduced for `WP_REST_Posts_Controller::prepare_links()`, and is now used in a few more places in core:

* `register_and_do_post_meta_boxes()`
* `wp_get_post_revisions_url()`
* `wp_update_custom_css_post()`

Follow-up to [53759], [53769], [53778], [53779], [53841].

Props peterwilsoncc, mukesh27, SergeyBiryukov.
Fixes #56279.
Built from https://develop.svn.wordpress.org/trunk@53842


git-svn-id: http://core.svn.wordpress.org/trunk@53401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 13:39:11 +00:00
Sergey Biryukov
b6198f330f Revisions: Use latest_id as the array key for the latest revision ID.
This updates `wp_get_latest_revision_id_and_total_count()` and its usage to be a bit more descriptive and a bit less repetitive, e.g. `$revisions['latest_id']` instead of `$revision['revision']`.

Includes updating the `@return` tag to explain when the function returns a `WP_Error`.

Follow-up to [53759], [53769], [53778], [53779].

See #55857.
Built from https://develop.svn.wordpress.org/trunk@53841


git-svn-id: http://core.svn.wordpress.org/trunk@53400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 13:02:13 +00:00
audrasjb
233089c138 Coding standards: Properly escape URLs returned by self_admin_url() calls.
This address some other echoed instances missed by [53839].

Fixes #56329.

Built from https://develop.svn.wordpress.org/trunk@53840


git-svn-id: http://core.svn.wordpress.org/trunk@53399 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 06:12:10 +00:00
audrasjb
b79e2df684 Coding standards: Properly escape URLs returned by self_admin_url() calls.
Props krishaweb, audrasjb, SergeyBiryukov.
Fixes #56329.

Built from https://develop.svn.wordpress.org/trunk@53839


git-svn-id: http://core.svn.wordpress.org/trunk@53398 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 06:00:09 +00:00
Peter Wilson
6219eb95bf Sitemaps: Prevent invalid provider names throwing errors.
Validate the requested sitemap is a string before attempting to use it in a provider. This prevents `WP_Sitemaps_Registry::get_provider()` from triggering a fatal error in more recent versions of PHP.

The errors can be triggered by items outside the site owner or developers control (such as a user visiting `?sitemap[foo]=bar`) so the code fails silently to avoid filling error logs with unfixable errors.

Props costdev, dd32.
Fixes #56336.

Built from https://develop.svn.wordpress.org/trunk@53838


git-svn-id: http://core.svn.wordpress.org/trunk@53397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 05:49:11 +00:00
audrasjb
301ac6bf38 Docs: Provide a more accurate @return type for get_pages() function.
Props malthert, audrasjb, johnbillion, jigar-bhanushali.
Fixes #56330.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53837


git-svn-id: http://core.svn.wordpress.org/trunk@53396 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 05:46:10 +00:00
Sergey Biryukov
a0944f075a Tests: Combine test classes for get_edit_term_link() tests.
There were two sets of tests for the function:
* One in the `link` directory, based on the `link-template.php` file name.
* One in the `term` directory, based on the component name.

To avoid confusion and make it easier to decide where new tests should go in the future, the existing tests are now combined in the former location.

Includes:
* Setting the current user in `::set_up()` instead of each individual test method.
* Changing the custom taxonomy name to `wptests_tax` for consistency with other tests.
* Moving `::register_custom_taxonomy()` and `::get_term()` helpers to the beginning of the class.

Follow-up to [32954], [36646], [52180], [52255], [53833].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53836


git-svn-id: http://core.svn.wordpress.org/trunk@53395 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 18:30:09 +00:00
Sergey Biryukov
b0c086417e Tests: Use named data provider for WP_Object_Cache::is_valid_key() test.
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.

Follow-up to [53818], [53821], [53822], [53834].

See #56198.
Built from https://develop.svn.wordpress.org/trunk@53835


git-svn-id: http://core.svn.wordpress.org/trunk@53394 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 17:49:10 +00:00
Sergey Biryukov
962607928e Tests: Add more test cases for WP_Object_Cache::is_valid_key().
A valid cache key for `wp_cache_*()` functions must be either an integer number or a non-empty string. To avoid potential compatibility issues or key collisions, a string that becomes empty after `trim()` should not be considered a valid cache key.

Follow-up to [53818], [53821], [53822].

Props tillkruess.
See #56198.
Built from https://develop.svn.wordpress.org/trunk@53834


git-svn-id: http://core.svn.wordpress.org/trunk@53393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 17:33:08 +00:00
Sergey Biryukov
e2024bd466 Tests: Correct data providers for get_term_link() and get_edit_term_link() tests.
* The tests use named data providers which include a flag for passing either a term ID or term object to the test, but the values for the flag were the opposite of what the array key says.
* Some array keys were duplicated, which means the earlier test case with the same name did not actually run.

Follow-up to [52180], [52255], [52258], [52305].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53833


git-svn-id: http://core.svn.wordpress.org/trunk@53392 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 17:20:08 +00:00
Sergey Biryukov
215a5fd1b7 Coding Standards: Reorder global cache groups alphabetically for some consistency.
Follow-up to [53823], [53824].

See #55647.
Built from https://develop.svn.wordpress.org/trunk@53832


git-svn-id: http://core.svn.wordpress.org/trunk@53391 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 16:29:10 +00:00
Sergey Biryukov
e88c783a0d Docs: Remove obsolete comment in object cache tests.
The comment mentioned creating two cache objects with a shared cache directory, which was no longer the case.

Follow-up to [5/tests] [170/tests].

See #55646, #55652.
Built from https://develop.svn.wordpress.org/trunk@53831


git-svn-id: http://core.svn.wordpress.org/trunk@53390 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 15:51:11 +00:00
Sergey Biryukov
5bb069bda8 Tests: Move wp_cache_replace() test to a more appropriate place.
This matches the location of other `wp_cache_*()` tests following the respective `WP_Object_Cache` method tests.

Follow-up to [1275/tests].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53830


git-svn-id: http://core.svn.wordpress.org/trunk@53389 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 15:44:10 +00:00
Sergey Biryukov
707cf6aaa6 Tests: Remove the list of non-persistent groups in Memcached implementation used in the test suite.
This list was not up to date, and does not appear to be required, as `WP_UnitTestCase_Base::flush_cache()` adds the correct list of groups, which is up to date.

Follow-up to [1332/tests], [8068], [37613], [40561], [52976], [53826], [53828].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53829


git-svn-id: http://core.svn.wordpress.org/trunk@53388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 15:39:10 +00:00
Sergey Biryukov
b7cabd9c88 Tests: Make the comment cache group persistent in WP_UnitTestCase_Base::flush_cache().
This brings the list of persistent groups when running the test suite in line with core.

Follow-up to [1332/tests], [37613], [52976].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53828


git-svn-id: http://core.svn.wordpress.org/trunk@53387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 15:18:09 +00:00
John Blackbourn
79db573265 Docs: Various corrections and improvements to inline documentation.
See #55646

Built from https://develop.svn.wordpress.org/trunk@53827


git-svn-id: http://core.svn.wordpress.org/trunk@53386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 14:52:11 +00:00
Sergey Biryukov
9c75453606 Tests: Remove the list of global groups in Memcached implementation used in the test suite.
This list was not up to date, and does not appear to be required, as `WP_UnitTestCase_Base::flush_cache()` adds the correct list of groups, which is up to date.

Follow-up to [1332/tests], [40343], [40561], [53823], [53824].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53826


git-svn-id: http://core.svn.wordpress.org/trunk@53385 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 14:48:12 +00:00
desrosj
0d62f02303 Posts, Post Types: Change variable name in wp_set_post_terms() for clarity.
This changes the `$tags` variable used within `wp_set_post_terms()` to `$terms`.

While the default for the `$taxonomy` argument is `post_tag`, the function can be used to assign terms to a post for any taxonomy. When a different taxonomy is passed, `$tags` is an inaccurate name and could be confusing.

Props hilayt24, costdev, SergeyBiryukov, krishaweb, desrosj.
Fixes #56331.
Built from https://develop.svn.wordpress.org/trunk@53825


git-svn-id: http://core.svn.wordpress.org/trunk@53384 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 14:09:23 +00:00
Sergey Biryukov
68e50c583c Tests: Simplify the list of global groups in object cache tests.
This list was not up to date due to missing `blog_meta` group, and does not appear to be required for the tests to pass, as `WP_UnitTestCase_Base::flush_cache()` adds the same list of groups, which is up to date.

Follow-up to [946/tests], [1332/tests], [40343], [42836], [53823].

See #55647.
Built from https://develop.svn.wordpress.org/trunk@53824


git-svn-id: http://core.svn.wordpress.org/trunk@53383 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 14:04:34 +00:00
Sergey Biryukov
309ff9c4ba Coding Standards: Wrap long lines with global cache groups for better readability.
Follow-up to [946/tests], [1060/tests], [https://mu.trac.wordpress.org/changeset/1784 mu1784], [https://mu.trac.wordpress.org/changeset/2032 mu2032] [https://mu.trac.wordpress.org/changeset/2029 mu2029], [7986], [12128], [12603], [12688], [12732], [12755], [13125], [14009], [15482], [21403], [22092], [31347], [31348], [36258], [36393], [36413], [37918], [40343], [40347], [42836].

See #55647.
Built from https://develop.svn.wordpress.org/trunk@53823


git-svn-id: http://core.svn.wordpress.org/trunk@53382 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 13:33:12 +00:00
Sergey Biryukov
1a460d5155 Tests: Add a test case with a float value for WP_Object_Cache::is_valid_key().
A valid cache key for `wp_cache_*()` functions must be either an integer number or a non-empty string. To avoid potential compatibility issues or key collisions, float values should not be considered a valid cache key.

Follow-up to [53818], [53821].

Props tillkruess, malthert, spacedmonkey.
See #56198.
Built from https://develop.svn.wordpress.org/trunk@53822


git-svn-id: http://core.svn.wordpress.org/trunk@53381 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 12:37:21 +00:00
Sergey Biryukov
39821528b4 Tests: Add a unit test for WP_Object_Cache::is_valid_key().
A valid cache key for `wp_cache_*()` functions must be either an integer number or a non-empty string.

Follow-up to [53818].

See #56198.
Built from https://develop.svn.wordpress.org/trunk@53821


git-svn-id: http://core.svn.wordpress.org/trunk@53380 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 12:11:19 +00:00
audrasjb
39903f841e Twenty Eleven: Remove a useless CSS comment after [53819].
This comment does not apply anymore. Follow-up to [53819].

See #56297.

Built from https://develop.svn.wordpress.org/trunk@53820


git-svn-id: http://core.svn.wordpress.org/trunk@53379 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-03 17:17:10 +00:00
audrasjb
f05709ac51 Twenty Eleven: Use more specific CSS selectors for .required styles.
This changeset adds more specific CSS selectors so third-parties fields are not targeted by the related CSS rules.

Props umesh84, sabernhardt, costdev.
Fixes #56297.

Built from https://develop.svn.wordpress.org/trunk@53819


git-svn-id: http://core.svn.wordpress.org/trunk@53378 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-03 17:12:13 +00:00
Sergey Biryukov
df054f2dae Cache API: Validate cache key in WP_Object_Cache methods.
Some plugins may call the `wp_cache_*()` functions with an empty string, `false`, or `null` as cache key, usually as a result of not checking the return value of another function that's used as the key.

Previously, this was silently failing, leading to odd behavior at best and often breakage due to key collisions.

A valid cache key must be either an integer number or a non-empty string.

This commit introduces a quick type check on the given cache keys and adds a `_doing_it_wrong()` message that should help plugin developers to notice these issues quicker.

Includes:
* A check in `update_user_caches()` and `clean_user_cache()` to make sure user email is not empty before being cached or removed from cache, as it is technically possible to create a user with empty email via `wp_insert_user()`.
* Some minor cleanup in unit tests where the email was passed to `wp_insert_user()` incorrectly or was unintentionally reset.

Props tillkruess, malthert, dd32, spacedmonkey, flixos90, peterwilsoncc, SergeyBiryukov.
Fixes #56198.
Built from https://develop.svn.wordpress.org/trunk@53818


git-svn-id: http://core.svn.wordpress.org/trunk@53377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-03 14:36:12 +00:00
Sergey Biryukov
de97f21367 Coding Standards: Remove extra space in two conditionals.
This fixes WPCS errors in `WP_Site_Health::get_test_plugin_version()` and `::get_test_theme_version()`:

* `Expected exactly one space between closing parenthesis and opening control structure; " " found.`
* `Expected 1 space(s) after closing parenthesis; found 2`

Follow-up to [53816].

See #56134.
Built from https://develop.svn.wordpress.org/trunk@53817


git-svn-id: http://core.svn.wordpress.org/trunk@53376 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-03 14:32:12 +00:00
Sergey Biryukov
1f39318123 Site Health: Improve the wording in plugin and theme version tests.
This displays a more appropriate message in case the site does not have any active plugins or installed themes.

Follow-up to [44986], [45099], [45336].

Props Presskopp, costdev, martin.krcho, Clorith, SergeyBiryukov.
Fixes #56134.
Built from https://develop.svn.wordpress.org/trunk@53816


git-svn-id: http://core.svn.wordpress.org/trunk@53375 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-03 13:09:09 +00:00
audrasjb
66d425d86a Administration: Change default site tagline to an empty string.
This changeset replaces the default "Just another WordPress site" tagline with an empty string for new installations. The reasoning is:

1. Not all themes display the tagline;
2. Not everyone changes the default tagline;
3. When people don't see the tagline in their theme, they may not realize it is still visible in some places, like feeds.

The string "Just another WordPress site" and the related multisite string: "Just another {NETWORK} site" are now only used as a placeholder for the tagline admin option.

Props markjaquith, Denis-de-Bernardy, westi, RyanMurphy, kovshenin, SergeyBiryukov, chriscct7, tyxla, hyperbrand, karmatosed, lukecavanagh, melchoyce, boemedia, khag7, sabernhardt, audrasjb, peterwilsoncc, costdev, martinkrcho, rafiahmedd.
Fixes #6479.

Built from https://develop.svn.wordpress.org/trunk@53815


git-svn-id: http://core.svn.wordpress.org/trunk@53374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-03 12:20:16 +00:00
audrasjb
ef0c9211ca Docs: Use third-person singular verbs for function descriptions in WP_REST_Posts_Controller, as per docblocks standards.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53814


git-svn-id: http://core.svn.wordpress.org/trunk@53373 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-03 10:07:13 +00:00
audrasjb
2692f4a0be Posts, Post Types: Force unique slugs for draft posts.
This fixes a behavior where a draft created with the same slug as an existing post would set the existing post to a 404.

`wp_unique_post_slug()` returns the same slug for 'draft' or 'pending' posts, so to ensure that a unique slug is generated, this changeset adds the post data with the 'publish' status to `wp_unique_post_slug()`.

Props Toro_Unit, h2ham, peterwilsoncc, costdev, antonvlasenko, azaozz, ironprogrammer, audrasjb, hellofromTonya.
Fixes #52422.

Built from https://develop.svn.wordpress.org/trunk@53813


git-svn-id: http://core.svn.wordpress.org/trunk@53372 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-03 09:03:14 +00:00
Sergey Biryukov
d7d371b840 Database: Suppress errors when checking the validity of table prefix during installation.
There are some table prefixes (for example, `7e1_`), which the database will try and parse as values unless they are quoted in backticks. Because not everyone remembers to quote their table names, WordPress discourages use of such prefixes during setup.

To test if the table prefix is valid, WordPress executes a query deliberately trying to generate an error:
> `Unknown column 'wp_' in 'field list'`
which means the prefix is safe to use, as the database was not able to parse it as a value.

Previously, this error would not be displayed to the user in a typical configuration, but would be logged on the server via `wpdb::print_error()`, and in some cases could block the installation.

This commit makes sure the error is still checked to display a proper message in case the prefix needs to be edited, but otherwise is silently discarded instead of being logged.

Follow-up to [37581], [41631], [51582].

Props pento, lazam786, Velochicdunord, irecinius, mikemanzo, dd32, blackawxs, codewhy, psykro, burgiuk, mdrago, maythamalsudany, peterwilsoncc, sumitsingh, deksar, SergeyBiryukov.
Fixes #42362.
Built from https://develop.svn.wordpress.org/trunk@53812


git-svn-id: http://core.svn.wordpress.org/trunk@53371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-02 16:34:13 +00:00
audrasjb
46c1425601 Docs: Improve the description of param $list in wp_list_sort() docblock.
Props audrasjb, rherault.
Fixes #56324.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53811


git-svn-id: http://core.svn.wordpress.org/trunk@53370 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-02 14:50:12 +00:00
Peter Wilson
0008d2a443 Date/Time: Increase test coverage of wp_date().
Props costdev, pbearne, rarst.
Fixes #53485.
See #55652.


Built from https://develop.svn.wordpress.org/trunk@53810


git-svn-id: http://core.svn.wordpress.org/trunk@53369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-01 22:50:15 +00:00
Sergey Biryukov
a3a299ce1e Docs: Improve description for doing_filter() and doing_action().
This corrects a note about `did_action()` return type, and brings more consistency between the two DocBlocks.

Follow-up to [27294], [53803].

See #55646.
Built from https://develop.svn.wordpress.org/trunk@53809


git-svn-id: http://core.svn.wordpress.org/trunk@53368 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-01 11:15:14 +00:00
Sergey Biryukov
7c316c4f1a Tests: Move the test for action callback representations to the general action tests file.
A separate file in the `actions` directory may have seemed like a good location at the time, but this is the only test left there. For consistency, it is now moved with the other action tests.

Follow-up to [1294/tests], [53806].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53808


git-svn-id: http://core.svn.wordpress.org/trunk@53367 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-31 21:37:13 +00:00
Sergey Biryukov
6feee39137 Tests: Update a transients test to account for terminology changes in MockAction.
Follow-up to [33110], [53805].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53807


git-svn-id: http://core.svn.wordpress.org/trunk@53366 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-31 16:51:07 +00:00
Sergey Biryukov
97565d4a0d Tests: Move the test for actions using closures to the general action tests file.
This was previously moved to a separate file to be excluded when running the tests on PHP 5.2.x.

Now that WordPress supports PHP 5.6.x or later, this can be moved back with the other action tests.

Follow-up to [299/tests], [301/tests], [862/tests], [866/tests], [963/tests].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53806


git-svn-id: http://core.svn.wordpress.org/trunk@53365 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-31 16:43:09 +00:00
Sergey Biryukov
f2138f29a8 Tests: Update the terminology used for action or filter names in MockAction class.
This replaces the "tag" wording with "hook name" where appropriate, to match the core function signatures.

Includes:
* Introducing a `::get_hook_names()` method instead of `::get_tags()`, keeping the latter as an alias.
* Adding a `hook_name` key to the `::$events` property, keeping `tag` for backward compatibility for now.
* Adding missing `@since` tags for class methods.

Follow-up to [24/tests], [62/tests], [70/tests], [50807], [53804].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53805


git-svn-id: http://core.svn.wordpress.org/trunk@53364 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-31 16:27:09 +00:00
Sergey Biryukov
6e4bc189f5 Tests: Update the terminology used for action or filter names in hook tests.
This replaces the `$tag` variables with `$hook_name`, to match the core function signatures.

Follow-up to [24/tests], [62/tests], [866/tests], [1294/tests], [38571], [50807].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53804


git-svn-id: http://core.svn.wordpress.org/trunk@53363 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-31 15:05:10 +00:00
Sergey Biryukov
bf067ce93a Plugins: Introduce did_filter() function.
While most of the action functions are aliases for the respective filter functions, using `did_action()` to detect whether a filter has been run is not possible, as it only works specifically for actions.

This is now resolved by introducing a new function, `did_filter()`, which retrieves the number of times a filter has been applied during the current request, bringing parity with `did_action()`.

Follow-up to [4630], [6318], [27294].

Props mordauk, chriscct7, andykeith, nacin, dd32, markparnell, SergeyBiryukov.
Fixes #35357.
Built from https://develop.svn.wordpress.org/trunk@53803


git-svn-id: http://core.svn.wordpress.org/trunk@53362 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-31 14:20:12 +00:00
Sergey Biryukov
5a9b1a44a1 Tests: Correct alignment in has_filter() unit test.
Follow-up to [100/tests].

See #55652, #55647.
Built from https://develop.svn.wordpress.org/trunk@53802


git-svn-id: http://core.svn.wordpress.org/trunk@53361 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-31 13:10:14 +00:00
Sergey Biryukov
f53c815b6e Coding Standards: Use more meaningful variables names in some Ajax functions.
This renames `$tax` to `$taxonomy_object` and `$s` to `$search` for clarity. The latter is only renamed when used as an internal variable and not referring to the `$s` global.

The list of affected functions:
* `wp_ajax_ajax_tag_search()`
* `wp_ajax_add_link_category`
* `wp_ajax_add_tag()`
* `wp_ajax_get_tagcloud()`
* `wp_ajax_inline_save_tax()`
* `wp_ajax_find_posts()`

Follow-up to [6542], [8901], [10222], [12833], [16771], [16992], [22723], [38698].

Props azouamauriac.
Fixes #55098.
Built from https://develop.svn.wordpress.org/trunk@53801


git-svn-id: http://core.svn.wordpress.org/trunk@53360 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-30 15:16:08 +00:00
Sergey Biryukov
75ff07ccbf Docs: Use more inclusive language in PHPCS configuration files.
Follow-up to [42346], [43348], [45455], [46290], [46820], [48121], [48477].

See #55646, #55647.
Built from https://develop.svn.wordpress.org/trunk@53800


git-svn-id: http://core.svn.wordpress.org/trunk@53359 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-30 14:11:08 +00:00
audrasjb
35ab933067 Docs: Fix $feature parameter type in block_has_support().
In `block_has_support()` docblock, the `$feature` parameter is an array, not a string.

Props Soean, audrasjb.
Fixes #56307.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53799


git-svn-id: http://core.svn.wordpress.org/trunk@53358 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-30 14:09:10 +00:00
audrasjb
9ddff60ecd Docs: Various docblock fixes in WP_Date_Query class, as per docs standards.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53798


git-svn-id: http://core.svn.wordpress.org/trunk@53357 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-30 14:01:13 +00:00
audrasjb
1cfcf1791e Twenty Twenty: Ensure comments section links are identifiable as links.
Links should look like links. This changeset makes sure that links displayed in the comments section of Twenty Twenty are identifiable as links.

Props audrasjb, whaze, sabernhardt, mukesh27.
Fixes #56269.

Built from https://develop.svn.wordpress.org/trunk@53797


git-svn-id: http://core.svn.wordpress.org/trunk@53356 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-29 20:26:12 +00:00
audrasjb
37c514cc62 Comments: Improve accessibility of the "Logged in as" link in comment form.
This changeset ensures the "Logged in as" link conveys the information about its purpose ("Edit your profile") while the information "Logged in as Jane Doe" is only a simple text.

Props juliemoynat, SergeyBiryukov, joedolson, audrasjb, lopo.
Fixes #55718.

Built from https://develop.svn.wordpress.org/trunk@53796


git-svn-id: http://core.svn.wordpress.org/trunk@53355 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-29 17:06:15 +00:00
Sergey Biryukov
221b68fe4b Tests: Simplify some function calls in Tests_Media.
The remaining assertions using `preg_match_all()` do actually pass a regex, but the third parameter `$matches` is never used.

This third parameter became optional in PHP 5.4, so we may as well remove it.

Reference: [https://www.php.net/manual/en/function.preg-match-all.php PHP Manual: preg_match_all()]

Follow-up to [711/tests], [53558], [53790].

Props jrf.
See #55652.
Built from https://develop.svn.wordpress.org/trunk@53795


git-svn-id: http://core.svn.wordpress.org/trunk@53354 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-29 14:35:13 +00:00
audrasjb
9a517ac7ae Docs: Various docblock improvements in Importer Administration API, as per docs standards.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53794


git-svn-id: http://core.svn.wordpress.org/trunk@53353 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-29 09:22:10 +00:00
audrasjb
698e0466a0 Themes: Allow remote pattern registration in theme.json when core patterns are disabled.
In 6.0 there is now a functionality that allows to register selected remote patterns (from the Pattern Directory) via `theme.json`. However, it requires to fully enable all core and remote patterns. This can be a blocker for user adoption.

Many theme authors want to have all core and remote patterns disabled by default using `remove_theme_support( 'core-block-patterns' )`. This changeset ensures they are serving only patterns relevant to their theme.

This changeset removes theme support check from the function that registers remote patterns specified in `theme.json`. This allows theme authors to disable core patterns but then selectively register the ones they want from the Pattern Directory. If a theme author intentionally specifies patterns in `theme.json`, they probably intend for them to be present in the pattern inserter and the check is not required.

This change will make the Pattern Directory more appealing/usable from the theme author's perspective.

Props ndiego, ryelle.
Fixes #56112.

Built from https://develop.svn.wordpress.org/trunk@53793


git-svn-id: http://core.svn.wordpress.org/trunk@53352 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-29 08:31:10 +00:00
audrasjb
d853d1ece2 Docs: Various docblock improvements in Export Administration API, as per docs standards.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53792


git-svn-id: http://core.svn.wordpress.org/trunk@53351 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-29 08:14:12 +00:00
Peter Wilson
839d20f9c5 Cron API: Modify _get_cron_array() to always return an array.
Change the return type of `_get_cron_array()` to an empty array if the `cron` option is either missing or of an 
unexpected type.

This change ensures the return value for no registered events is consistently an empty array. Previously the return 
value could be either an empty array or `false`.

Props thakkarhardik, jrf, costdev.
Fixes #53940.

Built from https://develop.svn.wordpress.org/trunk@53791


git-svn-id: http://core.svn.wordpress.org/trunk@53350 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-29 03:34:13 +00:00
Sergey Biryukov
9646cd2a77 Tests: Simplify some assertions in Tests_Media.
A number of assertions are checking for the number of times a hard-coded substring existed in a larger `$haystack`.

These assertions were using `preg_match_all()` to do so, but without actually using a regex.

In these cases, it is more performant (and simpler) to use the PHP native `substr_count()` function, which will yield the same result, without the overhead of regex parsing.

Reference: [https://www.php.net/manual/en/function.substr-count.php PHP Manual: substr_count()]

Follow-up to [711/tests], [38838], [42694], [53558].

Props jrf.
See #55652.
Built from https://develop.svn.wordpress.org/trunk@53790


git-svn-id: http://core.svn.wordpress.org/trunk@53349 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-28 22:38:13 +00:00
Sergey Biryukov
ac02adfaec Tests: Use named data providers in some wp_insert_post() tests.
Follow-up to [42380], [49125], [53521], [53785], [53787], [53788].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53789


git-svn-id: http://core.svn.wordpress.org/trunk@53348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-27 16:29:07 +00:00
Sergey Biryukov
8e51578146 Tests: Don't unnecessarily randomize the post type in some wp_insert_post() tests.
Follow-up to [33041], [52389], [53785], [53787].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53788


git-svn-id: http://core.svn.wordpress.org/trunk@53347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-27 16:09:12 +00:00
Sergey Biryukov
2786e0f54d Tests: Don't unnecessarily set the author in some wp_insert_post() tests.
This aims to make the tests more specific. Setting the author appears to be redundant, as the as the authorship is out of scope for these particular tests.

Follow-up to [66/tests], [84/tests], [167/tests], [296/tests], [412/tests], [496/tests], [1026/tests], [1323/tests], [25554], [33041], [34762], [35183].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53787


git-svn-id: http://core.svn.wordpress.org/trunk@53346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-27 15:43:11 +00:00
Felix Arntz
b39a441f3a Media: Add information about additional MIME type sources to attachments REST endpoints.
This changeset is a follow-up to [53751] which ensures the additional `sources` information stored in attachment metadata are available under `media_details` for each image size in the REST API responses for attachments.

Props mukesh27, eugenemanuilov, mitogh, flixos90, aaemnnosttv.
See #55443.

Built from https://develop.svn.wordpress.org/trunk@53786


git-svn-id: http://core.svn.wordpress.org/trunk@53345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-27 15:15:15 +00:00
Sergey Biryukov
c6235a37c7 Tests: Move wp_insert_post() tests to their own file.
Now that there is a separate test class for `wp_insert_post()` tests, some of the pre-existing tests from the general `Tests_Post` class can be moved there.

Includes:
* Removal of unnecessarily setting the current user to Editor for all tests.
* Removal of unnecessarily setting the cron option to an empty array for all tests.

Follow-up to [496/tests], [36607], [53782], [53783].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53785


git-svn-id: http://core.svn.wordpress.org/trunk@53344 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-27 15:01:14 +00:00
gziolo
db37be017f Site Editor: Pass correct context into get_block_categories
Site Editor passed incorrectly global $post as a context when setting up block categories. Instead, it should pass $block_editor_context, since global $post is null in this file.

Props Mamaduka.
Fixes #56284.


Built from https://develop.svn.wordpress.org/trunk@53784


git-svn-id: http://core.svn.wordpress.org/trunk@53343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-27 12:27:16 +00:00
Sergey Biryukov
7af37ed1ad Tests: Move wp_publish_post() tests to their own file.
Now that there is a separate test class for `wp_publish_post()` tests, some of the pre-existing tests from the general `Tests_Post` class can be moved there.

Follow-up to [1039/tests], [1174/tests], [46969], [49000].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53783


git-svn-id: http://core.svn.wordpress.org/trunk@53342 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-26 14:30:14 +00:00
Sergey Biryukov
3df4fd7679 Tests: Bring some modernization to wp_insert_post() tests.
Includes:
* Using `assertIsInt()` instead of `assertIsNumeric()` for post IDs.
* Using consistent variable names for post data and retrieved posts.
* Removing added filters before performing assertions, not after.
* Removing unused `Tests_Post::$post_ids` property.
* Correcting the order of arguments in some assertions.
* Converting some `foreach()` loops to data providers.
* Wrapping long lines for better readability.

Follow-up to [13/tests], [14/tests], [167/tests], [496/tests], [1174/tests], [1246/tests], [1287/tests], [1307/tests], [1326/tests], [30510], [33261], [33630], [34762], [46279], [50012], [51438].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53782


git-svn-id: http://core.svn.wordpress.org/trunk@53341 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-26 13:55:14 +00:00
audrasjb
49ace608dc Taxonomy: Allow filtering Ajax term search results in quick edit.
This changeset introduces the `ajax_term_search_results` hook which can be used to filter the term search results returned by the AJAX term query.

Props grandeljay, costdev, ironprogrammer, audrasjb, SergeyBiryukov.
Fixes #55606.

Built from https://develop.svn.wordpress.org/trunk@53781


git-svn-id: http://core.svn.wordpress.org/trunk@53340 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-26 13:23:14 +00:00
audrasjb
82edcc17f5 Docs: Improve parameter descriptions in render_block and render_block_* filters.
The former `$block_content` parameter descriptions were too opinionated as block content can be appended, prepended, nested, removed, etc.

Props milana_cap.
Fixes #56286.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53780


git-svn-id: http://core.svn.wordpress.org/trunk@53339 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-26 13:00:16 +00:00
Sergey Biryukov
87464289c3 Revisions: Update the "last revision" wording to "latest revision" in various files.
This aims to reduce ambiguity about what exactly is the "first" or "last" revision, and bring more consistency with similar wording elsewhere in core, e.g. latest posts, latest comments, etc.

This affects:
* `wp_save_post_revision()`
* `wp_prepare_revisions_for_js()`
* `WP_Customize_Manager::filter_revision_post_has_changed()`

Follow-up to [53759], [53769], [53778].

Props peterwilsoncc.
Fixes #55857.
Built from https://develop.svn.wordpress.org/trunk@53779


git-svn-id: http://core.svn.wordpress.org/trunk@53338 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-25 19:30:09 +00:00
Sergey Biryukov
adb5ff451c Revisions: Rename the function for retrieving the latest revision ID and total count.
The new name is `wp_get_latest_revision_id_and_total_count()`.

This aims to reduce ambiguity about what exactly is the "first" or "last" revision, and bring more consistency with similar wording elsewhere in core, e.g. latest posts, latest comments, etc.

Follow-up to [53759], [53769].

Props peterwilsoncc.
See #55857.
Built from https://develop.svn.wordpress.org/trunk@53778


git-svn-id: http://core.svn.wordpress.org/trunk@53337 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-25 19:20:07 +00:00
audrasjb
a85bde79df Media: Prevent URLs from overflowing their container in the media editor.
This changeset also introduces the `.word-wrap-break-word` class which can be used to apply `word-wrap: break-word` to admin elements when needed.

Props mitogh, costdev, kapilpaul, alamgircsebd, sabernhardt, anantajitjg, afercia, circlecube, SergeyBiryukov, rafiahmedd, audrasjb.
Fixes #55393.

Built from https://develop.svn.wordpress.org/trunk@53777


git-svn-id: http://core.svn.wordpress.org/trunk@53336 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-25 18:11:08 +00:00
audrasjb
b6fad3a241 Docs: Remove an obsolete function description in addslashes_gpc().
- Usage of `get_magic_quotes_gpc()` was removed from `addslashes_gpc()` in [46105] / #47783.
- A similar description fragment was removed from `wp_parse_str()` in that changeset, but this one was missed.
- The `get_magic_quotes_gpc()` function itself was deprecated in PHP 7.4 and removed in PHP 8.0.

Props mitweka, audrasjb, SergeyBiryukov.
Fixes #56233.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53776


git-svn-id: http://core.svn.wordpress.org/trunk@53335 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-25 17:28:09 +00:00
audrasjb
83da7ca360 Docs: Refine @return docblock mentions for esc_sql(), wp_slash() and wp_unslash().
Props malthert, SergeyBiryukov, johnbillion, desrosj, byohann6.
Fixes #53946.
See #55646.

Built from https://develop.svn.wordpress.org/trunk@53775


git-svn-id: http://core.svn.wordpress.org/trunk@53334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-25 15:43:09 +00:00
Sergey Biryukov
46cf3ecda4 Tests: Declare custom-logo theme support for custom logo tests.
This addresses failures in `has_custom_logo()` and `get_custom_logo()` tests when being run separately:
{{{
1) Tests_General_Template::test_has_custom_logo
Custom logo should not be set after removal.
Failed asserting that true is false.
tests/phpunit/tests/general/template.php:291

2) Tests_General_Template::test_get_custom_logo
Custom logo should not be set after removal.
Failed asserting that a string is empty.
tests/phpunit/tests/general/template.php:336
}}}

Specifically, this ensures that the `site_logo` option gets deleted in `_delete_site_logo_on_remove_theme_mods()`, which in turn prevents the `core/site-logo` block filters from affecting the custom logo tests.

Alternatively, these filters could be removed instead:
{{{
remove_filter( 'theme_mod_custom_logo', '_override_custom_logo_theme_mod' );
remove_filter( 'pre_set_theme_mod_custom_logo', '_sync_custom_logo_to_site_logo' );
}}}

Follow-up to [36905], [51091], [51421], [52042].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53774


git-svn-id: http://core.svn.wordpress.org/trunk@53333 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-25 13:48:10 +00:00
Sergey Biryukov
a39042b237 Tests: Add failure messages for site icon and custom logo tests.
This makes the assertions more helpful, as per the [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#using-assertions Writing PHP Tests] guidelines:
> All PHPUnit assertions, as well as all WordPress custom assertions, allow for a `$message` parameter to be passed. This message will be displayed when the assertion fails and can help immensely when debugging a test. This parameter should always be used if more than one assertion is used in a test method.

Follow-up to [33181], [36905].

See #55652.
Built from https://develop.svn.wordpress.org/trunk@53773


git-svn-id: http://core.svn.wordpress.org/trunk@53332 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-25 13:33:12 +00:00
Peter Wilson
276d3b34ca REST API: Prime post caches in comments endpoint.
Prevent each call to `get_post()` triggering a seperate database query by priming the cache of each comment's post in 
the REST API's comments endpoint.

Props spacedmonkey, timothyblynjacobs.
Fixes #56272.


Built from https://develop.svn.wordpress.org/trunk@53772


git-svn-id: http://core.svn.wordpress.org/trunk@53331 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-25 02:53:13 +00:00
Sergey Biryukov
ae807463ac Posts, Post Types: Check if the post type exists in wp_insert_post().
This avoids an `Attempt to read property "cap" on null` PHP warning when checking an unregistered post type's `publish_posts` capability to disallow contributors setting the post slug for pending posts.

Follow-up to [9055], [42380].

Props Chouby, mukesh27, rafiahmedd, SergeyBiryukov.
Fixes #55877.
Built from https://develop.svn.wordpress.org/trunk@53771


git-svn-id: http://core.svn.wordpress.org/trunk@53330 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-24 13:26:12 +00:00
Sergey Biryukov
a7d02201ea Docs: List the expected type first in a few functions:
* `is_allowed_http_origin()`
* `doing_filter()`
* `wp_get_post_revisions_url()`

Follow-up to [28010], [28889], [30674], [46696], [47060], [48068], [49929], [49963], [52095], [51286], [52111].

See #55646.
Built from https://develop.svn.wordpress.org/trunk@53770


git-svn-id: http://core.svn.wordpress.org/trunk@53329 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-23 16:57:09 +00:00
Sergey Biryukov
e5fca86316 Revisions: Correct the function name for retrieving the last revision ID and total count.
Includes:
* Renaming the function to `wp_get_last_revision_id_and_total_count()`.
* Making the default value for `$post` consistent with `wp_get_post_revisions()`.
* Making `WP_Error` codes more specific and using them in test assertions.
* Adjusting the function description per the documentation standards.

Follow-up to [53759].

Props JustinSainton, SergeyBiryukov.
See #55857.
Built from https://develop.svn.wordpress.org/trunk@53769


git-svn-id: http://core.svn.wordpress.org/trunk@53328 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-23 15:42:16 +00:00