Commit Graph

20585 Commits

Author SHA1 Message Date
Sergey Biryukov
e9acf1fc0a Code Modernization: Explicitly declare all properties in POMO_Reader et al.
Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

There are a number of ways to mitigate this:
* If it is an accidental typo for a declared property: fix the typo.
* For known properties: declare them on the class.
* For unknown properties: add the magic `__get()`, `__set()`, et al. methods to the class or let the class extend `stdClass` which has highly optimized versions of these magic methods built in.
* For unknown ''use'' of dynamic properties, the `#[AllowDynamicProperties]` attribute can be added to the class. The attribute will automatically be inherited by child classes.

In this case, the `$is_overloaded` property and the `$_f` property fall in the “known property” category. In both cases, these are being set in the `__construct()` method of the class they apply to.

The `$_post` property appears to be a typo however. The `$_post` property looks to be unused, while there is an undeclared integer `$_pos` (“position”) property, which is used throughout the class and used by the child classes.

Reference: [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties].

Follow-up to [11626], [12174], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936], [53937], [53938], [53942], [53945], [53948], [53949], [53952], [53953].

Props jrf, antonvlasenko, costdev.
See #56033.

git-svn-id: https://develop.svn.wordpress.org/trunk@53954 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-29 14:05:14 +00:00
Sergey Biryukov
48e9706f04 Code Modernization: Explicitly declare WP-specific property in WP_SimplePie_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.

There are a number of ways to mitigate this:
* If it is an accidental typo for a declared property: fix the typo.
* For known properties: declare them on the class.
* For unknown properties: add the magic `__get()`, `__set()`, et al. methods to the class or let the class extend `stdClass` which has highly optimized versions of these magic methods built in.
* For unknown use of dynamic properties, the `#[AllowDynamicProperties]` attribute can be added to the class. The attribute will automatically be inherited by child classes.

In this case, the `$timeout` property falls in the “known property” category.

Note: In contrast to the other properties being set in the constructor, this property is not declared on the parent class, so not inherited.

Reference: [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties].

Follow-up to [10687], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936], [53937], [53938], [53942], [53945], [53948], [53949], [53952].

Props jrf, antonvlasenko, costdev.
See #56033.

git-svn-id: https://develop.svn.wordpress.org/trunk@53953 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-29 13:17:28 +00:00
Sergey Biryukov
ec9e8ca25d Code Modernization: Explicitly declare all properties in WP_Ajax_Upgrader_Skin.
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, the `$plugin_info` and `$theme_info` properties are set in `Plugin_Upgrader::bulk_upgrade()` and `Theme_Upgrader::bulk_upgrade()` specifically.

The `Bulk_Plugin_Upgrader_Skin` class and the `Bulk_Theme_Upgrader_Skin` class both already allow for this, but the `wp_ajax_update_plugin()` and `wp_ajax_update_theme()` functions also call the `*_Upgrader::bulk_upgrade()` methods, so the `WP_Ajax_Upgrader_Skin` class also needs to have these properties explicitly declared.

Includes adding proper DocBlocks for the pre-existing properties in the `Bulk_Plugin_Upgrader_Skin` and the `Bulk_Theme_Upgrader_Skin` classes.

Follow-up to [13686], [37714], [38199], [42677], [42873], [53557], [53558], [53850], [53851], [53852], [53853], [53854], [53856], [53916], [53935], [53936], [53937], [53938], [53942], [53945], [53948], [53949].

Props jrf, costdev.
See #56033.

git-svn-id: https://develop.svn.wordpress.org/trunk@53952 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-29 12:44:30 +00:00
Marius L. J
1d45670654 Site Health: Improve the fatal error handling text in multisite scenarios.
The fatal error handler is responsible for providing a more user-friendly page to visitors if a site would normally encounter a fatal error, informing them of the next steps to access recovery mode (where applicable).

Those next steps would be to check the email address for the site administrator, but this was only the case for single site installs; In a multisite scenario, no email is sent.

This changes the text to account for that, still informing site administrators to check their email if it is a single site, but for multisite directing users to reach out to their site administrator for further assistance, so that they may take appropriate action.

Props rkaiser0324, Clorith.
Fixes #48929.

