Commit Graph

3232 Commits

Author SHA1 Message Date
Sergey Biryukov 67f7d1f4c7 Date/Time: Rewrite and simplify `date_i18n()` using `wp_timezone()` to address multiple issues with certain date formats and timezones, while preserving some extra handling for legacy use cases.
Improve unit test coverage.

Props Rarst, remcotolsma, raubvogel.
Fixes #25768.

git-svn-id: https://develop.svn.wordpress.org/trunk@45882 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-23 00:56:21 +00:00
Sergey Biryukov 4e129d1506 Date/Time: Use `wp_timezone()` in `WP_Date_Query::build_mysql_datetime()` to address timezone issues.
Improve unit test coverage.

Props Rarst, Biranit, birgire, jave.web, SergeyBiryukov.
Fixes #41782.

git-svn-id: https://develop.svn.wordpress.org/trunk@45876 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-22 03:10:05 +00:00
Sergey Biryukov 1ba44554be Users: Adjust [45708] to make sure `wp_update_user()` does not issue a `WP_Error` if a single site was previously set up as Multisite and there's still a `spam` field in the user table.
Add a unit test.

Props azaozz, SergeyBiryukov.
Fixes #45747.

git-svn-id: https://develop.svn.wordpress.org/trunk@45874 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-22 01:52:16 +00:00
Sergey Biryukov 7fbabd505d Administration: Adjust [45814] to address a backward compatibility issue for plugins passing multiple CSS classes to `add_settings_error()`.
Only add the `notice-` prefix for `error`, `success`, `warning`, `info` CSS classes, keep other classes as is.

Add unit tests for `settings_errors()`.

Props afercia, SergeyBiryukov.
Fixes #44941.

git-svn-id: https://develop.svn.wordpress.org/trunk@45873 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-22 00:21:49 +00:00
Sergey Biryukov d471151f45 Tests: Remove `$wpdb` global reference from `test_wp_insert_user_with_empty_data()`.
See #47902.

git-svn-id: https://develop.svn.wordpress.org/trunk@45859 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-20 17:27:17 +00:00
Sergey Biryukov 31a6309902 Users: In `wp_insert_user()`, account for the `wp_pre_insert_user_data` filter returning empty data.
Props juliobox, SergeyBiryukov.
Fixes #47902.

git-svn-id: https://develop.svn.wordpress.org/trunk@45858 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-20 17:25:02 +00:00
Sergey Biryukov 051aa3847c Date/Time: Fix race conditions in `current_time()` tests.
* Restore default timezone before performing assertions to avoid affecting other tests in case of failure.
* Use delta comparison for timestamps to avoid race conditions.

Props SergeyBiryukov, desrosj.
Fixes #45821.

git-svn-id: https://develop.svn.wordpress.org/trunk@45857 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-20 01:34:37 +00:00
Sergey Biryukov 91f60afbe5 Date/Time: Use PHP `DateTime` class API in `current_time()`.
Only use the legacy WP timestamp approach (a sum of timestamp and timezone offset) for `timestamp` and `U` formats without the `$gmt` flag.

Otherwise, make sure the function returns correct local time for any format.

Props Rarst, jdgrimes.
Fixes #40653.

git-svn-id: https://develop.svn.wordpress.org/trunk@45856 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-19 21:05:42 +00:00
Sergey Biryukov f5f2fc379e Coding Standards: Use long array syntax in `Tests_WP_Timezone::timezone_offset_provider()`.
Per https://make.wordpress.org/core/2019/07/12/php-coding-standards-changes/, arrays must be declared using long array syntax for clarity.

See #24730.

git-svn-id: https://develop.svn.wordpress.org/trunk@45855 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-19 21:05:25 +00:00
Sergey Biryukov 904b41e01c Date/Time: Introduce `wp_timezone_string()` and `wp_timezone()` for unified timezone retrieval.
* `wp_timezone_string()` retrieves the timezone from current settings as a string. Uses the `timezone_string` option to get a proper timezone if available, otherwise falls back to an offset.
* `wp_timezone()` retrieves the timezone from current settings as a `DateTimeZone` object. Timezone can be based on a PHP timezone string or a `±HH:MM` offset.

Props Rarst, remcotolsma, johnjamesjacoby, rmccue.
Fixes #24730.

git-svn-id: https://develop.svn.wordpress.org/trunk@45853 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-19 19:07:03 +00:00
Sergey Biryukov f2b6c12ddb Coding Standards: Fix WPCS violations in [45851].
See #25347.

