4042 Commits

Author SHA1 Message Date
Jonathan Desrosiers
9d70497b8b Build/Test Tools: Introduce the PHPUnit Polyfills package for easier cross branch testing.
This backports the PHPUnit Polyfills package and related test infrastructure changes to make it easier for developers to continue testing on multiple versions WordPress while adding tests for newer versions of PHP, which require more modern PHPUnit practices.

One of the changes included is the addition of wrappers for the new snake_case fixture methods in PHPUnit. This allows the native camelCase standard in PHPUnit to be used, but allows for developers to transition to the new naming conventions.

Props hellofromTonya, jrf, SergeyBiryukov, johnbillion, netweb, schlessera, jeherve, lucatume, desrosj.
Merges [51559,51560,51810-51813,51828] to the 5.7 branch.
See #53911.

git-svn-id: https://develop.svn.wordpress.org/branches/5.7@51839 602fd350-edb4-49c9-b593-d223f7449a82
2021-09-21 19:28:47 +00:00
Peter Wilson
a7c126747e XML-RPC: Set HTTP status code in accordance with the spec.
When the XML-RPC endpoint is enabled, always return a HTTP `200 OK` status code in accordance with the XML-RPC specification. Continue to return an HTTP `405 Method Not Allowed` status code when the endpoint is disabled.

Props ariskataoka, johnbillion.
Merges [50954] in to the 5.7 branch.
Fixes #52958.



git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50989 602fd350-edb4-49c9-b593-d223f7449a82
2021-05-25 05:18:54 +00:00
Jonathan Desrosiers
58d79a0458 REST API: Allow authors to read their own password protected posts.
Allow authenticated users to read the contents of password protected posts if they have the `edit_post` meta capability for the post.

Merges [50717] to the 5.7 branch.
Props xknown, zieladam, peterwilsoncc, swissspidy, timothyblynjacobs.

git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50718 602fd350-edb4-49c9-b593-d223f7449a82
2021-04-14 23:25:28 +00:00
Peter Wilson
8bf7643c4b Media: Do not lazy load hidden images or embeds.
Improve the check for sourceless or dimensionless media when determining if the lazy loading attribute should be added to iframes and images. Never include the lazy loading attribute on embeds of WordPress posts as the iframe is initially hidden.

Including `loading="lazy"` on initially hidden iframes and images can prevent the media from loading in some browsers.

Props adamsilverstein, fabianpimminger, flixos90, johnbillion, jonkastonka, joyously, peterwilsoncc, SergeyBiryukov, SirStuey, swissspidy.
Merges [50682], [50683] to the 5.7 branch.
Fixes #52768.



git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50684 602fd350-edb4-49c9-b593-d223f7449a82
2021-04-07 01:50:59 +00:00
Sergey Biryukov
ac89f69207 REST API: Correct enum validation for numeric values.
When validating `enum` values as `integer` or `number`, consider a number with a zero fractional part to be equivalent to an integer of the same value.

In `rest_are_values_equal()`, when comparing two values of type `int` or `float` (in any combination), first cast both of them to `float` and then compare.

This matches some test cases from the official JSON Schema test suite.

Follow-up to [50010].

Props yakimun, stefanjoebstl, TimothyBlynJacobs, rachelbaker.
Merges [50653] to the 5.7 branch.
Fixes #52932.

git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50656 602fd350-edb4-49c9-b593-d223f7449a82
2021-04-04 19:11:07 +00:00
Jonathan Desrosiers
4ba7f55796 Build/Test Tools: Backport several build tool fixes & improvements.
This backports a handful of test fixes related to generating code coverage reporting, as well as some `devDependency` updates.

Backports [50591-50595,50597-50598] to the 5.7 branch.
See #52624, #52786, #51734.

git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50601 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-26 16:07:38 +00:00
Jonathan Desrosiers
c2e97f26f4 Revert [50599].
Unprops desrosj.

git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50600 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-26 15:54:07 +00:00
Jonathan Desrosiers
0559bf34cf git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50599 602fd350-edb4-49c9-b593-d223f7449a82 2021-03-26 15:50:36 +00:00
Peter Wilson
84dc8fce67 Robots: Remove contradictory directive check in wp_robots().
Removes the mutually exclusive directives check in `wp_robots()`, ie allow both `follow` and `nofollow` to be specified and for `archive` and `noarchive` to be specified.

This fixes a bug in which WordPress would defer to the most permissive over the least permissive. When contradictory instructions are included, WordPress will defer to the search engine's or archivist's resolution policy: generally this is to observe the least, not most permissive.

Props Cybr, flixos90, SergeyBiryukov.
Merges [50566] to the 5.7 branch.
Fixes #52713.