git-svn-id: https://develop.svn.wordpress.org/trunk@53951 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-28 19:49:40 +00:00
Marius L. J
52d8c0ea3d Site Health: Don't show issue groups unless there are items in them.
The Site Health Status screen groups issues into the categories `good`, `recommended`, and `critical` when displaying them to the end user.

Initially, this screen would show `0 critical issues` while the checks were being performed, and then hide the group if no issues were discovered after all checks had completed, this not being an ideal user experience, as it is a better experience to show areas that have content, instead of hiding them after the fact.

This change makes the groups hidden by default, and also changes the logic to see if a group should be displayed when an item is added to the list (as opposed to the previous approach which only did this check once every single test had completed).

Props DavidAnderson, palmiak.
Fixes #47222.

git-svn-id: https://develop.svn.wordpress.org/trunk@53950 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-28 19:15:37 +00:00
Anthony Burchell
1356e3b18d Coding Standards: Use strict comparisons in path_is_absolute().
This patch adjusts conditions to use strict comparisons when comparing `realpath()` in `path_is_absolute()`.

Props jrf.
See #36308.



git-svn-id: https://develop.svn.wordpress.org/trunk@53946 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-26 18:57:48 +00:00
Peter Wilson
541b4eb646 Cache API, Docs: Remove private delegation from cache priming functions.
Remove the private delegation from the following cache priming functions for various object types:

- `_prime_post_caches()`
- `_prime_term_caches()`
- `_prime_comment_caches()`
- `_prime_network_caches()`
- `_prime_site_caches()`
- `_get_non_cached_ids() `

Plugins and themes are now encouraged to use these functions to improve the performance of their code by reducing the number of database queries.

Props robinwpdeveloper, desrosj, SergeyBiryukov, mukesh27, costdev.
Fixes #56386.



git-svn-id: https://develop.svn.wordpress.org/trunk@53944 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-26 01:01:23 +00:00
Miguel Fonseca
8db6a6e26a Block Patterns: Add new Footers category
Quoting poena from the ticket: "[...] To make it easier for users to find these
patterns, a new block pattern category should be added. The patterns have
already been built to include the new category, with the slug "footer" [to]
match the existing Headers category"

Props poena.

Fixes #56416.



git-svn-id: https://develop.svn.wordpress.org/trunk@53943 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-25 15:40:58 +00:00
Peter Wilson
7f7d616d82 Query: Cache post ID database query within WP_Query.
Add object caching to the first database query in `WP_Query`, ie the database query for post IDs that match the desired result. Randomly ordered queries remain uncached as they are not intended to return consistent results.

Caching of ID queries is enabled by default, per the post object, term and meta caches.

Props spacedmonkey, aaroncampbell, batmoo, chriscct7, costdev, dd32, drewapicture, johnbillion, mukesh27, nacin, ocean90, peterwilsoncc, ryan, scribu, sergeybiryukov, tillkruss.
Fixes #22176.


git-svn-id: https://develop.svn.wordpress.org/trunk@53941 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-25 04:21:40 +00:00
Jonathan Desrosiers
6ab901eda4 Docs: Correct typo in wp_maybe_clean_new_site_cache_on_update() parameter description.
Props kebbet.
See #55646.

git-svn-id: https://develop.svn.wordpress.org/trunk@53939 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-24 15:24:14 +00:00
Anthony Burchell
b351a2f058 Media: Account for Windows when normalizing file paths.
Previously, Windows paths in the `path_is_absolute` function resulted in incorrect URIs. This patch adjusts for forward slashes and adds tests for the `get_attached_file` function.
Props Whissi, SergeyBiryukov, desrosj, stevenlinx, birgire, davidbaumwald, costdev, peterwilsoncc, audrasjb, hellofromTonya, johnbillion.
Fixes #36308.



git-svn-id: https://develop.svn.wordpress.org/trunk@53934 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-23 19:57:17 +00:00
Sergey Biryukov
edd85686c4 Themes: Add support for Update URI header.
This allows third-party themes to avoid accidentally being overwritten with an update of a theme of a similar name from the WordPress.org Theme Directory.

Additionally, introduce the `update_themes_{$hostname}` filter, which third-party themes can use to offer updates for a given hostname.

If set, the `Update URI` header field should be a URI and have a unique hostname.

Some examples include:

* `https://wordpress.org/themes/example-theme/`
* `https://example.com/my-theme/`
* `my-custom-theme-name`

