Commit Graph

3082 Commits

Author SHA1 Message Date
Sergey Biryukov 4b8e33fbee Build/Test Tools: Move `WP_UnitTestCase_Base::assertPostConditions()` to a more appropriate place.
See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44719 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-30 14:30:42 +00:00
Felix Arntz 0612ea2d38 Bootstrap/Load: Revert fatal error recovery mechanism from 5.1 to polish for 5.2.
Due to the high number of follow-up tickets and associated security concerns, it was decided to reschedule the fatal error recovery feature for WordPress 5.2, in order to address these issues properly. The feature will continue to be developed, with iterations being merged into trunk early in the 5.2 release cycle.

Fixes #46141. See #44458, #45932, #45940, #46038, #46047, #46068.


git-svn-id: https://develop.svn.wordpress.org/trunk@44717 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-30 11:00:30 +00:00
Sergey Biryukov b9b66b159b Build/Test Tools: Simplify `WP_PHPUnit_Util_Getopt` and update documentation.
Introduced in [918/tests] and updated in [26871], the class is there to make sure that known bugs are not skipped when `phpunit` is called with a `--group` that corresponds to an `@ticket` annotation (such as `phpunit --group 12345`).

Enforcing recognized arguments or correctly formed arguments is not the concern here, so reusing `PHPUnit_Util_Getopt::parseLongOption()` was superfluous.

See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44715 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-30 00:53:52 +00:00
Peter Wilson 99450a446d Customize: Remove `wp_targeted_link_rel` pre-save filter from change-sets.
The pre-save filters added to links in [43732] could invalidate JSON data when saving Customizer change-sets.

This removes the filters when saving and publishing change-sets.

Props peterwilsoncc, nikeo for testing.
See #45292.



git-svn-id: https://develop.svn.wordpress.org/trunk@44714 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-29 21:28:57 +00:00
Gary Pendergast 9efcfbbf3f Tests: Fix the tests for the `c` and `r` formats in `date_i18n()`.
To test the `date_i18n()` output correctly, the tests added in [43434] need to set a non-UTC timezone.

Props Rarst.
Fixes #20973.



git-svn-id: https://develop.svn.wordpress.org/trunk@44710 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-29 01:19:30 +00:00
Sergey Biryukov 6e80f7cebf Build/Test Tools: Don't throw an exception for unrecognized options in `WP_PHPUnit_Util_Getopt::parseLongOption()`.
The method is only used for two known options: `group` and `exclude-group`, others should be passed to PHPUnit.

Props johnbillion.
See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44707 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-28 18:49:22 +00:00
Sergey Biryukov ad71116f38 Coding Standards: Replace spaced indentation sections of `phpunit.xml.dist`, `multisite.xml`, and `build.xml` with tabs.
Props netweb, desrosj.
See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44705 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-28 17:20:06 +00:00
Sergey Biryukov e4813189c3 Build/Test Tools: Reorder `<file>` and `<exclude>` rules in `multisite.xml` to avoid warnings in PHPUnit 7.2+.
Missed in [44702].

See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44704 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-28 17:19:14 +00:00
Sergey Biryukov 48070a45a9 Build/Test Tools: Correct `WP_Test_REST_Schema_Sanitization::test_type_string()` to check for both `1.1` float and `'1.10'` string explicitly.
Previously, the test only passed due to a bug in PHPUnit 7.1.x and older versions.

Fixes #43218. See #38586.

git-svn-id: https://develop.svn.wordpress.org/trunk@44703 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-28 16:53:14 +00:00
Sergey Biryukov 001c6498e8 Build/Test Tools: Add support for PHPUnit 7.x.
* Create an abstract `WP_UnitTestCase_Base` class to share between PHPUnit 7.x and older versions.
* Add a speed-trap loader to determine which `SpeedTrapListener` class needs to be loaded for the current PHPUnit version.
* Remove unnecessary `PHPUnit\Util\Test` and `PHPUnit_Util_Getopt` inheritances.
* Update Travis CI config to use PHPUnit 7.x for PHP 7.1, 7.2, and nightly PHP versions.

