Commit Graph

42446 Commits

Author SHA1 Message Date
Sergey Biryukov
898eb5fc51 Tests: Speed up slashed data tests by reusing some more shared fixtures.
Follow-up to [35249], [49003].

See #51344.

git-svn-id: https://develop.svn.wordpress.org/trunk@49005 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-19 11:11:00 +00:00
Sergey Biryukov
4018e92c39 Coding Standards: Give the $id variable in slashed data tests a more descriptive name.
See #50767, #51344.

git-svn-id: https://develop.svn.wordpress.org/trunk@49004 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-19 10:53:15 +00:00
Sergey Biryukov
ffc129395c Tests: Speed up slashed data tests by reusing shared fixtures.
Follow-up to [35249].

See #51344.

git-svn-id: https://develop.svn.wordpress.org/trunk@49003 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-19 10:34:54 +00:00
Sergey Biryukov
0c5324df3b Tests: Speed up tests for wp_allow_comment() by reusing shared fixtures.
Props frank-klein.
Fixes #51216.

git-svn-id: https://develop.svn.wordpress.org/trunk@49002 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-19 09:25:55 +00:00
Sergey Biryukov
1ec9dc6fa4 Tests: Simplify the logic in WP_UnitTestCase_Base::setUpBeforeClass() and ::tearDownAfterClass().
See #51344.

git-svn-id: https://develop.svn.wordpress.org/trunk@49001 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-19 09:11:23 +00:00
Peter Wilson
1ffdfdaea7 Posts, Post Types: Ensure default terms are added by wp_publish_post().
Transitioning posts from `auto-draft` to `publish` via `wp_publish_post()` could result in published posts without the default category or custom taxonomy default terms.

Props frank-klein, TimothyBlynJacobs, peterwilsoncc.
Fixes #51292.



git-svn-id: https://develop.svn.wordpress.org/trunk@49000 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-19 01:20:48 +00:00
Sergey Biryukov
2f491fba50 Tests: Simplify PluralFormsTest::test_exceptions().
Previously, the test had to use an older pattern for catching the generic `Exception` exceptions for compatibility with PHPUnit 3.6 on PHP 5.2.

Now that WordPress supports PHPUnit 5.4 as the minimum version, the `expectException()` method can be used directly.

Follow-up to [41725], [41730].

See #51344.

git-svn-id: https://develop.svn.wordpress.org/trunk@48999 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-18 14:11:11 +00:00
Sergey Biryukov
ba20847ef5 Docs: Update the code example in WP_Ajax_UnitTestCase::dieHandler() DocBlock to use expectException().
Follow-up to [48996], [48997].

See #51344.

git-svn-id: https://develop.svn.wordpress.org/trunk@48998 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-18 13:53:31 +00:00
Sergey Biryukov
5164bba5e2 Tests: Switch Ajax tests to use the expectException() method directly, instead of the WP_UnitTestCase_Base::setExpectedException() wrapper.
This brings some consistency with other tests.

Follow-up to [48996].

See #51344.

git-svn-id: https://develop.svn.wordpress.org/trunk@48997 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-18 13:48:27 +00:00
Sergey Biryukov
d46af0956d Tests: Consistently use the expectException() method instead of the older @expectedException annotation.
See https://thephp.cc/news/2016/02/questioning-phpunit-best-practices

The method is available since PHPUnit 5.2, and WordPress currently supports PHPUnit 5.4 as the minimum version.

Follow-up to [48993].

See #51344.

git-svn-id: https://develop.svn.wordpress.org/trunk@48996 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-18 13:22:22 +00:00
Sergey Biryukov
f78acee893 Docs: Add a @since note about adjacent_posts_rel_link_wp_head() no longer being used in core.
Follow-up to [48966].

Props jnylen0.
See #39111.

git-svn-id: https://develop.svn.wordpress.org/trunk@48995 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-18 11:04:48 +00:00
Sergey Biryukov
8bc03cf494 Docs: Add a @since note for the recovery_mode_email filter about the $email argument now including the attachments key.
Follow-up to [48964].