`Update URI: false` also works, and unless there is code handling the `false` hostname, the theme will never get an update notification.

If the header is present, the WordPress.org API will currently only return updates for the theme if it matches the following format:

* `https://wordpress.org/themes/{$slug}/`
* `w.org/theme/{$slug}`

If the header has any other value, the API will not return a result and will ignore the theme for update purposes.

Follow-up to [50921].

Props dd32, meloniq, costdev, audrasjb, DavidAnderson, markjaquith, DrewAPicture, mweichert, design_dolphin, filosofo, sean212, nhuja, JeroenReumkens, infolu, dingdang, joyously, earnjam, williampatton, grapplerulrich, markparnell, apedog, afragen, miqrogroove, rmccue, crazycoders, jdgrimes, damonganto, joostdevalk, jorbin, georgestephanis, khromov, GeekStreetWP, jb510, Rarst, juliobox, Ipstenu, mikejolley, Otto42, gMagicScott, TJNowell, GaryJ, knutsp, mordauk, nvartolomei, aspexi, chriscct7, benoitchantre, ryno267, lev0, gregorlove, dougwollison, leemon, SergeyBiryukov.
See #14179, #23318, #32101.

git-svn-id: https://develop.svn.wordpress.org/trunk@53933 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-23 17:46:46 +00:00
Greg Ziółkowski
0fb2e697d5 Editor: Backport bug fixes from Gutenberg into Core for WP 6.0.2 RC
This brings a new version of the Gutenberg code from the [https://github.com/WordPress/gutenberg/tree/wp/6.0 wp/6.0 branch] into core.

- @wordpress/block-directory@3.4.14
 - @wordpress/block-editor@8.5.10
 - @wordpress/block-library@7.3.14
 - @wordpress/customize-widgets@3.3.14
 - @wordpress/edit-post@6.3.14
 - @wordpress/edit-site@4.3.14
 - @wordpress/edit-widgets@4.3.14
 - @wordpress/editor@12.5.10
 - @wordpress/format-library@3.4.10
 - @wordpress/reusable-blocks@3.4.10
 - @wordpress/widgets@2.4.10

Props SergeyBiryukov.
Fixes #56414.



git-svn-id: https://develop.svn.wordpress.org/trunk@53929 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-23 15:40:25 +00:00
Sergey Biryukov
ba7503322f Editor: Ensure get_block_templates() returns unique templates or template parts.
The function was using the `array_column()` PHP function on an array of objects, which works as expected on PHP 7 or later, but not on PHP 5.6.

This resulted in customized templates being listed multiple times on the Templates and Template Parts screens, and being repeatedly added between lists when switching between the screens.

The issue is now resolved by replacing `array_column()` with the `wp_list_pluck()` WordPress core function, which provides consistent behavior beetween PHP versions.

Reference: [https://github.com/php/php-src/blob/PHP-7.0.0/UPGRADING#L626 PHP 7.0 Upgrade Notes: array_column()].

Props uofaberdeendarren, antonvlasenko, ironprogrammer, jonmackintosh, costdev, hellofromTonya, swissspidy, rudlinkon.
Fixes #56271.

git-svn-id: https://develop.svn.wordpress.org/trunk@53927 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-23 14:50:56 +00:00
Sergey Biryukov
d385497144 Help/About: Improve vertical alignment in the Additional Design Tools section.
This makes a transparent circle SVG smaller by removing empty space to match the height of other images in the same section, so that all three columns are aligned correctly.

Follow-up to [53339].

Props sabernhardt, weboccults, ironprogrammer, webcommsat, marybaum, oglekler.
Fixes #56210.

git-svn-id: https://develop.svn.wordpress.org/trunk@53924 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-23 13:46:21 +00:00
Sergey Biryukov
5d78ecbe25 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53918 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-22 15:37:59 +00:00
Sergey Biryukov
45fbc51aaa 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53917 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-22 12:24:30 +00:00
Sergey Biryukov
1648e71a9f 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53915 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-20 00:30:54 +00:00
Sergey Biryukov
f96eb8eeef 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53914 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-20 00:25:13 +00:00
Joe Dolson
de3fbdecc0 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53913 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-19 23:04:04 +00:00
Joe Dolson
13a3c4c7f4 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53912 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-19 22:05:00 +00:00
Joe Dolson
868be75a50 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53911 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-19 20:58:34 +00:00
Jonathan Desrosiers
cef2139a4d Docs: Remove incorrect default value for $path argument of admin_url().
Props joyously, costdev.
See #55646.

git-svn-id: https://develop.svn.wordpress.org/trunk@53910 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-19 19:46:22 +00:00
Sergey Biryukov
74fa60b30a 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53908 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-19 13:09:12 +00:00
Sergey Biryukov
459e5d52ac 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53907 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-18 14:07:53 +00:00
Jb Audras
9341d6980f 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@53906 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-18 11:43:34 +00:00
Jb Audras
4da6f65d88 Docs: Use third-person singular verbs for function descriptions in WP_Tax_Query class, as per docblocks standards.
See #55646.


git-svn-id: https://develop.svn.wordpress.org/trunk@53905 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-18 11:26:54 +00:00
Jb Audras
5aee8db5a2 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@53904 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-18 08:43:19 +00:00
Sergey Biryukov
4a2130228f 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53901 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-17 13:58:22 +00:00
Jonathan Desrosiers
002ca62974 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53900 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-16 18:16:43 +00:00
Sergey Biryukov
286fe4ceb0 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53898 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-16 13:39:58 +00:00
Sergey Biryukov
37368555a5 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53897 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-15 13:16:22 +00:00
Sergey Biryukov
d51b039755 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53896 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-14 02:12:22 +00:00
John Blackbourn
0a2b35180b 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


git-svn-id: https://develop.svn.wordpress.org/trunk@53893 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-13 22:42:12 +00:00
John Blackbourn
dfcc2f6b18 Editor: Document the arguments for registering a block style.
See #55646


git-svn-id: https://develop.svn.wordpress.org/trunk@53892 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-13 22:36:27 +00:00
John Blackbourn
01c9ea7540 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


git-svn-id: https://develop.svn.wordpress.org/trunk@53891 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-13 22:29:19 +00:00
Jb Audras
902530bba9 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@53888 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-12 12:09:10 +00:00
Jb Audras
e44c3c4fac Docs: Use third-person singular verbs for function descriptions in wp-includes/functions.php, as per docblocks standards.
See #55646.


git-svn-id: https://develop.svn.wordpress.org/trunk@53887 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-12 09:51:10 +00:00
Jb Audras
38037ebb2c 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@53886 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-12 09:24:23 +00:00
Peter Wilson
c2e2e55b0d 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@53885 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-12 00:15:20 +00:00
Sergey Biryukov
299c8485c0 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53884 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 21:49:08 +00:00
John Blackbourn
40c19e45bf 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


git-svn-id: https://develop.svn.wordpress.org/trunk@53883 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 19:58:21 +00:00
John Blackbourn
7bb8dc6269 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


git-svn-id: https://develop.svn.wordpress.org/trunk@53882 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 18:22:59 +00:00
John Blackbourn
e999a8b281 XML-RPC: Correct the documented arguments for XML-RPC server methods.
See #55646


git-svn-id: https://develop.svn.wordpress.org/trunk@53881 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 14:58:55 +00:00
Jonathan Desrosiers
93c52bcb6a 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@53880 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 14:44:45 +00:00
John Blackbourn
57d6313f33 Docs: Revert two changes that need to instead be made upstream in the Gutenberg repo.
Partially reverts [53877].

See #55646


git-svn-id: https://develop.svn.wordpress.org/trunk@53879 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 14:31:59 +00:00
John Blackbourn
8d745ce28d Docs: Miscellaneous inline documentation improvements.
See #55646


git-svn-id: https://develop.svn.wordpress.org/trunk@53878 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 14:09:04 +00:00
John Blackbourn
0f1f17ebe2 Docs: Correct and improve the documented types for various functions and hooks.
See #55646


git-svn-id: https://develop.svn.wordpress.org/trunk@53877 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 14:01:35 +00:00
John Blackbourn
2b6107d05f 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


git-svn-id: https://develop.svn.wordpress.org/trunk@53876 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 13:53:51 +00:00
Jonathan Desrosiers
134cbc5eaf Twenty Eleven: Correct inline translator comment.
Props sabernhardt.
See #40039.

git-svn-id: https://develop.svn.wordpress.org/trunk@53875 602fd350-edb4-49c9-b593-d223f7449a82
2022-08-11 13:04:04 +00:00