Props jipmoors, netweb, desrosj, ayeshrajans, soulseekah, SergeyBiryukov.
See #43218.

git-svn-id: https://develop.svn.wordpress.org/trunk@44701 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-28 14:10:24 +00:00
Peter Wilson 554ee5b53c Cron: Move logic for finding the next event's timestamp.
Moves the logic for determining when an event will next run from `wp_next_scheduled()` to `wp_get_scheduled_event()`.

This improves the performance of `wp_get_scheduled_event()` by avoiding duplicate function calls and object cache hits.

Props peterwilsoncc.
Fixes #45976.


git-svn-id: https://develop.svn.wordpress.org/trunk@44693 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-23 23:07:39 +00:00
Peter Wilson bb463b5265 Formatting: Prevent `wp_targeted_link_rel()` adding an empty attribute.
Bypass adding a `rel` attribute when the `wp_targeted_link_rel` filter returns an empty string or other falsy result.

Props mcmwebsol, spartank, meatman89fs.
Fixes #45352.


git-svn-id: https://develop.svn.wordpress.org/trunk@44691 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-22 21:54:26 +00:00
Felix Arntz fbe0605156 Bootstrap/Load: Fix fatal error when passing a `WP_Error` to `wp_die()`.
This was introduced in [44466]. Also, this changeset adds tests for `_wp_die_process_input()` so that this never happens again.

Props dd32.
See #45933.


git-svn-id: https://develop.svn.wordpress.org/trunk@44690 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-22 08:51:56 +00:00
Sergey Biryukov 44ce02e28a PHPCS: Fix formatting issues introduced in [44670].
See #44914.

git-svn-id: https://develop.svn.wordpress.org/trunk@44672 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-21 19:56:47 +00:00
Sergey Biryukov 8fe01c0621 Post Formats: Prevent Bulk Edit from unintentionally changing post format to Standard even if set to "No change".
Correct the logic in [41187].

Props birgire, mukesh27, lanche86.
Fixes #44914. See #41396.

git-svn-id: https://develop.svn.wordpress.org/trunk@44670 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-21 18:04:55 +00:00
Peter Wilson 7d8ce1e287 Options: Avoid unnecessary DB calls when updating network options.
Adds a `maybe_serialize()` comparison for the old and new values in `update_network_option()` to avoid unnecessary database writes when options contain identical objects.

Props bor0.
Fixes #44956.



git-svn-id: https://develop.svn.wordpress.org/trunk@44662 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-21 04:26:33 +00:00
Gary Pendergast 9dfde992ee Comments: Show the "awaiting moderation" message when comment cookies are disabled.
The "Your comment is awaiting moderation." message relied upon the comment author cookie being set. However, since it's now possible to opt-out of that cookie, submitting a comment won't show the comment preview when the comment is placed in moderation.

To avoid this issue, we now include a hash in the redirect URL, allowing the site to identify that a preview of the moderated comment should be displayed.

Props imath, tomdxw, birgire, lakenh, azaozz, pento.
Fixes #43857.



git-svn-id: https://develop.svn.wordpress.org/trunk@44659 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-21 01:33:50 +00:00
Gary Pendergast 19645a4790 Tests: Add tests for the `__return*()` functions.
Props pbearne, mukesh27.
Fixes #46043.



git-svn-id: https://develop.svn.wordpress.org/trunk@44658 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-21 00:32:33 +00:00
Andrea Fercia 6dde7cd74f Build/Test Tools: Update QUnit index file after [43174].
Updates the last occurrence of "(opens in a new window)" to "(opens in a new tab)".

See #43803.


git-svn-id: https://develop.svn.wordpress.org/trunk@44655 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-19 15:27:11 +00:00
Gary Pendergast 2ec6c8f3d3 Build Tools: Upgrade WPCS to 2.0.0.
A few sniffs have been renamed, this change includes the relevant `phpcs:ignore` comment updates.

Fixes #46002.