git-svn-id: https://develop.svn.wordpress.org/trunk@45852 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-19 16:34:57 +00:00
Sergey Biryukov 896da178e0 Date/Time: In `wp_insert_post()`, when checking the post date to set `future` or `publish` status, use string comparison to work around far future dates (year 2038+) on 32-bit systems.
Props Rarst, nofearinc.
Fixes #25347.

git-svn-id: https://develop.svn.wordpress.org/trunk@45851 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-19 15:49:32 +00:00
Gary Pendergast 4e0499e5bf Tests: Add an xdebug group for tests that require xdebug.
These tests are now also run as their own part of the Travis build, to ensure performance of other tests isn't affected by the presence of xdebug.

Fixes #40532.



git-svn-id: https://develop.svn.wordpress.org/trunk@45827 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-19 02:17:50 +00:00
Sergey Biryukov 95c36ce5ba Privacy: Add descriptions for sections in a personal data export file.
Props garrett-eclipse, Venutius, karmatosed.
Fixes #45491.

git-svn-id: https://develop.svn.wordpress.org/trunk@45825 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-18 02:07:00 +00:00
K. Adam White 4bb45c674a Add @ticket annotations for [45812].
Props birgire.
See #43709.



git-svn-id: https://develop.svn.wordpress.org/trunk@45820 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-16 03:32:23 +00:00
K. Adam White 5a98103567 REST API: Add @ticket annotation to test from [45813].
Props birgire.
See #42209.


git-svn-id: https://develop.svn.wordpress.org/trunk@45815 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 23:08:31 +00:00
K. Adam White d65b89c5e4 REST API: Always return post types list in taxonomies endpoint response as an array.
Prevents a non-sequential post type array such as [ 0 => 'post', 2 => 'page' ] from being improperly converted to an object in the taxonomy endpoint's response JSON.

Props TimothyBlynJacobs, birgire, spectacula.
Fixes #42209.


git-svn-id: https://develop.svn.wordpress.org/trunk@45813 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 22:11:07 +00:00
K. Adam White 8f100777e8 REST API: Prevent deletion of post revisions.
Allowing the client to delete revisions breaks the "audit trail" functionality. This is not allowed in WordPress and shouldn't be allowed through the API.
While not recommended, a plugin may opt-in to the previous behavior by setting a custom 'delete_post' capability for the revisions post type.

Props dlh, danielbachhuber, TimothyBlynJacobs, azaozz, kadamwhite.
Fixes #43709.



git-svn-id: https://develop.svn.wordpress.org/trunk@45812 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 22:00:49 +00:00
K. Adam White eb468c4446 REST API: Cache results of get_item_schema on controller instances for performance.
Caches the output of get_item_schema() to avoid redundant recomputation of translatable strings and other computed values. This method is called many times per item in each REST request, and the results of the method should not vary between calls.
Additional schema fields are not cached.

Props kadamwhite, joehoyle, TimothyBlynJacobs.
Fixes #47871.


git-svn-id: https://develop.svn.wordpress.org/trunk@45811 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 21:08:05 +00:00
K. Adam White 80e44e49e2 REST API: Do not send response body if status is 204 or body is null.
Status code 204 should indicate no response body is sent. Previously, a "null" string was sent, which MacOS Safari would try to parse as JSON and thereby fail to complete the request.

Props TimothyBlynJacobs, andizer, matthias.thiel.
Fixes #43691.



git-svn-id: https://develop.svn.wordpress.org/trunk@45809 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 19:55:13 +00:00
K. Adam White 22480c035b REST API: Add test class file incorrectly omitted from [45807].
Props @TimothyBlynJacobs.
See #43392.


git-svn-id: https://develop.svn.wordpress.org/trunk@45808 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 17:20:02 +00:00
K. Adam White c92ef7c441 REST API: Support 'object' and 'array' types in register_meta() schemas.
Extends meta registration to support complex schema values, mirroring the functionality in the settings controller.
Error when trying to modify a meta key containing schema-nonconformant data.

Props @TimothyBlynJacobs, @birgire, @mnelson4, @flixos90.
Fixes #43392.



git-svn-id: https://develop.svn.wordpress.org/trunk@45807 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 17:16:21 +00:00
Peter Wilson 0d2b94a44a Site Health Check: New tests file missed in [45801].
git-svn-id: https://develop.svn.wordpress.org/trunk@45802 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-15 00:36:38 +00:00
Sergey Biryukov a2a28e4608 Widgets: Allow for short-circuiting widget output in `the_widget()` using the `widget_display_callback` filter, for consistency with output via a registered sidebar.
Props MarcGuay, donmhico.
Fixes #34226.

