Commit Graph

5099 Commits

Author SHA1 Message Date
Sergey Biryukov
13fb9e268c Tests: Move wp_dropdown_pages() tests to their own file.
This aims to make the tests more discoverable and easier to expand.

Includes removing a basic test hidden among `get_pages()` tests, as there is already a more comprehensive set of tests available.

Follow-up to [1279/tests], [28399], [31338].

See #57841.

git-svn-id: https://develop.svn.wordpress.org/trunk@55590 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-24 16:12:35 +00:00
Sergey Biryukov
99b8216888 Tests: Add a @ticket reference for wp_list_pages() CSS classes test.
Follow-up to [55588].

See #57841.

git-svn-id: https://develop.svn.wordpress.org/trunk@55589 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-24 15:05:29 +00:00
Sergey Biryukov
1de4538a38 Tests: Move the wp_list_pages() test for CSS classes to a more appropriate place.
Back when this test was introduced, `wp_list_pages()` did not have its own test class.

It does now, so the test can be moved there, instead of being hidden among `get_pages()` tests.

Includes:
* Updating the test name for clarity.
* Adding an unique message for each assertion.

Follow-up to [27755], [28400].

See #57841.

git-svn-id: https://develop.svn.wordpress.org/trunk@55588 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-24 14:58:39 +00:00
Jb Audras
dfc078d19d Login and Registration: Revert [55358] and [55360].
This reverts the changes implemented in [55358] and [55360].

Changeset [55358] was committed to prevent login name collision when one user registers with the email address `user@example.com` and a second user tries to register with the username `user@example.com`. However, it also introduced a potential backward compatibility issues for plugins that use `wp_update_user()`. When updating an existing user, it throws an `existing_user_email_as_login` error if the email address is also used for the user login, due to the code introduced in [55358].

This changeset removes the new scenario added in [55358] and [55360], restoring the `wp_insert_user()` function back to its previous state.

Props polevaultweb, audrasjb, costdev, peterwilsoncc, hellofromTonya, SergeyBiryukov, azaozz.
See #57967, #57394.


git-svn-id: https://develop.svn.wordpress.org/trunk@55584 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-23 13:52:25 +00:00
Sergey Biryukov
77883f97fc Tests: Improve get_pages() tests organization.
Includes:
* Renaming some tests for clarity.
* Moving some tests to a more appropriate place.
* Moving the `@covers` tag to the top of the class.
* Using consistent formatting for assertion messages.

Follow-up to [27767], [41849], [44587], [55569].

See #57841.

git-svn-id: https://develop.svn.wordpress.org/trunk@55583 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-23 11:35:21 +00:00
Sergey Biryukov
464ad20218 Tests: Consistently sanitize expiration in the test suite's Memcached implementation.
In a previous commit, the `::sanitize_expiration()` call in the `::add()` method was moved closer to where the value is used.

This commit does the same for the other methods:
* `::cas()`
* `::replace()`
* `::set()`
* `::setMulti()`

Follow-up to [40561], [55577].

See #57841, #57963.

git-svn-id: https://develop.svn.wordpress.org/trunk@55581 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-22 09:25:32 +00:00
Tonya Mork
d0f1816c36 Code Modernization: Fix dynamic properties in WP_Admin_Bar.
To fix the dynamic properties, the following changes are included:
* Removes `WP_Admin_Bar::__get()`.
* Declares `menu` as a property on the class, deprecates it, and initializes it to an empty array.
* Removes the unused 'proto' dynamic property.

Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.

== Why remove the `WP_Admin_Bar::__get()` magic method?

tl;dr
The magic method is no longer needed.

The magic method only handled the `menu` and `proto` dynamic properties. Introducing a full set of magic methods is overkill for this class. Instead of having to maintain magic methods, this changeset instead directly addresses the 2 properties (see below).

== Why declare the `menu` property on the class?

tl;dr
To simplify the code while maintaining backwards compatibility for extenders who are using this deprecated property.

The `menu` property was introduced during the 3.1.0 ''development cycle'' as a declared property [15671]. Its purpose was to ''internally'' hold the menu structure.

During the WP 3.3.0 development cycle, it was replaced by a new `private` property called `nodes` (see [19120]).