git-svn-id: https://develop.svn.wordpress.org/trunk@44645 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-18 02:14:24 +00:00
Gary Pendergast d3ee420c14 Emoji: Upgrade Twemoji to 11.2.0.
This upgrade includes general improvements to the style of a variety of emoji.

Full changelog: https://github.com/twitter/twemoji/compare/v11.0.0...v11.2.0

Props desrosj, pento.
Fixes #45133.



git-svn-id: https://develop.svn.wordpress.org/trunk@44644 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-18 01:41:41 +00:00
Jonathan Desrosiers 3e390cdf9b Tests: Do not include the delimiter parameter in `ucwords()` calls.
This parameter is not supported in PHP < 5.4. Introduced in [44641].

See #44672.

git-svn-id: https://develop.svn.wordpress.org/trunk@44642 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-17 21:44:30 +00:00
Jonathan Desrosiers 83cfc77500 REST API: Allow a user to change the letter casing of their email.
When a `PUT` request is performed to update a user, a `rest_user_invalid_email` error is incorrectly being returned when the email exists with different letter casing, even if it belongs to the user being updated. `email_exists()` performs a case insensitive lookup, but the conditional statement following that lookup was performing a strict comparison between the new email and the user’s current email.

This changes that comparison to instead compare the user ID returned by `email_exists()` with the user ID being updated. This more closely matches the logic used in `edit_user()` and allows a user to change the letter casing of their email.

Props fuchsws, rachelbaker, desrosj.
Fixes #44672.

git-svn-id: https://develop.svn.wordpress.org/trunk@44641 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-17 21:24:47 +00:00
Gary Pendergast bcba20dd2b Docs: Fix the last handful of incorrect `@since 5.0.0` docblock tags.
Props peterwilsoncc.
Fixes #45543.



git-svn-id: https://develop.svn.wordpress.org/trunk@44635 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-17 06:45:58 +00:00
Gary Pendergast 2e63f69564 Tests: Ensure meta keys are cleaned up after each test.
Props jnylen0.
Fixes #46007.



git-svn-id: https://develop.svn.wordpress.org/trunk@44633 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-17 04:33:42 +00:00
Jonathan Desrosiers 06371823e3 Privacy: Allow column sorting in the privacy request admin tables.
This allows users to sort the export and erase personal data request tables by “Requester” (`post_title`, or user email) and “Requested” (`post_date`, or when the request was created), which can be helpful when sites have many requests present.

Props birgire, ianbelanger, pbiron, desrosj.
Fixes #43405.

git-svn-id: https://develop.svn.wordpress.org/trunk@44628 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-16 17:51:56 +00:00
Gary Pendergast afa551294e Formatting: Add type checking to `_sanitize_text_fields()`.
When a non-string value is passed, return an empty string.

Props Mte90.
Fixes #41450.



git-svn-id: https://develop.svn.wordpress.org/trunk@44618 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-16 06:04:51 +00:00
Gary Pendergast e79bddcb02 Users: Add extra checking to `wp_new_user_notification()`.
Prevent a notification from being sent when an unrecognised value is passed in the `$notify` parameter.

Props cthreelabs, 360zen.
Fixes #44293.



git-svn-id: https://develop.svn.wordpress.org/trunk@44611 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-16 04:26:48 +00:00
Gary Pendergast f418ee12b1 Link Template: In `get_adjacent_post()`, move the sanitisation of `$excluded_terms` earlier.
This is a followup to [42828], ensuring that the `get_{$adjacent}_post_excluded_terms` filter is always passed an array, as expected.

Props soulseekah, zottto.
Fixes #43521.



git-svn-id: https://develop.svn.wordpress.org/trunk@44591 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-15 01:53:02 +00:00
Gary Pendergast 5cdc0e1397 Query: Cache the result when `get_pages()` doesn't find anything in the database.
Props flixos90, soulseekah.
Fixes #43514.