git-svn-id: https://develop.svn.wordpress.org/trunk@45798 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-14 23:02:25 +00:00
Sergey Biryukov a58eb86d5e Posts, Post Types: In `wp_trim_words()` make sure the `$num_words` parameter is always an integer, as documented, to avoid a PHP warning.
Props donmhico, pikamander2.
Fixes #47867.

git-svn-id: https://develop.svn.wordpress.org/trunk@45796 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-14 17:17:51 +00:00
Sergey Biryukov d4a305292f Users: Make `wp_list_authors()` unit tests more readable.
See #23498.

git-svn-id: https://develop.svn.wordpress.org/trunk@45795 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-14 15:35:19 +00:00
Peter Wilson feb0830c79 Comments: Include post permalink in comment reply link.
Include the post's permalink when generating reply links in `get_comment_reply_link()` to account for comments displayed on index and archive pages.

This reapplies [32786] which was inadvertently reverted in [42360].

Props justinahinon, donmhico.
See #33383.
Fixes #47174.


git-svn-id: https://develop.svn.wordpress.org/trunk@45787 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-13 05:08:14 +00:00
Gary Pendergast 13d356691b Build Tools: Miscellaneous `local-env` improvements.
- Move the functionality for controlling `local-env` out of `package.json`, into JS scripts.
- Merge the `docker-compose` config files, and move it to the root directory. This allows `docker-compose.override.yml` to work for local overrides.
- Fix nginx redirecting to port 80 under some circumstances.
- `npm run env:install` now creates `wp-tests.config.php` for you.
- Cleaned up a bunch of cruft in `.travis.yml`.

See #47767.



git-svn-id: https://develop.svn.wordpress.org/trunk@45783 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-12 08:28:33 +00:00
Gary Pendergast 4271f1aeca Build Tools: Switch all Travis PHPUnit jobs over to Docker-based PHP.
Additionally, there are a handful of related minor changes in this commit:
- `.travis.yml` has been tidied up a little.
- [45745] was incorrectly marking Travis jobs as passed when some PHPUnit runs failed.
- Add the `LOCAL_PHP_MEMCACHED` environment variable, for enabling Memcached.
- Add the `env:pull` NPM script, for refreshing Docker images.

See #47767.


git-svn-id: https://develop.svn.wordpress.org/trunk@45762 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-07 11:54:22 +00:00
Sergey Biryukov 4bbe1ab5a9 Coding Standards: Fix WPCS violation in [45754].
See #46570.

git-svn-id: https://develop.svn.wordpress.org/trunk@45755 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-05 18:09:20 +00:00
Sergey Biryukov fad1821dd7 General: Correctly detect large floats in `is_serialized()`.
Props killerbishop, donmhico, hoythan.
Fixes #46570.

git-svn-id: https://develop.svn.wordpress.org/trunk@45754 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-05 13:54:43 +00:00
Sergey Biryukov 6c78848612 Users: Clean user cache in `check_password_reset_key()` tests.
Props davidbaumwald, spacedmonkey.
See #45845.

git-svn-id: https://develop.svn.wordpress.org/trunk@45717 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-01 19:53:45 +00:00
Sergey Biryukov f912470ac3 Users: Use `wp_update_user()` in `get_password_reset_key()`.
Props jayswadas, spacedmonkey, donmhico, SergeyBiryukov.
Fixes #45746.

git-svn-id: https://develop.svn.wordpress.org/trunk@45714 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-01 17:24:20 +00:00
Sergey Biryukov 209a72c35a Coding Standards: Fix WPCS violations after [45708].
See #45747.

git-svn-id: https://develop.svn.wordpress.org/trunk@45709 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-01 12:02:30 +00:00
Sergey Biryukov 03122ef7e1 Users: Deprecate `update_user_status()` in favor of `wp_update_user()`.
Props spacedmonkey, SergeyBiryukov.
Fixes #45747.

git-svn-id: https://develop.svn.wordpress.org/trunk@45708 602fd350-edb4-49c9-b593-d223f7449a82
2019-08-01 11:27:28 +00:00
K. Adam White a875f9dae7 REST API: Skip processing fields which are not present in the selected context.
In `WP_REST_Controller::get_fields_for_response()`, exclude fields which are not registered to appear in the request's context.

In conjunction with r45705 this prevents the unnecessary computation of the sample permalink when making a request that is not context=edit.

Props dlh.
Fixes #45605.


git-svn-id: https://develop.svn.wordpress.org/trunk@45706 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-31 20:20:02 +00:00
Dominik Schilling 41dc7c7365 I18N: Following [45688], remove test for removed method.
See #44865.