See #51276.

git-svn-id: https://develop.svn.wordpress.org/trunk@48994 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-18 11:01:52 +00:00
Sergey Biryukov
bc556578b3 Tests: Fix the failure in test_get_weekday_undefined_index() on PHP 8.
The test ensures that `WP_Locale::get_weekday()` throws an "undefined offset" notice when called with an incorrect `$weekday_number` parameter.

In PHP 8, that notice is now a warning, so the test needs to be adjusted accordingly.

See #50913.

git-svn-id: https://develop.svn.wordpress.org/trunk@48993 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-18 10:56:27 +00:00
Sergey Biryukov
cb356d9cfc Twenty Twenty: Update the URL for PHP date formats table in translator comments.
Follow-up to [48991].

Props hareesh-pillai, mukesh27, iandunn.
Fixes #51335. See #51332.

git-svn-id: https://develop.svn.wordpress.org/trunk@48992 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-18 10:42:26 +00:00
Sergey Biryukov
7d23a212c4 Docs: Update the URL for PHP date formats table in translator comments.
Props hareesh-pillai, iandunn.
Fixes #51332.

git-svn-id: https://develop.svn.wordpress.org/trunk@48991 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-18 10:35:41 +00:00
Sergey Biryukov
cb38bc973e Comments: Assign the array of comment data returned from the comments_pre_query filter to the comments property of the current WP_Comment_Query instance.
This avoids the performance overhead of calling `WP_Comment_Query::get_comments()` twice: first when creating the object instance, then to retrieve the filtered results.

This also makes the filter a bit more consistent with other similar filters, e.g. `posts_pre_query`, `terms_pre_query`, or `users_pre_query`.

Follow-up to [46086].

Props dinhtungdu, imath, spacedmonkey, adamsilverstein, SergeyBiryukov.
Fixes #50521.

git-svn-id: https://develop.svn.wordpress.org/trunk@48990 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-17 19:53:47 +00:00
Anthony Burchell
7da52b8eae Media: Allow contextually generated images to show in Media Library grid view.
In grid view, contextually generated or cropped media is filtered out causing page numbering to be offset and incorrect. This also impacted any media utilizing `media-models.js`.
Props webmandesign, audrasjb, afercia, pbiron, mista-flo.
Fixes #46127, #50410, #47215.



git-svn-id: https://develop.svn.wordpress.org/trunk@48989 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-17 14:40:47 +00:00
Sergey Biryukov
f5fc714cf6 Tests: Move the data_wp_site_query_meta_query() data provider next to the test it's used in.
See #50767.

git-svn-id: https://develop.svn.wordpress.org/trunk@48988 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-17 11:28:05 +00:00
Sergey Biryukov
64a0a9f108 Docs: Correct comments in comments_pre_query, networks_pre_query, and sites_pre_query tests.
Follow-up to [44983], [46086].

See #50768.

git-svn-id: https://develop.svn.wordpress.org/trunk@48987 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-17 11:18:39 +00:00
Sergey Biryukov
e145c9aaba Docs: Reformat comments_pre_query, networks_pre_query, sites_pre_query DocBlocks for better readability.
See #50768.

git-svn-id: https://develop.svn.wordpress.org/trunk@48986 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-17 11:08:04 +00:00
Sergey Biryukov
8621e8d5c8 Docs: Fix typo in *_pre_query filter DocBlocks.
See #50768.

git-svn-id: https://develop.svn.wordpress.org/trunk@48985 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-17 10:43:23 +00:00
Sergey Biryukov
77647aea23 Docs: Correct the parameter type for networks_pre_query filter.
The filter should return the network count as an integer if `$this->query_vars['count']` is set.

Follow-up to [46100].

See #50768, #47599.