git-svn-id: https://develop.svn.wordpress.org/trunk@44587 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-14 23:26:20 +00:00
Jonathan Desrosiers dd85c357d8 Tests: Add missing `parent::tearDown()`.
Also, remove a `tearDown()` method that was not serving any purpose.

Fixes #45931.

git-svn-id: https://develop.svn.wordpress.org/trunk@44584 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-14 21:33:56 +00:00
Gary Pendergast 065e7817c4 Customizer: Fix a coding standards issue introduced in [44580].
See #40020.




git-svn-id: https://develop.svn.wordpress.org/trunk@44582 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-14 07:22:03 +00:00
Gary Pendergast f5f5da1fff Customizer: Improve browser compatibility of the preview iframe.
When `home` and `siteurl` are different, the customizer preview iframe will be blank in Chrome and Safari, due to their `X-Frame-Options` implementation quirks.

Changing this to `SAMEORIGIN` and adding the `frame-ancestors` Content Security Policy gives the correct behaviour.

Props fullyint.
Fixes #40020.



git-svn-id: https://develop.svn.wordpress.org/trunk@44580 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-14 06:37:30 +00:00
Gary Pendergast 4550488c99 Widgets: Don't log invalid HTML in the Text Widget.
[41215] supresses these irrelevant error messages from the front end, this removes them from the error log, too.

Props jeherve.
Fixes #43815.



git-svn-id: https://develop.svn.wordpress.org/trunk@44578 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-14 05:04:12 +00:00
Gary Pendergast e547ecc791 Tests: Add missing `parent::setUp()` calls to all test classes.
Props johnbillion, birgire.
Fixes #37375.



git-svn-id: https://develop.svn.wordpress.org/trunk@44577 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-14 04:54:01 +00:00
Gary Pendergast a139c8cbf7 Coding Standards: Fix and whitelist variable names.
From the `WordPress.NamingConventions.ValidVariableName` sniff, this commit fixes/whitelists all `NotSnakeCaseMemberVar`, `MemberNotSnakeCase`, and `StringNotSnakeCase` violations. It also fixes a handful of the `NotSnakeCase` violations.

See #45934.



git-svn-id: https://develop.svn.wordpress.org/trunk@44573 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-12 06:05:55 +00:00
Gary Pendergast ff53bd388c Coding Standards: Extract `extract()` from the codebase.
Of the last four instances of `extract()` occurring, three of them are removed by this commit, and the fourth is appropriately documented.

See #45934.



git-svn-id: https://develop.svn.wordpress.org/trunk@44569 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-12 03:19:23 +00:00
Jonathan Desrosiers 34e3de7b7f REST API: Encourage proper usage of `register_rest_route()`.
Calling `register_rest_route()` too early in the loading process has the potential to cause some unintentional problems and pitfalls. Because `register_rest_route()` calls `rest_get_server()` (which creates the `WP_REST_Server` instance), calling the function directly and/or before `rest_api_init` should be discouraged.

For example, if `register_rest_route ()` is called on `init`, the REST API server instance is set up (and all functions added to `rest_api_init` and other related hooks are invoked), even though the current request may not be a REST request. Also, if `register_rest_route()` is called even earlier (say, in an `mu-plugin` file), required endpoints may be missing since normal plugins have not yet been loaded and have not had a chance to register their own action hooks.

This adds a `_doing_it_wrong()` notice the first time `register_rest_route()` is called before `rest_api_init` in a request to encourage best practices for registering REST API routes.

Props kraftbj, desrosj, timothyblynjacobs.
Fixes #45265.

git-svn-id: https://develop.svn.wordpress.org/trunk@44568 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-11 18:18:41 +00:00
Gary Pendergast 6f0487c2f0 Coding Standards: Ignore the violations of `Generic.NamingConventions.UpperCaseConstantName.ConstantNotUpperCase`.
See #45934.



git-svn-id: https://develop.svn.wordpress.org/trunk@44563 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-11 06:07:50 +00:00
Gary Pendergast 65f5fcb0fb Coding Standards: Ignore the single WordPress.PHP.RestrictedPHPFunctions.create_function_create_function violation.
This is intentional, for older PHP support.