git-svn-id: https://develop.svn.wordpress.org/trunk@45689 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-27 14:29:28 +00:00
Dominik Schilling 84b977945c I18N: Add support for custom `WP_PLUGIN_URL` in `load_script_textdomain()`.
Plugins may not be on the same host/path as the rest of the content. To support loading translations for this setup check if the script source matches `plugins_url()`.
Also fixes an undefined index notice when a custom content URL has no path.

Props odminstudios, ocean90.
Fixes #46336, #46387.

git-svn-id: https://develop.svn.wordpress.org/trunk@45685 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-27 12:43:56 +00:00
Gary Pendergast 4943b377ce Coding Standards: Move `wp-includes/class-oembed.php` to `wp-includes/class-wp-oembed.php`.
This renames the file containing the `WP_oEmbed` class to conform to the coding standards.

This commit also includes:

- A new `class-oembed.php` that includes the new file, for anyone that may've been including the file directly.
- Replaces references to the old filename with the new filename.

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45663 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-19 04:31:40 +00:00
Sergey Biryukov fd23000b11 Menus: Trim whitespace from custom link URLs.
Props majemedia, SergeyBiryukov.
Fixes #47723.

git-svn-id: https://develop.svn.wordpress.org/trunk@45655 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-17 18:44:56 +00:00
Gary Pendergast 8416a2b410 Coding Standards: Move `wp-admin/custom-header.php` to `wp-admin/includes/class-custom-image-header.php`
This renames the file containing the `Custom_Image_Header` class to conform to the coding standards.

This commit also includes:
- A new `custom-header.php` that includes the new file, for anyone that may've been including the file directly.
- Replaces references to the old filename with the new filename.

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45654 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-17 06:16:27 +00:00
Sergey Biryukov 2ae276c44f Media: Add a unit test for `wp_get_mime_types()`.
Props pbearne.
Fixes #47701.

git-svn-id: https://develop.svn.wordpress.org/trunk@45646 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-16 21:51:45 +00:00
Gary Pendergast 2da7f9f524 Code Modernisation: Fix known instances of array access on data types that can't be accessed as arrays.
PHP 7.4 addes a warning when trying access a null/bool/int/float/resource (everything but array, string and object) as if it were an array.

This change fixes all of these warnings visible in unit tests.

Props jrf.
See #47704.




git-svn-id: https://develop.svn.wordpress.org/trunk@45639 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-15 06:24:08 +00:00
Gary Pendergast c6c78490e2 Coding Standards: Fix the remaining issues in `/tests`.
All PHP files in `/tests` now conform to the PHP coding standards, or have exceptions appropriately marked.

Travis now also runs `phpcs` on the `/tests` directory, any future changes to these files must conform entirely to the WordPress PHP coding standards. 🎉

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45607 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-08 00:55:20 +00:00
Gary Pendergast 18ec05e23a Coding Standards: Fix all `WordPress.DB.PreparedSQLPlaceholders` issues.
See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45603 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-05 05:42:57 +00:00
Gary Pendergast 6acb0c6402 Coding Standards: Fix all `WordPress.WhiteSpace.PrecisionAlignment` issues.
See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45602 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-05 05:20:52 +00:00
Gary Pendergast a00c69458b Formatting: Revert the changes to `wpautop()` in [45585,45587].
See #27350.


git-svn-id: https://develop.svn.wordpress.org/trunk@45589 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-02 11:21:53 +00:00
Gary Pendergast fe28df65e3 Coding Standards: Fix the `Squiz.PHP.DisallowMultipleAssignments` violations in `tests`.
See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45588 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-02 04:43:01 +00:00
Gary Pendergast 8298f9dad0 Clean up stray `<p>` tags added by `wpautop()` inside block level tags.
`autop()` can sometimes get confused and not clean up stray `<p>` or `</p>` tags inside block level elements, which produces sub-optimal HTML. While browsers can generally handle it, there's no need to make things harder for them if we don't have to.

Props pento, ayubi, pbearne, jond, azaozz, 1994rstefan, dionysous, MikeHansenMe, jorbin, miqrogroove, niallkennedy.
Fixes #27350.




git-svn-id: https://develop.svn.wordpress.org/trunk@45585 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-02 01:30:15 +00:00
Adam Silverstein b97899a07f Taxonomy: add a new 'terms_pre_query' filter to short circuit WP_Term_Query 'get_terms' queries.
Add a new `terms_pre_query` filter which returns null by default. Return a non-null value to bypass WordPress's default `get_terms` queries.

Props jarocks, boonebgorges, spacedmonkey.
Fixes #41246.



git-svn-id: https://develop.svn.wordpress.org/trunk@45584 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-01 20:47:21 +00:00