git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50587 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-26 00:26:55 +00:00
Peter Wilson
7e66aefa7f REST API: Prevent database error when deleting meta data.
Add a check to `WP_REST_Meta_Fields::delete_meta_value()` ensuring meta data is set before attempting to delete it from the database. If the data does not exist, the delete is considered successful as the data matches the desired state.

Props BrechtVds, goaroundagain, TimothyBlynJacobs.
Merges [50567] to the 5.7 branch.
Fixes #52787.


git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50573 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-25 00:02:35 +00:00
Jonathan Desrosiers
64444cd67e Build/Test Tools: Ensure the test_php_and_js_shortcode_attribute_regexes_match() test can run when testing using either the src or build directory.
Reviewed by desrosj, johnbillion.
Props alexstine, desrosj.
Merges [50501] to the 5.7 branch.
Fixes #51734.

git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50509 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-08 15:14:30 +00:00
Robert Anderson
e68cc485ab Editor: Update @wordpress npm packages
Update @wordpress npm packages to the latest published versions. This includes
block editor bug fixes for WordPress 5.7 RC 3.

See #52718.


git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50497 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-05 04:11:36 +00:00
Sergey Biryukov
da266e6ca5 Security, Site Health: Do not store HTTPS request error messages in an option.
This changes the logic in `update_https_detection_errors()` to never store error messages from the actual request since they could use a different encoding, which would make storing them in an option potentially fail, leading WordPress to then falsely assume that HTTPS is supported.

While this doesn't actually fix the encoding issue, it is not crucial to do so anyway, since these messages are not used anywhere. A simple differentiation between whether the overall HTTPS request or only the SSL verification failed should be sufficient for the purpose of this function.

Props flixos90, tmatsuur, lukecarbis.
Reviewed by flixos90, SergeyBiryukov.
Merges [50471] to the 5.7 branch.
Fixes #52484.

git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50472 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-02 15:14:09 +00:00
John Blackbourn
cc13009e99 Build/Test Tools: PHPUnit test improvements:
* Switch back to running the PHPUnit test suite against the `src` directory instead of `build`
* Increase the reliability of backing up the `mu-plugins` directory during tests
* Split the PHPUnit tests for PHP versions below 7.0 in half, allowing them to run in parallel and reduce the overall test run duration on GitHub Actions

Merges [50441-50444] to the 5.7 branch.

Fixes #51734, #51735, #52645


git-svn-id: https://develop.svn.wordpress.org/branches/5.7@50464 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-01 20:21:23 +00:00
Peter Wilson
db9c95a056 Security: move Content-Security-Policy script loaders.
Move `wp_get_script_tag()`, `wp_print_script_tag()`, `wp_print_inline_script_tag()` and `wp_get_inline_script_tag()` functions from `functions.php` to `script-loader.php`.

Relocate related tests to `dependencies` sub-directory.

Follow up to [50167].
Props adamsilverstein, hellofromTonya, SergeyBiryukov.
Fixes #39941.


git-svn-id: https://develop.svn.wordpress.org/trunk@50409 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-23 01:58:21 +00:00
Peter Wilson
50639dbad6 Script Loader: Prevent wp_localize_script() warnings.
Prevent `wp_localize_script()` (via `WP_Scripts::localize()`) throwing warnings in PHP 8 when the translation data is passed as a string. This maintains backward compatibility with earlier versions of PHP.

Introduce a `_doing_it_wrong()` notice to `WP_Scripts::localize()` if the translation data is not passed as an array.

Props jrf, peterwilsoncc, SergeyBiryukov.
Fixes #52534.


git-svn-id: https://develop.svn.wordpress.org/trunk@50408 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-22 23:21:56 +00:00
Sergey Biryukov
6479ea9af8 Embeds: Allow posts with a public custom post status to be embedded.
Previously, only posts with the `publish` status could be embedded.

Props goaroundagain, peterwilsoncc, poena.
Fixes #47574.

git-svn-id: https://develop.svn.wordpress.org/trunk@50401 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-22 13:21:26 +00:00
John Blackbourn
66504ce36e Posts, Post Types: Rename the new post parent conditional tag functions for clarity.
* `get_parent_post()` becomes `get_post_parent()`
* `has_parent_post()` becomes `has_post_parent()`

Props johnjamesjacoby, SergeyBiryukov, lukecarbis, peterwilsoncc

Fixes #33045


git-svn-id: https://develop.svn.wordpress.org/trunk@50396 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-20 17:43:55 +00:00
John Blackbourn
3f705da1f2 Cron API: Add a missing $wp_error parameter to the pre_reschedule_event filter.
Props tmatsuur, mukesh27