git-svn-id: https://develop.svn.wordpress.org/trunk@48984 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-17 10:35:51 +00:00
Sergey Biryukov
9cb0da3754 Formatting: Make sure links_add_target() adds the target attribute to the correct tag.
Previously, the attribute could unintentionally be added to a tag that starts with the same characters, e.g. `<aside>` instead of `<a>`.

Props antonlukin.
Fixes #51313.

git-svn-id: https://develop.svn.wordpress.org/trunk@48983 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-17 10:12:32 +00:00
Helen Hou-Sandi
9648bcd373 i18n: Ensure block type strings in the REST API end with a full stop.
Props ramiy, justinahinon.
Fixes #50805.



git-svn-id: https://develop.svn.wordpress.org/trunk@48982 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-16 19:21:03 +00:00
Sergey Biryukov
2cc4276746 Code Modernization: Return an empty string from wpdb::prepare() if there are not enough arguments to match the placeholders.
This avoids a fatal error on PHP 8 caused by passing mismatched arguments to `vsprintf()`, and maintains the current behaviour.

Follow-up to [48979], [48980].

See #50913, #50639.

git-svn-id: https://develop.svn.wordpress.org/trunk@48981 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-16 02:27:42 +00:00
Sergey Biryukov
35ceac68f4 Code Modernization: Return an empty string from wpdb::_real_escape() if a non-scalar value is passed.
This avoids a fatal error on PHP 8 caused by passing a non-string value to ` mysqli_real_escape_string()`, and maintains the current behaviour.

See #50913, #50639.

git-svn-id: https://develop.svn.wordpress.org/trunk@48980 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-16 01:46:25 +00:00
Sergey Biryukov
aadc1d70f2 Tests: Revert [48973].
These tests ensure that a `_doing_it_wrong()` notice is thrown when `wpdb::prepare()` is called incorrectly, but also that the function will still handle the provided input as correctly as possible.

Disabling these tests on PHP 8 hides a problem, i.e. the function will no longer throw a notice and handle things correctly, it will now cause a white screen of death due to a fatal error.

That is a backward compatibility break, and `wpdb::prepare()` should be updated instead to maintain the original behaviour on PHP 8.

Props jrf, ayeshrajans.
See #50913, #50639.

git-svn-id: https://develop.svn.wordpress.org/trunk@48979 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-16 01:33:42 +00:00
Sergey Biryukov
b936a4131d Build/Test Tools: Restore the QUnit global in JSHint config for QUnit.
Follow-up to [47512], [48977].

See #51312, #37117.

git-svn-id: https://develop.svn.wordpress.org/trunk@48978 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-15 10:07:29 +00:00
Sergey Biryukov
d9514d19f1 Build/Test Tools: Remove unused legacy globals from JSHint config for QUnit.
Follow-up to [47512].

Props TimoTijhof.
Fixes #51312. See #37117.

git-svn-id: https://develop.svn.wordpress.org/trunk@48977 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-15 10:02:22 +00:00
Sergey Biryukov
54fd2f7a80 Docs: Document the usage of $wpdb global in wp_delete_attachment_files().
Props jontyravi.
Fixes #51309.

git-svn-id: https://develop.svn.wordpress.org/trunk@48976 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-14 13:41:33 +00:00
Sergey Biryukov
82a4978a71 Docs: Document the usage of $wpdb global in wp_get_post_autosave().
Follow-up to [48422].

Props ravivaddweb.
Fixes #51308. See #34560.

git-svn-id: https://develop.svn.wordpress.org/trunk@48975 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-14 13:35:10 +00:00
Sergey Biryukov
91feaf04af Tests: Correct assertion in Tests_DB::test_prepare_incorrect_arg_count().
On failure, `wpdb::prepare()` returns either an empty string or `null`, not `false`.

The test only passed accidentally due to `assertEquals()` not performing a strict type check.

Follow-up to [41662].

See #38266.