But breakage reports from extenders caused it to be restored. [19501] added the `__get()` magic method, i.e. for handling it as a dynamic property, and deprecated it.

>We're not going to maintain compat for $menu. Suggest we make it array() and plugins will have to deal. We can throw a _deprecated_argument() and push them to use the new methods.
~ Source: [https://core.trac.wordpress.org/ticket/19371#comment:17 see #19371 comment 17]

[https://wpdirectory.net/search/01GSTW1X69TBN8FH3SY7V8KPY5 A search of the wp.org plugins and themes repository] shows that a few plugins are still using this deprecated property. To maintain backwards compatibility, `menu` is moved back to the class as a declared property, set to an empty array (as it's been since 3.3.0), and deprecated in the property's description.

== Why remove the `proto` dynamic property?

tl;dr
* It was not intended to be released in 3.1.
* There are no usages of it in Core or in the WP.org's plugin or theme directories.
* It should be safe to remove.

This property was first introduced in the WP 3.1.0 ''development cycle'' to replace the `PROTO` constant (see [16038]) for protocol handling for the admin bar's hyperlinks. [16077] replaced the property's usages with URL functions such as `get_admin_url()` and `admin_url()`. But it missed removing the property, which was no longer needed or used.

It was relocated to the `__get()` magic method as a dynamic property when the `menu` property was restored (see [19501]).

A search of WP.org's plugins and themes repositories shows no usages of the property. Core hasn't used it since the removed in [16038] before 3.1 final release. It should be safe to remove it, but committing very early in the 6.3 alpha cycle to give time for reports of usages, if there are any.

References:
* A [https://www.youtube.com/watch?v=vDZWepDQQVE&t=9362s live open public working session] where these changes were discussed and agreed to.
* [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties].

Follow-up to [19501], [19120], [16308], [16038], [15671].

Props antonvlasenko, hellofromTonya, jrf, markjaquith, desrosj, ironprogrammer, peterwilsoncc, SergeyBiryukov.
See #56876, #56034.

git-svn-id: https://develop.svn.wordpress.org/trunk@55580 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-21 19:58:45 +00:00
Jonny Harris
9233e3a85a Build/Test Tools: Fix issue with add method in object-cache.php.
In the object-cache.php file used for unit tests, the add method did not work as expected. Other object cache plugins and core, have a check to see if the key exists in memory before writing it. Without this check, it used to write unnecessarily to the cache.  

Props spacedmonkey, SergeyBiryukov.
Fixes #57963.

git-svn-id: https://develop.svn.wordpress.org/trunk@55577 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-21 17:00:21 +00:00
Tonya Mork
95826a28f1 Tests: Rename test class and improve tests for wp_get_global_stylesheet().
Changes include:
* Renames the test class to be compliant with test coding standards.
* Converts the test class to extend `WP_Theme_UnitTestCase` to reuse test fixtures.
* Implements data providers to encapsulate datasets and reduce code repetition.
* Adds a `@covers` annotation.
* Improves assertion messages to help with diagnosing failed tests.

Follow-up to [55567], [55148], [52682], [53916], [52675-52677].

Props costdev, hellofromTonya.
See #57841, #57958.

git-svn-id: https://develop.svn.wordpress.org/trunk@55572 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-21 13:52:29 +00:00
Jonny Harris
eb6bf15bc7 Posts, Post Types: Use WP_Query internally in get_pages.
Convert `get_pages` to use `WP_Query` internally. Using WP_Query means that a lot of code has been removed however existing parameters supported by get_pages are transformed in to query arguments. The custom caching solution found in the old version of this function is replaced with the caching found in WP_Query (added in [53941]). This change adds consistency to the codebase, as improvements and changes to `WP_Query` will filter down to the `get_pages` function. 

Props mikeschinkel, spacedmonkey, nacin, scribu, filosofo, jane, garyc40, markoheijnen, grandslambert, kevinB, wlindley, dbernar1, atimmer, mdawaffe, helen, benjibee, johnbillion, peterwilsoncc, costdev, flixos90, joemcgill.
Fixes #12821.

git-svn-id: https://develop.svn.wordpress.org/trunk@55569 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-21 12:47:20 +00:00
Tonya Mork
7cef755d27 Tests: Add test class for wp_enqueue_stored_styles().
[54214] added the `wp_enqueue_stored_styles()` tests and `clean_up_global_scope()` reset global method to `Tests_Theme_wpGetGlobalStylesheet`.

This changeset relocates those tests a new test class specifically for `wp_enqueue_stored_styles()` and removes `Tests_Theme_wpGetGlobalStylesheet::clean_up_global_scope()` method.

Why not relocate the `clean_up_global_scope()` method to the new test class?
The test class extends from `WP_Theme_UnitTestCase` which includes this method.

Follow-up to [54214], [54703].

Props costdev.
See #57841.

git-svn-id: https://develop.svn.wordpress.org/trunk@55567 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-20 18:20:05 +00:00
Tonya Mork
94edf36189 Tests: Add test class for wp_script_is().
Changes:
* Adds a test class for `wp_script_is()`.
* Moves `WP_Dependencies_jQuery::test_wp_script_is_dep_enqueued()` into this test class and splits it into 2 separate tests, happy and unhappy paths.
* Adds `WP_Scripts::query` `@covers`, as `wp_script_is()` is helper function for it.
* Relocates the global resetting from the test method to the `clean_up_global_scope()` method.

Follow-up to [52010], [29252].

Props hellofromTonya, antonvlasenko.
See #57841, #57958.

git-svn-id: https://develop.svn.wordpress.org/trunk@55565 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-20 16:16:22 +00:00
Sergey Biryukov
6d1381180b KSES: Allow filter property to accept a URL in safecss_filter_attr().
CSS filters can accept `url()` as a reference to an SVG filter element:
{{{
filter: url( file.svg#filter-element-id );
}}}
This commit allows for that syntax to be used in inline CSS.

Original PR from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/48281 #48281 Duotone: Use the style engine to generate CSS for Duotone]

References:
* [https://developer.mozilla.org/en-US/docs/Web/CSS/filter MDN Web Docs: filter()]
* [https://developer.mozilla.org/en-US/docs/Web/CSS/url MDN Web Docs: url()]

Follow-up to [44136], [52049].

Props scruffian, jeryj, ironprogrammer, azaozz, hellofromTonya, SergeyBiryukov.
Fixes #57780.

git-svn-id: https://develop.svn.wordpress.org/trunk@55564 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-20 08:23:47 +00:00
Sergey Biryukov
a387dee3f9 Tests: Improve documentation and variable names in some formatting tests.
Includes documenting data provider values using hash notation in the tests for:
* `convert_smilies()`
* `get_url_in_content()`
* `links_add_target()`
* `normalize_whitespace()`

Follow-up to [26191], [26327], [26328], [26972], [55562].

See #57841.

git-svn-id: https://develop.svn.wordpress.org/trunk@55563 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-19 12:51:14 +00:00
Sergey Biryukov
d1046dc5f3 Tests: Use the data_ prefix for various data provider methods.
This aims to bring more consistency to the test suite, as the vast majority of data providers already use that prefix.

Includes moving some data providers next to the tests they are used in.

Follow-up to [55464].

See #57841.

git-svn-id: https://develop.svn.wordpress.org/trunk@55562 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-19 12:03:30 +00:00
Tonya Mork
f2028e108e HTML API: Add bookmark invalidation logic.
While `WP_HTML_Tag_Processor` currently only supports changing a given tag's attributes, the plan is to provide methods to make broader changes (possibly through a subclass of `WP_HTML_Tag_Processor`). The API will have the potential of replacing a tag that a bookmark points to. To prepare, this changeset makes sure that all bookmarks affected by a HTML replacement are invalidated (i.e. released).

Changes:
* Extends the existing loop in `WP_HTML_Tag_Processor::apply_attributes_updates()` that adjusts bookmarks' start and end positions upon HTML changes to check if the entire bookmark is within a portion of the HTML that has been replaced.
* Adds `WP_HTML_Tag_Processor::has_bookmark() to check whether the given bookmark name exists.

References:
* [https://github.com/WordPress/gutenberg/pull/47559 Gutenberg PR 47559]
* [https://github.com/WordPress/gutenberg/releases/tag/v15.3.0 Released in Gutenberg 15.3.0]

Follow-up to [55203].

Props bernhard-reiter, dmsnell, zieladam.
Fixes #57788.

git-svn-id: https://develop.svn.wordpress.org/trunk@55555 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-16 13:09:55 +00:00
Jonny Harris
767f16f6a5 Widgets: Defer register inline script in WP_Widget_Custom_HTML and WP_Widget_Text.
In [41376] an inline script was added to push `idBases` for the custom html and text widgets. However, this script is not used unless the widget script is output in the widget screen / customizer. Deferring registering this script until it is needed, results in a faster server response times. 


Props spacedmonkey, sakibmd, flixos90, westonruter.
Fixes #57864.

git-svn-id: https://develop.svn.wordpress.org/trunk@55553 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-15 11:36:52 +00:00
Sergey Biryukov
200868214a Docs: Fix typo in _validate_cache_id() description.
Includes:
* Capitalizing "ID" in a consistent way.
* Expanding the comment on not using `filter_var()`.
* Adding a `@covers` tag for the function in unit tests.
* Minor tweak to the `_doing_it_wrong()` message.

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

See #57593.

git-svn-id: https://develop.svn.wordpress.org/trunk@55549 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-14 16:53:07 +00:00
Jonny Harris
2724a495af Cache API: Add a warning when calling _get_non_cached_ids with invalid ids.
Sanitize the array of ids passed to the `_get_non_cached_ids` function and add a `_doing_it_wrong` call, if an invalid type is passed. 

Props tillkruess, spacedmonkey, peterwilsoncc, flixos90, SergeyBiryukov.
Fixes #57593.

git-svn-id: https://develop.svn.wordpress.org/trunk@55543 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-14 15:51:28 +00:00
Jonny Harris
c421c7ead6 Cache API: Make network-queries and site-queries global cache groups.
Fixes a bug introduced in [55526]. The cache groups `network-queries` and `site-queries` store query results for network and site. These are network level data and should be stored in a global cache group. 

Props spacedmonkey, tillkruess, flixos90.
See #57625.

git-svn-id: https://develop.svn.wordpress.org/trunk@55537 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-10 17:49:58 +00:00
Tonya Mork
b0c91dbdf1 Editor: Add more details to template descriptions.
The template descriptions in `get_default_block_template_types()` are updated to add more details. Why? These descriptions are now more prominent in 6.2 to provide a better UX experience with more helpful information.

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

Follow-up to [54761], [54104], [54269], [53129], [52331], [52062].

Props ntsekouras, andrewserong, bph, davidbaumwald, greenshady, glendaviesnz, hellofromTonya, jameskoster, mamaduka, peterwilsoncc, sabernhardt, SergeyBiryukov.
Fixes #57892.

git-svn-id: https://develop.svn.wordpress.org/trunk@55500 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-09 16:29:13 +00:00
Sergey Biryukov
16901ff4ca Formatting: Restore consistent quotes in _make_web_ftp_clickable_cb().
After the introduction of `_make_clickable_rel_attr()` in an earlier commit, the function ended up returning link markup with a mix of single and double quotes.

This commit ensures that `_make_web_ftp_clickable_cb()` always returns double quotes, restoring consistency with other similar callback functions used by `make_clickable()`:
* `_make_url_clickable_cb()`
* `_make_email_clickable_cb()`

Follow-up to [55289].

See #53290, #56444.

git-svn-id: https://develop.svn.wordpress.org/trunk@55495 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-09 00:18:29 +00:00
Tonya Mork
7b979b3515 Site Editor: Revert r54860.
[54860] caused a regression. Changes to a parent theme's template part (i.e.e when a child theme does not override that template part) no longer saved in the Site Editor. Reverting the changeset resolves the regression.

Props mreishus, hellofromTonya, azaozz, ironprogrammer, antonvlasenko.

Fixes #57630.
See #55437.

git-svn-id: https://develop.svn.wordpress.org/trunk@55493 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-08 22:43:32 +00:00
Sergey Biryukov
9ec9103669 Tests: Add a unit test for register_block_style_handle() with an RTL locale.
The test ensures that the function loads RTL stylesheets when a locale with the right-to-left text direction is set.

Follow-up to [54330].

Props costdev, thomasplevy, audrasjb, mukesh27.
Fixes #56797.

git-svn-id: https://develop.svn.wordpress.org/trunk@55486 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-08 15:00:12 +00:00
Peter Wilson
4d3627fd2e Build/Tests Tools: Add unit tests for Gallery blocks.
Introduces unit tests for the following blocks

* Gallery block with caption
* Gallery block, deprecations 1 thru 7

Updates the unit tests for the following blocks to match the counterparts stored in the Gutenberg repository:

* Gallery block
* Gallery block with columns

Modifies `Tests_Blocks_Render::test_do_block_output()` to ignore white space at the end of lines to account for whitespace equivalence in HTML.

Props peterwilsoncc, isabel_brison, gziolo.
Fixes #55571.



git-svn-id: https://develop.svn.wordpress.org/trunk@55471 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-07 05:46:16 +00:00
Tonya Mork
455b1e857e HTML API: Fix finding RCData and Script tag closers.
Fixes finding the following tag closers `</script>`, `</textarea>`, and `</title>` in `WP_HTML_Tag_Processor`.

Follow-up to [55407], [55203].

Props zieladam, dmsnell, hellofromTonya.
Fixes #57852.
See #57575.

git-svn-id: https://develop.svn.wordpress.org/trunk@55469 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-06 18:53:38 +00:00
Tonya Mork
65c7df0344 Tests: Use assertSame() in Tests_Theme_wpThemeJson.
Change from assertEquals() to assertSame(). Why? To ensure both the return value and data type match the expected results.

Follow-up to [55216].

Props costdev, peterwilsoncc, mukesh27, ankitmaru.
See #56800, #57621.

git-svn-id: https://develop.svn.wordpress.org/trunk@55468 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-06 17:44:15 +00:00
Tonya Mork
cd9d0eadf1 Tests: Improve Tests_Media::test_wp_generate_attachment_metadata_doesnt_generate_sizes_for_150_square_image().
Changes:

* from `assertEquals()` to `assertSame()`. Why? To ensure both the return value and data type match the expected results.

* the expected height and width from `string` to `integer` data types. Why integer? `getimagesize()` (within `wp_getimagesize()`) will return an integer for both height and weight.

* adds the ticket annotation.

* adds assertion failure messages. Why? To denote which assertion failed, which aids in debugging efforts.

Follow-up to [55278].

Props costdev, peterwilsoncc, mukesh27, ankitmaru, hellofromTonya.
See #56800, #57370.

git-svn-id: https://develop.svn.wordpress.org/trunk@55467 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-06 16:27:23 +00:00
Tonya Mork
f08a0e2a3b Build/Test Tooling: Use assertSame() in Tests_Comment::test_update_comment_from_privileged_user_by_privileged_user().
Change from `assertEquals()` to `assertSame()`. Why? To ensure both the return value and data type match the expected results.

Follow-up to [c].

Props costdev, peterwilsoncc, mukesh27, ankitmaru.
See #56800.

git-svn-id: https://develop.svn.wordpress.org/trunk@55466 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-06 15:01:33 +00:00
Tonya Mork
c39d384d33 Build/Test Tooling: Use assertSame() in WP_Date_Query tests.
Change from `assertEquals()` to `assertSame()`. Why? To ensure both the return value and data type match the expected results.

Follow-up to [54530].

Props costdev, peterwilsoncc, mukesh27, ankitmaru.
See #56800.

git-svn-id: https://develop.svn.wordpress.org/trunk@55465 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-06 14:44:35 +00:00
Sergey Biryukov
a66d268920 Tests: Move some data providers in Tests_Functions next to the tests they are used in.
Includes renaming some data provider methods to use the `data_` prefix for consistency.

Follow-up to [36832], [40124], [40397], [50810], [53457].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@55464 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-06 13:08:03 +00:00
Sergey Biryukov
d7c458f866 Tests: Adjust the expected mime type for WOFF fonts on PHP 8.1.12+.
As of PHP 8.1.12, which includes libmagic/file update to version 5.42, the expected mime type for WOFF files has changed to `font/woff`, so the type needs to be adjusted accordingly in `wp_check_filetype_and_ext()` tests.

References:
* [https://github.com/php/php-src/issues/8805 php-src: #8805: finfo returns wrong mime type for woff/woff2 files]
* [https://www.php.net/ChangeLog-8.php#8.1.12 PHP 8.1.12 changelog]

Follow-up to [40124], [54508], [54509], [54724].

Props costdev, SergeyBiryukov.
Fixes #56817.

git-svn-id: https://develop.svn.wordpress.org/trunk@55462 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-06 12:39:18 +00:00
Sergey Biryukov
6eeeeaaea5 Tests: Make sure the correct query is tested for term limits in taxonomy queries.
By hooking into `terms_pre_query` after the fixture posts and terms are created but before the actual taxonomy query runs, we ensure that the correct SQL query from `WP_Term_Query::get_terms()` is tested for requested term limits, rather than the one initiated from `wp_insert_post()` or `wp_insert_term()` via `term_exists()`.

Follow-up to [52921], [53037].

Props david.binda.
Fixes #57342.

git-svn-id: https://develop.svn.wordpress.org/trunk@55460 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-04 11:50:26 +00:00
Sergey Biryukov
b0f085ece3 Tests: Second pass at merging file-level and class-level DocBlocks in various unit test files.
Per the[https://developer.wordpress.org/coding-standards/inline-documentation-standards/php/#6-file-headers documentation standards], whenever possible, all WordPress files should contain a header DocBlock, regardless of the file’s contents – this includes files containing classes.

However, this recommendation makes less sense for unit test classes if not applied consistently, and the duplicate tags cause some confusion.

This commit aims to reduce confusion and avoid repeating information by combining the DocBlocks.

Follow-up to [55337].

Props sakibmd, fuadragib, robinwpdeveloper, naeemhaque, seakashdiu, jakariaistauk, hasanmisbah, SergeyBiryukov.
Fixes #57723.

git-svn-id: https://develop.svn.wordpress.org/trunk@55457 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-03 14:42:42 +00:00
Tonya Mork
6a574d7676 Build/Test Tools: Add wp_check_filetype() unit tests.
Adds a test class and data set for unit testing `wp_check_filetype()`.

Props pbearne, costdev.
Fixes #57151.

git-svn-id: https://develop.svn.wordpress.org/trunk@55456 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-02 21:03:15 +00:00
Jb Audras
66055a520d Editor: Ensure Global styles values are reset in the site editor.
This changeset fixes a bug by which the reset function of the global styles sidebar would not work as expected in the site editor. It reverts [54517] and adds related unit tests.

Props oandregal, ntsekouras, youknowriad, hellofromTonya.
Fixes #57824
See #56467


git-svn-id: https://develop.svn.wordpress.org/trunk@55448 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-01 16:15:27 +00:00
Sergey Biryukov
0bd424f428 Tests: Ignore EOL differences in a wpautop() test for <math> block elements.
Unix vs. Windows EOL style mismatches can cause misleading failures in tests using the heredoc syntax (`<<<`) or multiline strings as the expected result.

This commit resolves a failure when running the test suite on Windows:
{{{
1) Tests_Formatting_wpAutop::test_skip_block_math_elements
Failed asserting that two strings are identical.
...
#Warning: Strings contain different line endings!
}}}

Follow-up to [55272].

Props davidbaumwald, ignatggeorgiev, sakibmd.
Fixes #57718.

git-svn-id: https://develop.svn.wordpress.org/trunk@55445 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-01 15:56:39 +00:00
Sergey Biryukov
0a91a53cf7 Users: Use a separate variable for the post counts query in wp_list_authors().
This avoids a collision if `wp_list_authors()` is called with the `optioncount` parameter enabled, and the resulting array for the post counts query contains a key that matches the ID of a user who does not have any posts.

Follow-up to [54262].

Props peterwilsoncc, johnbillion, lifeboat, brookedot, thedaysse, Toru.
Fixes #57011.

git-svn-id: https://develop.svn.wordpress.org/trunk@55444 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-01 15:37:06 +00:00
Sergey Biryukov
b12e340f11 Tests: Add unit tests for get_next_posts_link() and get_previous_posts_link().
The tests ensure that the `next_posts_link_attributes` and `previous_posts_link_attributes` filters are applied correctly.

Follow-up to [1383], [5045], [8502], [9632], [55429].

Props geisthanen, mukesh27, costdev, audrasjb, SergeyBiryukov.
Fixes #55751.

git-svn-id: https://develop.svn.wordpress.org/trunk@55442 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-01 14:43:27 +00:00
Andrew Ozz
0bbf09f496 Media: Revert the addition of a $size parameter to get_attached_file().
Reverts [55199], [55202], and [55217] but keeps the updated docs.

Props: flixos90, joedolson, azaozz.
Fixes: #51780.

git-svn-id: https://develop.svn.wordpress.org/trunk@55437 602fd350-edb4-49c9-b593-d223f7449a82
2023-03-01 00:34:18 +00:00
Tonya Mork
5ce8b1f9ed Editor: Deprecate _resolve_home_block_template().
The internal Core-only `_resolve_home_block_template()` function was introduced in [53093] for a specific purpose of resolving the template for a site's home page. It was used as part of the Site Editor's redirect when the `postType` and `postId` query args were missing. The server-side handling was removed in [55338]. The function is no longer used in Core.

This changeset deprecates the function and removes its tests.

Follow-up to [55338], [53093].

Props johnbillion, hellofromTonya.
Fixes #57716.

git-svn-id: https://develop.svn.wordpress.org/trunk@55436 602fd350-edb4-49c9-b593-d223f7449a82
2023-02-28 15:05:50 +00:00
Peter Wilson
63b3c26f07 Formatting: Add aspect-ratio tests for safecss_filter_attr().
Follow up to [55309].

Props rahmohn, desrosj, mukesh27.
Fixes #57664.


git-svn-id: https://develop.svn.wordpress.org/trunk@55430 602fd350-edb4-49c9-b593-d223f7449a82
2023-02-28 02:50:28 +00:00
Jb Audras
c102b78ea6 Build/Test Tools: Add test coverage for the get_posts_navigation() function.
This changeset adds a test case to verify that `get_the_posts_navigation()` only includes the "Older posts" and "Newer" posts links when appropriate.

Props jongycastillo, michelmany, joyously, geisthanen, SergeyBiryukov, mukesh27, audrasjb, costdev, sun, chrisbaltazar.
Fixes #55751.


git-svn-id: https://develop.svn.wordpress.org/trunk@55429 602fd350-edb4-49c9-b593-d223f7449a82
2023-02-27 23:14:57 +00:00
Sergey Biryukov
18878a1d93 Themes: Account for a numeric theme directory in WP_Theme::__construct().
This ensures that if a theme with a numeric directory name is active, it is correctly identified as such, and that theme support features work as expected.

Follow-up to [20029], [49925].

Props lopo, alvastar, winterpsv, hugodevos, ankit-k-gupta, jakariaistauk, mukesh27, spacedmonkey, SergeyBiryukov.
Fixes #54645.

git-svn-id: https://develop.svn.wordpress.org/trunk@55426 602fd350-edb4-49c9-b593-d223f7449a82
2023-02-27 15:32:22 +00:00
Sergey Biryukov
12fcc5cfac Upgrade/Install: Introduce WP_Automatic_Updater::is_allowed_dir() method.
As part of determining whether to perform automatic updates, WordPress checks if it is running within a version-controlled environment, recursively looking up the filesystem to the top of the drive, looking for a Subversion, Git, Mercurial, or Bazaar directory, erring on the side of detecting a VCS checkout somewhere.

This commit avoids a PHP warning if the `open_basedir` directive is in use and any of the directories checked in the process are not allowed:
{{{
is_dir(): open_basedir restriction in effect. File(/.git) is not within the allowed path(s)
}}}

Follow-up to [25421], [25700], [25764], [25835], [25859].

Props costdev, markjaquith, meyegui, dd32, arnolp, robin-labadie, hellofromTonya, afragen, pbiron, SergeyBiryukov.
Fixes #42619.

git-svn-id: https://develop.svn.wordpress.org/trunk@55425 602fd350-edb4-49c9-b593-d223f7449a82
2023-02-26 15:17:45 +00:00
Sergey Biryukov
c758a10d98 General: Add more error checking to WP_List_Util::pluck().
Values for the input array in `WP_List_Util::pluck()` or `wp_list_pluck()` must be either objects or arrays.

This commit adds a check to ensure that the value retrieved in the loop is an array before treating it as such, and throws a `_doing_it_wrong()` notice if it is neither an object nor an array.

Follow-up to [14108], [15686], [18602], [28900], [38928].

Props afragen, costdev, audrasjb.
Fixes #56650.

git-svn-id: https://develop.svn.wordpress.org/trunk@55423 602fd350-edb4-49c9-b593-d223f7449a82
2023-02-25 10:57:14 +00:00
Sergey Biryukov
b394c9c144 Posts, Post Types: Pass the post object to _update_posts_count_on_delete().
The function checks the status of the post being deleted, and then only calls `update_posts_count()` if the deleted post was previously published, as the update query would be unnecessary otherwise.

However, by the time the function runs, the post is already deleted from the database, and the post status check fails.

This commit uses the previously retrieved post object for the status check, so that the function proceeds as expected.

Includes updating the unit test to call `wp_delete_post()` with the `$force_delete` argument, so that the post is actually deleted, not trashed, and the `after_delete_post` action is run.

Follow-up to [28835], [52207], [54760], [54762].

Fixes #57023.

git-svn-id: https://develop.svn.wordpress.org/trunk@55419 602fd350-edb4-49c9-b593-d223f7449a82
2023-02-24 01:21:54 +00:00
Jb Audras
0a422d3f4b Help/About: Use the new /documentation/ URLs for HelpHub links in WordPress Admin.
As `https://wordpress.org/support/` was redirected to `https://wordpress.org/documentation/`, this changeset replaces various `/support/article/*` links with `/documentation/article/*` to avoid an extra redirect.

This also updates links to Support Forums by replacing `https://wordpress.org/support/` URLs with `https://wordpress.org/support/forums/`.

Props SergeyBiryukov, audrasjb, dhrupo, hasanmisbah, sakibmd, sabernhardt.
See #57726.


git-svn-id: https://develop.svn.wordpress.org/trunk@55412 602fd350-edb4-49c9-b593-d223f7449a82
2023-02-23 10:36:33 +00:00
Tonya Mork
83ae6b790e HTML API: Fix finding bookmarks set on closing tag WP_HTML_Tag_Processor.
Setting a bookmark on a tag should set its "start" position before the opening "<", e.g.:
{{{
<div> Testing a <b>Bookmark</b>
----------------^
}}}

The previous calculation assumed this is always one byte to the left from `$tag_name_starts_at`.

However, in a closing tag that index points to a solidus symbol "/":
{{{
<div> Testing a <b>Bookmark</b>
----------------------------^
}}}

The bookmark should therefore start two bytes before the tag name:
{{{
<div> Testing a <b>Bookmark</b>
---------------------------^
}}}

This changeset achieves this by:
* Using the correct starting index for closing tag bookmarks.
* Adding `array( 'tag_closers' => 'visit' )` in `WP_HTML_Tag_Processor::seek()`.

Follow-up to [55203].

Props zieladam, dmsnell, flixos90.
Fixes #57787.
See #57575.

git-svn-id: https://develop.svn.wordpress.org/trunk@55407 602fd350-edb4-49c9-b593-d223f7449a82
2023-02-22 20:53:41 +00:00
John Blackbourn
b0754798c6 Revisions: Remove an unnecessary call to _doing_it_wrong() and corresponding new text string from the implementation of the new wp_save_post_revision_revisions_before_deletion filter.
While the guard condition was technically correct, it's not practical or necessary to provide this protection for every use of every filter, and it adds unnecessary burden to translators to provide translations for strings that will likely not be seen.

Follow up to [55254].

Fixes #57320


git-svn-id: https://develop.svn.wordpress.org/trunk@55406 602fd350-edb4-49c9-b593-d223f7449a82
2023-02-22 20:47:38 +00:00