Fixes #52572
See #49961


git-svn-id: https://develop.svn.wordpress.org/trunk@50394 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-20 12:09:45 +00:00
Sergey Biryukov
77a7160821 Tests: Fix typo in one of wp_resource_hints() test method names.
Add `@ticket` reference.

Follow-up to [38100].

See #51802.

git-svn-id: https://develop.svn.wordpress.org/trunk@50392 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-20 09:52:14 +00:00
Felix Arntz
c8bbd79d2d Security: Fix bug in wp_is_local_html_output().
Prior to this changeset, the check for the correct RSD link output was relying on a specific protocol, although it needs to accept both the HTTP and HTTPS version of the URL.

Props TimothyBlynJacobs.
Fixes #52542. See #47577.


git-svn-id: https://develop.svn.wordpress.org/trunk@50391 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-19 21:11:02 +00:00
Sergey Biryukov
d8da8a3619 Tests: Rename stick_post() and unstick_post() tests for a bit more clarity.
Add missing DocBlock for `test_unstick_post_updates_option()`.

Follow-up to [50380].

See #52007.

git-svn-id: https://develop.svn.wordpress.org/trunk@50384 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-18 12:02:42 +00:00
Peter Wilson
d79722b09f Editor: Additional tests for reusable blocks.
Ensure that subsequent renders of a reusable block will render correctly and that recursively inserting a reusable block into itself does not cause an internal server (500) error.

Props bernhard-reiter, SergeyBiryukov.
Fixes #52364.



git-svn-id: https://develop.svn.wordpress.org/trunk@50382 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-18 01:11:18 +00:00
Peter Wilson
50af962653 Posts/Post Types: Prevent duplicates in sticky posts option.
In `unstick_post()` if a post ID is duplicated in the `sticky_posts` option remove all instances.

In both `stick_post()` and `unstick_post()` check for duplicate IDs already stored in the `sticky_post` option and remove them if the option is updated.

Props rahmohn, archon810.
Fixes #52007.


git-svn-id: https://develop.svn.wordpress.org/trunk@50380 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-17 22:56:34 +00:00
John Blackbourn
910c2db68a Comments: Revert the introduction of the opt-in comment approval notification feature.
This reverts the following commits: [50113], [50112], [50109].

See #33717


git-svn-id: https://develop.svn.wordpress.org/trunk@50375 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-17 13:06:43 +00:00
Peter Wilson
f400eb5ab9 General: Add noindex robots meta tag to search results.
Prevent search engines indexing internal search results to protect against reflected web spam attacks.

Props abagtcs, audrasjb, ayeshrajans, burtrw, johnbillion, jonoaldersonwp, peterwilsoncc, poena, sabernhardt, xkon.
Fixes #52457


git-svn-id: https://develop.svn.wordpress.org/trunk@50370 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-16 23:36:44 +00:00
John Blackbourn
22618cef9a Feeds: Fix the URL returned by get_feed_link() when pretty permalinks are not in use.
Props hauvong, peterwilsoncc, SergeyBiryukov

Fixes #51839


git-svn-id: https://develop.svn.wordpress.org/trunk@50354 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-16 17:32:58 +00:00
Sergey Biryukov
e50f46d49a Tests: Rename two classes in phpunit/tests/http/ to match the function names.
See #51802.

git-svn-id: https://develop.svn.wordpress.org/trunk@50345 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-15 14:05:42 +00:00
Sergey Biryukov
4e4b4de3be Tests: Add missing @covers tags for files in phpunit/tests/http/.
Props patopaiar, jrf.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@50344 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-15 14:00:02 +00:00
Sergey Biryukov
a17ae3dc0f Tests: Rename classes in phpunit/tests/hooks/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291], [50292].
See #51802.

git-svn-id: https://develop.svn.wordpress.org/trunk@50342 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-14 12:20:34 +00:00
Sergey Biryukov
8d1dfb6bcf Tests: Add missing @covers tags for files in phpunit/tests/hooks/.
Props patopaiar, jrf.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@50341 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-14 12:09:25 +00:00
Sergey Biryukov
cb623c351c Tests: Add missing @covers tags for files in phpunit/tests/general/.
Props patopaiar, jrf.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@50339 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-13 13:47:12 +00:00
Sergey Biryukov
3f50750a50 Tests: Simplify @covers tags in editor/wpEditors.php using @coversDefaultClass annotation.
Follow-up to [50288].

See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@50338 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-13 13:45:23 +00:00
Sergey Biryukov
f626e2897b Tests: Use @ticket annotation for ticket numbers, for clarity.
See #51802.