git-svn-id: https://develop.svn.wordpress.org/trunk@48974 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-13 15:19:40 +00:00
Sergey Biryukov
2d01fac875 Tests: Require PHP less than 8.0 for some wpdb tests.
These tests ensure that `wpdb::prepare()` throws a `_doing_it_wrong()` notice when called with an incorrect number of arguments, or with arguments of a wrong type.

PHP 8 introduces similar error messages natively, making these tests redundant on PHP 8.0 or later.

Follow-up to [41470], [41662].

See #50913.

git-svn-id: https://develop.svn.wordpress.org/trunk@48973 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-13 02:47:20 +00:00
Sergey Biryukov
1a89e63838 Tests: Replace the native PHPUnit getMockForAbstractClass() and getMockBuilder() methods.
This avoids parse errors in PHPUnit internals due to `match` being a reserved keyword in PHP 8.

To run on PHP 8, the tests relying on these methods require PHPUnit 9.3 or later.

When the test suite is updated for compatibility with PHPUnit 9.x, these overrides can be removed.

See #50913, #50902.

git-svn-id: https://develop.svn.wordpress.org/trunk@48972 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-13 02:36:48 +00:00
Sergey Biryukov
9066eb15a2 Coding Standards: Explicitly declare the $wp_version global used in some core files.
Props jaydeep-rami, sabernhardt.
Fixes #44932.

git-svn-id: https://develop.svn.wordpress.org/trunk@48971 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-12 00:10:16 +00:00
Sergey Biryukov
2c843f03d5 Coding Standards: Use strict comparison in wp-admin/includes/class-wp-plugin-install-list-table.php.
See #50767.

git-svn-id: https://develop.svn.wordpress.org/trunk@48970 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-11 01:03:54 +00:00
Helen Hou-Sandi
b8e4f37a57 REST API: Include attribute name in schema validation error message.
Props bobbingwide.
Fixes #51231.


git-svn-id: https://develop.svn.wordpress.org/trunk@48969 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-10 16:32:52 +00:00
Sergey Biryukov
c0570b1398 Coding Standards: Use strict comparison in wp-admin/includes/class-wp-plugins-list-table.php.
See #50767.

git-svn-id: https://develop.svn.wordpress.org/trunk@48968 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-10 14:20:08 +00:00
Sergey Biryukov
54f62fc234 Coding Standards: Use strict comparison in wp-admin/includes/class-wp-ms-themes-list-table.php.
See #50767.

git-svn-id: https://develop.svn.wordpress.org/trunk@48967 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-10 14:19:35 +00:00
John Blackbourn
db9a91a2a8 Posts, Post Types: Don't output the adjacent posts rel link by default.
This has a considerable performance impact on sites which don't otherwise show previous and next post links, and has no SEO benefit.

Props joostdevalk, swissspidy, johnbillion

Fixes #39111

git-svn-id: https://develop.svn.wordpress.org/trunk@48966 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-09 21:32:07 +00:00
Helen Hou-Sandi
19bdc1e3f9 Privacy: Remove extraneous colon from settings screen.
Props vinita29, garrett-eclipse.
Fixes #50414.


git-svn-id: https://develop.svn.wordpress.org/trunk@48965 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-09 19:41:07 +00:00
Jonathan Desrosiers
0548043076 Site Health: Allow attachments to be added to recovery mode emails.
The `wp_mail()` function has the ability to add attachments to emails. There is currently no way to add attachments to the recovery mode email sent out to site admins when a PHP error is encountered on their site.

This change adds that ability through the use of the `recovery_mode_email` filter, allowing developers to use the full capabilities of `wp_mail()`.

Props desrosj, timothyblynjacobs.
Fixes #51276.

git-svn-id: https://develop.svn.wordpress.org/trunk@48964 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-09 16:19:33 +00:00
Jonathan Desrosiers
2c6df53917 Administration: Add the aria-hidden attribute to admin menu icons.
The admin menu icons are included as a visual element to support the text links. Without the `aria-hidden=“true”` attribute, they are also exposed to assistive technologies (which can process icon fonts in unpredictable ways).