See #45934.


git-svn-id: https://develop.svn.wordpress.org/trunk@44560 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-11 03:44:20 +00:00
Gary Pendergast 63fbf4a316 Coding Standards: Remove PHPCS 2.x `@codingStandardsIgnore*` ignore syntax.
Props netweb.
Fixes #42808.



git-svn-id: https://develop.svn.wordpress.org/trunk@44559 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-11 03:03:08 +00:00
Felix Arntz 6cc9452def General: Fix existing coding standard violations in bookmark tests, as outlined in [44546].
See #43977.


git-svn-id: https://develop.svn.wordpress.org/trunk@44547 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 21:16:49 +00:00
Felix Arntz 08564b5a80 General: Fix problematic string to array parsing.
WordPress has historically often used code like `preg_split( '/[\s,]+/', $var )` to parse a string of comma-separated values into an array. However, this approach was causing an empty string to not be parsed into an empty array as expected, but rather into an array with the empty string as its sole element.

This was among other areas causing problems in the REST API where passing an empty request parameter could cause that request to fail because, instead of it being ignored, that parameter would be compared against the valid values for it, which typically do not include an empty string.

Props david.binda, sstoqnov.
Fixes #43977.


git-svn-id: https://develop.svn.wordpress.org/trunk@44546 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 21:05:50 +00:00
Jonathan Desrosiers 2fe6670aff REST API: Restore use of `wp_ajax_ajax_tag_search()` for tag search.
This solution does not work with custom taxonomies in the current state.

Reverts [42614,42619,42737].

Props danielbachhuber.
See #38922.

git-svn-id: https://develop.svn.wordpress.org/trunk@44537 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 02:36:40 +00:00
Gary Pendergast 0394aab7a8 Tests: Add support for a `WP_TESTS_SKIP_INSTALL` environment variable.
Defining `WP_TESTS_SKIP_INSTALL=1` when running tests will skip the install step. While this shouldn't be used for full test runs, it's useful for saving time when running small groups of tests.

Props soulseekah.
Fixes #43432.



git-svn-id: https://develop.svn.wordpress.org/trunk@44536 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 02:18:19 +00:00
Jonathan Desrosiers 0161a5b70f Privacy: Add unit tests for privacy erasure fulfillment notifications.
Adds appropriate unit tests for `_wp_privacy_send_erasure_fulfillment_notification()`.

Props birgire, desrosj.
Fixes #44234.

git-svn-id: https://develop.svn.wordpress.org/trunk@44535 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 02:06:44 +00:00
Gary Pendergast e88eb4a63f Build/Tests: Allow running unit tests from `src`.
This is a partial recommit of [44509]: it allows running unit tests from `src` (which is useful), but doesn't make it the default (which Travis is having issues with).

See #45863.



git-svn-id: https://develop.svn.wordpress.org/trunk@44534 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 02:03:25 +00:00
Jonathan Desrosiers 25e9a6d249 Media: Store audio creation date in meta.
In [41746], `wp_get_media_creation_timestamp()` was introduced to read the created timestamp for videos from `getID3` in meta whenever possible. This information is useful separately from the dates on the file itself.

This adds the same support audio files by utilizing `wp_get_media_creation_timestamp()` in `wp_read_audio_metadata()`.

Props blob folio, desrosj.
Fixes #42017.

git-svn-id: https://develop.svn.wordpress.org/trunk@44528 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-10 01:31:52 +00:00
Felix Arntz ffd2a4bd16 Bootstrap/Load: Fix missing object argument for singular capability checks and support capability tests overlooked in [44524].
See #44458.


git-svn-id: https://develop.svn.wordpress.org/trunk@44525 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 20:43:57 +00:00
Pascal Birchler 1264df85b3 Build/Test Tools: Fix coding standards issues after [44515] and [44514].
See #44494, #43743.


git-svn-id: https://develop.svn.wordpress.org/trunk@44516 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-09 12:36:43 +00:00