git-svn-id: https://develop.svn.wordpress.org/trunk@50337 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-13 12:17:36 +00:00
gziolo
e794cb23a8 Tests: Fix failing unit test for block settings
Follow-up to [50297].

Fixes #52512.




git-svn-id: https://develop.svn.wordpress.org/trunk@50300 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-12 16:39:01 +00:00
Sergey Biryukov
ae1a9ba8db Tests: Rename some files and classes in phpunit/tests/general/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327], [50291].

See #51802.

git-svn-id: https://develop.svn.wordpress.org/trunk@50292 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-11 21:38:30 +00:00
Sergey Biryukov
88567c5bae Tests: Rename some classes in phpunit/tests/date/ per the naming conventions.
https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization

Follow-up to [47780], [48911], [49327].

See #51802.

git-svn-id: https://develop.svn.wordpress.org/trunk@50291 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-11 21:20:41 +00:00
Sergey Biryukov
835066933b Tests: Add missing @covers tags for files in phpunit/tests/external-http/.
Props patopaiar, jrf.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@50290 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-11 20:53:51 +00:00
Sergey Biryukov
5b3cb96ce0 Tests: Add missing @covers tags for files in phpunit/tests/error-protection/.
Props patopaiar, jrf.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@50289 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-11 20:53:19 +00:00
Sergey Biryukov
f184ef4b6c Tests: Add missing @covers tags for files in phpunit/tests/editor/.
Props patopaiar, jrf.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@50288 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-11 20:52:52 +00:00
Sergey Biryukov
c49e14bd7b Tests: Add missing @covers tags for files in phpunit/tests/dependencies/.
Props patopaiar, jrf.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@50287 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-11 15:15:37 +00:00
Sergey Biryukov
a4617592cb Tests: Add missing @covers tags for files in phpunit/tests/db/.
Props patopaiar, jrf.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@50286 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-11 14:02:42 +00:00
Sergey Biryukov
3d259c2b22 Tests: Use assertSame() in some newly introduced tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Follow-up to [49904], [49925], [49992], [50012], [50013], [50065], [50075], [50131], [50150], [50157].

See #38266, #52482.

git-svn-id: https://develop.svn.wordpress.org/trunk@50284 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-10 13:24:24 +00:00
Sergey Biryukov
62d5c54b67 Tests: Replace most instances of assertEquals() in phpunit/includes/ with assertSame().
Follow-up to [48937], [48939], [48940], [48944].

Props johnbillion, jrf, SergeyBiryukov.
See #38266, #52482.

git-svn-id: https://develop.svn.wordpress.org/trunk@50283 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-10 13:23:42 +00:00
Peter Wilson
f9b901549b Canonical: Rename wp_force_plain_ugly_permalink() to match UI terminology.
Rename `wp_force_plain_ugly_permalink()` to `wp_force_plain_post_permalink()` to match terminology used in the WordPress dashboard.

Follow up to [50132].
Props SergeyBiryukov.
Fixes #5272.



git-svn-id: https://develop.svn.wordpress.org/trunk@50282 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-10 05:38:23 +00:00
Sergey Biryukov
def10f619b Tests: Add missing @covers tags for files in phpunit/tests/date/.
Props patopaiar, jrf.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@50279 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-09 19:55:35 +00:00
Sergey Biryukov
6b7a708fa1 Tests: Correct the test for NOT BETWEEN comparison operator in WP_Date_Query.
Follow-up to [29793].

Props patopaiar, jrf.
See #39265, #51802.

git-svn-id: https://develop.svn.wordpress.org/trunk@50276 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-09 18:08:07 +00:00
John Blackbourn
b4f354d524 Build/Test Tools: Various docblock improvements within test utilities.
See #51802


git-svn-id: https://develop.svn.wordpress.org/trunk@50265 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-09 13:22:47 +00:00
Robert Anderson
385c29b49a Fix wp.i18n.isRTL()
Fixes a bug causing wp.i18n.isRTL() to return false in RTL langauges by manually
loading the translated 'ltr' string for the i18n dependency. This ports over an
identical fix that was made in Gutenberg.

Fixes #52441.
Props @jonsurrell @youknowriad.


git-svn-id: https://develop.svn.wordpress.org/trunk@50259 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-08 23:49:33 +00:00
Sergey Biryukov
73b353ef95 Privacy: Rename the $send_confirmation_email parameter of wp_create_user_request() to $status, for clarity.
Follow-up to [50159], [50165].

Props xkon, TimothyBlynJacobs.
Fixes #52430. See #43890.

git-svn-id: https://develop.svn.wordpress.org/trunk@50230 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-05 15:48:59 +00:00