This change improves the experience for multiple types of assistive technologies, including screen reading and voice control software. With `aria-hidden=“true”` added, the icons will not be read, and a user can now trigger a click of a top level admin menu item with commands such as “click posts”, or “click plugins”.

Props joedolson, afercia, audrasjb, adriantirusli.
Fixes #51012.

git-svn-id: https://develop.svn.wordpress.org/trunk@48963 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-09 16:13:17 +00:00
Jonathan Desrosiers
506c46593b Docs: Improve the recovery_mode_email inline docs.
See #51267, #50768.

git-svn-id: https://develop.svn.wordpress.org/trunk@48962 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-09 15:46:30 +00:00
Sergey Biryukov
875acd7b37 Code Modernization: Remove unnecessary reference sign from get_comment() definition.
This fixes a PHP 8 "argument must be passed by reference, value given" error when using `array_map( 'get_comment', ... )`.

Object variables in PHP 5+ contain a reference to the object, and it's the reference that's passed around.

Note: This reverts [48838], which is now redundant.

Follow-up to a similar change for `get_post()` in [21572].

See #50913.

git-svn-id: https://develop.svn.wordpress.org/trunk@48961 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-09 03:53:50 +00:00
Sergey Biryukov
f6f117a0a9 Code Modernization: Correct the check for negative post IDs in WP_Query::parse_query() to work as expected on PHP 8.
PHP 8 changes the way string to number comparisons are performed: https://wiki.php.net/rfc/string_to_number_comparison

In particular, checking if an empty string is less than zero in PHP 8 evaluates to `true`, not `false`.

For `WP_Query`, this resulted in unintentionally returning a 404 error for most of front-end requests, instead of the relevant content.

By explicitly casting the value to `int`, we make sure to compare both values as numbers, rather than a string and a number.

Follow-up to [38288].

Props trepmal.
See #50913.

git-svn-id: https://develop.svn.wordpress.org/trunk@48960 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-09 02:33:22 +00:00
Sergey Biryukov
427d72c8a1 Comments: Check if a valid comment ID was passed when editing a comment.
This avoids a PHP notice after submitting the Edit Comment form.

Props regan.khadgi.
Fixes #51263.

git-svn-id: https://develop.svn.wordpress.org/trunk@48958 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-08 13:39:41 +00:00
Sergey Biryukov
92bf360a03 Build/Test Tools: Allow unit tests to run on PHP 8 in full.
PHP 8 introduces a new control structure called `match`, which makes `match` a reserved keyword in PHP 8.

One of the PHPUnit dependencies declares a class named `Match`, which triggered a fatal error before PHPUnit could even start.

To be able to use PHPUnit 7.x on PHP 8 and run the tests, core needs a new version of that dependency, which is now installed using Composer.

This is the simplest way to get things working again and start addressing the individual test failures.

Additionally, various test runs on PHP 8 on Travis are now performed individually instead of being chained, so that failures outside of WP scope don't block further execution.

Props jrf, jorbin, pento.
See #50902.

git-svn-id: https://develop.svn.wordpress.org/trunk@48957 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-07 19:21:26 +00:00
Sergey Biryukov
a85d190b00 Tests: Replace a few instances of assertNotEquals() with assertNotFalse().
See #38266.

git-svn-id: https://develop.svn.wordpress.org/trunk@48954 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-07 04:11:54 +00:00
Sergey Biryukov
3a9e78c000 Tests: Remove the polyfill for assertNotFalse().
`assertNotFalse()` is available in PHPUnit since version 4.0.

The polyfill was introduced back when WordPress still supported PHP 5.2 and PHPUnit 3.6.x, and is now redundant.

Follow-up to [39919], [45058], [47880].

See #38266.

git-svn-id: https://develop.svn.wordpress.org/trunk@48953 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-07 03:26:24 +00:00