Commit Graph

1918 Commits

Author SHA1 Message Date
Dominik Schilling a927a48b31 Unit tests: Don't change the `memory_limit` setting during tests.
40M isn't enough and can lead to an "out of memory" error. Change `test_wp_raise_memory_limit()` to test that `wp_raise_memory_limit()` doesn't *lower* the memory limit.

See [38015].
See #32075.

git-svn-id: https://develop.svn.wordpress.org/trunk@38016 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-08 18:16:07 +00:00
Dominik Schilling c68f1ec772 Bootstrap: Enhance core's memory limit handling.
* Don't lower memory limit if the current limit is greater than `WP_MAX_MEMORY_LIMIT`.
* Set `WP_MEMORY_LIMIT` and `WP_MAX_MEMORY_LIMIT` to current limit if the `memory_limit` setting can't be changed at runtime.
* Use `wp_convert_hr_to_bytes()` when parsing the value of the `memory_limit` setting because it can be a shorthand or an integer value.
* Introduce `wp_raise_memory_limit( $context )` to raise the PHP memory limit for memory intensive processes. This DRYs up some logic and includes the existing `admin_memory_limit` and `image_memory_limit` filters. The function can also be used for custom contexts, the `{$context}_memory_limit` filter allows to customize the limit.
* Introduce `wp_is_ini_value_changeable( $setting )` to determine whether a PHP ini value is changeable at runtime.
* Remove a `function_exists( 'memory_get_usage' )` check. Since PHP 5.2.1 support for memory limit is always enabled.

Related commits: [38011-38013]

Props jrf, A5hleyRich, swissspidy, ocean90.
Fixes #32075.

git-svn-id: https://develop.svn.wordpress.org/trunk@38015 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-08 14:36:37 +00:00
Dominik Schilling 629c6e36b5 Bootstrap: Clean up `wp_convert_hr_to_bytes()`.
* Don't return a value higher than `PHP_INT_MAX`.
* Add unit tests.

Props jrf.
See #32075.

git-svn-id: https://develop.svn.wordpress.org/trunk@38013 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-08 12:53:08 +00:00
Boone Gorges f41d3cff7d Tests: Ensure that test for invalid user ID actually uses an invalid user ID.
This prevents false positives when the ID column's incrementor has exceeded the
hardcoded invalid ID.

Fixes #37308.

git-svn-id: https://develop.svn.wordpress.org/trunk@38005 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-07 16:47:25 +00:00
Boone Gorges 9d34db0590 Comments: Cache results of `SELECT FOUND_ROWS()` query.
When comment IDs are fetched from the cache rather than the database,
the subsequent `SELECT FOUND_ROWS()` query will not return the correct value.
To avoid unnecessary queries, we cache the results of the `found_comments`
query alongside the comment IDs.

Props spacedmonkey.
Fixes #37184.

git-svn-id: https://develop.svn.wordpress.org/trunk@38001 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-07 14:26:21 +00:00
Sergey Biryukov eff1d5f58e Unit Tests: Add description for `data_get_comments_number_text_declension()`.
See #13651.

git-svn-id: https://develop.svn.wordpress.org/trunk@37997 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-07 10:44:57 +00:00
Jeremy Felt 4938acf349 Meta: Introduce an initial set of tests for `register_meta()`.
Props sc0ttkclark, ericlewis.
See #35658.


git-svn-id: https://develop.svn.wordpress.org/trunk@37995 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-07 00:14:40 +00:00
Ryan McCue 194c8d0e33 HTTP API: Switch back to returning an array.
The array-compatibility object we started returning in r37428 unfortunately isn't enough like an array. In particular, `is_array()` checks fail, despite the object implementing ArrayAccess. Mea culpa.

This moves the WP_HTTP_Response object to a new http_response key in the array, and changes the value back to an actual array.

Fixes #37097.
See #33055.


git-svn-id: https://develop.svn.wordpress.org/trunk@37989 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-06 17:50:44 +00:00
Sergey Biryukov 946e6ac8de I18N: Introduce an on/off switch for locales where comment number needs to be declined.
When enabled, the switch would override the theme's pseudo-plural `'% Comments'` string with a correct form of `_n( '%s Comment', '%s Comments', $number )`.

Historically, `comments_popup_link()` and `get_comments_number_text()` did not support plural forms and used a pseudo-plural style instead, so some locales were forced to come up with workarounds to display the number of comments in their language correctly.

This change should make those functions more i18n-friendly.

Fixes #13651.

git-svn-id: https://develop.svn.wordpress.org/trunk@37987 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-06 14:45:55 +00:00
Dominik Schilling 0037aa1dd5 Plugins: In `plugin_basename()` sort plugin paths before resolving symlinks.
`arsort()` sorts the paths reverse-alphabetically while preserving the keys. It results in a longer path being listed before a shorter one with the same base directory(ies).

Props jdgrimes, ocean90.
Fixes #28441.

git-svn-id: https://develop.svn.wordpress.org/trunk@37983 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-06 09:44:58 +00:00
Weston Ruter ad52e49e4f Customize: Ensure that `WP_Customize_Setting::value()` can return a previewed value for aggregated multidimensionals.
Fixes #37294.


git-svn-id: https://develop.svn.wordpress.org/trunk@37982 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-06 05:58:28 +00:00
Dominik Schilling 8a1fad3178 XML-RPC: Add unit test to verify IXR changes in [37244].
Props aaires.
Fixes #36586.

git-svn-id: https://develop.svn.wordpress.org/trunk@37980 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-05 21:58:41 +00:00
Dominik Schilling e34157ceb8 I18N: Add tests for `wp_maybe_decline_date()`.
Reverts [37718], `$wp_locale` needs to be cloned.

Props SergeyBiryukov.
Fixes #36790.

git-svn-id: https://develop.svn.wordpress.org/trunk@37975 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-05 16:09:01 +00:00
Dominik Schilling c259f4c35d General: Return "O B" when passing 0 to `size_format()`.
Props swissspidy.
Fixes #36635.

git-svn-id: https://develop.svn.wordpress.org/trunk@37962 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-05 10:35:24 +00:00
Dominik Schilling 1ae9f9c733 Unit Tests: Change some `@group` annotations to `@ticket`.
git-svn-id: https://develop.svn.wordpress.org/trunk@37954 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-04 20:24:52 +00:00
Dominik Schilling 2f90caa574 Nav Menus: In `Walker_Nav_Menu_Edit::start_el()` initialize `$original_title` with `false`.
Prevents displaying "Original:" without a title when adding a menu item without a title.

Props grapplerulrich, swissspidy.
Fixes #36729.

git-svn-id: https://develop.svn.wordpress.org/trunk@37953 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-04 20:15:48 +00:00
Dominik Schilling bc6e877446 Unit Tests: Remove `@group foo` annotation from `Tests_WP_Resource_Hints::test_dns_prefetch_styles()`.
git-svn-id: https://develop.svn.wordpress.org/trunk@37951 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-04 19:28:25 +00:00
Dominik Schilling f043ad7e02 Unit Tests: Remove an unused parameter from `Tests_Ajax_DimComment::test_with_bad_id()`.
Prevents a "too few arguments" error in PHP 7.1.0.

Fixes #37271.

git-svn-id: https://develop.svn.wordpress.org/trunk@37950 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-04 19:07:21 +00:00
Rachel Baker 855c081931 REST API: Reverse order of setting sanitization/validation, validating prior to sanitizing.
Fixes mistake in the current behavior, where the sanitization callback ran before the validation callback. Now the validation callback will run before the sanitization.

Props schlessera, rachelbaker.
See #37247.
Fixes #37192.




git-svn-id: https://develop.svn.wordpress.org/trunk@37943 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-02 23:02:45 +00:00
Weston Ruter c8ebbb3e0d Customize: Reverse order of setting sanitization/validation, validating prior to sanitizing.
Reverses order where sanitization was being applied before validation originally in accordance with REST API logic.

Props westonruter, schlessera.
See #34893.
See #37192.
Fixes #37247.


git-svn-id: https://develop.svn.wordpress.org/trunk@37942 602fd350-edb4-49c9-b593-d223f7449a82
2016-07-02 18:38:07 +00:00
Dominik Schilling (ocean90) 92dd472359 Script Loader: Introduce an API to register resource hints.
Resource hints allow browsers to prefetch specific pages or render them in the background to perform DNS lookups or to begin the connection handshake (DNS, TCP, TLS) in the background.

By default, `wp_resource_hints()` prints hints for "s.w.org" (the WordPress.org CDN) and for all scripts and styles which are enqueued from external hosts.
Use the `wp_resource_hints` filter to add custom domains and URLs for `dns-prefetch`, `preconnect`, `prefetch` or `prerender`.

Props voldemortensen, swissspidy.
Fixes #34292.

git-svn-id: https://develop.svn.wordpress.org/trunk@37920 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 19:35:27 +00:00
Joe McGill 0b4798b2bc Post Thumbnails: Add helper functions for attachment captions.
This adds three new functions for getting/displaying attachment captions:

* `wp_get_attachment_caption` - Retrieves a caption for a specific attachment.
* `get_the_post_thumbnail_caption()` - Returns the post thumbnail caption.
* `the_post_thumbnail_caption()` - Displays the post thumbnail caption.

These are helpful for displaying a caption associated with an image directly
in a template, rather than using the caption shortcode.

This also introduces two new filters:

* `wp_get_attachment_caption` - Filters the value of `wp_get_attachment_caption()`.
* `the_post_thumbnail_caption` - Filters the display of the post thumbnail caption.

`the_post_thumbnail_caption()` is automatically filtered by `wptexturize()`,
`convert_smilies()`, and `convert_chars()` in `wp-includes/default-filters.php`.

Props flixos90, joemcgill.
Fixes #12235.

git-svn-id: https://develop.svn.wordpress.org/trunk@37915 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 17:28:00 +00:00
Dominik Schilling (ocean90) 206380180e Text Changes: Unify permission error messages.
The new format looks like "Sorry, you are not allowed to <action>.". This provides a consistent experience for all error messages related to missing permissions. It also reduces the number of similar strings and allows translators to provide a consistent style in their language.

Props ramiy, Presskopp.
Fixes #34521.

git-svn-id: https://develop.svn.wordpress.org/trunk@37914 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 15:15:40 +00:00
Dominik Schilling (ocean90) a89fdc3935 Plugins: Return the original value in `apply_filters_deprecated()` if no filter is registered for the tag.
Props flixos90.
Fixes #10441.

git-svn-id: https://develop.svn.wordpress.org/trunk@37911 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 13:21:24 +00:00
Andrew Ozz a985e346b1 TinyMCE: update to 4.3.13, changelog: https://github.com/tinymce/tinymce/blob/master/changelog.txt.
Fixes #37225.

git-svn-id: https://develop.svn.wordpress.org/trunk@37910 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 13:20:17 +00:00
Dominik Schilling (ocean90) 3d6c1e5ca2 Tests: After [37861] move tests for deprecated filters into `filters.php`.
See #10441.

git-svn-id: https://develop.svn.wordpress.org/trunk@37909 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 13:13:53 +00:00
Dominik Schilling (ocean90) 970b7c43ab HTTP: Add unit tests for `wp_get_http_headers()` and `wp_remote_retrieve_headers()`.
Props borgesbruno, jipmoors.
Fixes #37090.

git-svn-id: https://develop.svn.wordpress.org/trunk@37907 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 12:46:59 +00:00
Rachel Baker 0e6a328782 REST API: Include a refreshed nonce in a `X-WP-Nonce` header when responding to an authenticated request.
Props adamsilverstein, welcher, markjaquith, aidvu.
Fixes #35662.




git-svn-id: https://develop.svn.wordpress.org/trunk@37905 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 03:00:54 +00:00
Rachel Baker 9e9adb0bfe REST API: Include auto-discovery Link header when serving API requests.
The Link header allows clients to verify if a site has made the REST API available, as well as indicating how to access it.

Props danielbachhuber.
Fixes #35580.




git-svn-id: https://develop.svn.wordpress.org/trunk@37903 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-29 01:56:32 +00:00
Jeremy Felt d277dd8ef1 Multisite: Introduce `WP_Network_Query`.
Provides a consistent way to query `$wpdb->site` for `WP_Network` objects based on domain, path, network ID, and (main) site ID.

Introduces and uses update_network_cache() and _prime_network_caches() to maintain a cached list of WP_Network objects for use in multiple queries.

Props flixos90.
See #32504.


git-svn-id: https://develop.svn.wordpress.org/trunk@37894 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-28 21:26:48 +00:00
Pascal Birchler 41b39bae16 Embeds: Add tests for the `WP_Embed` class.
Fixes #37214. See #34115.

git-svn-id: https://develop.svn.wordpress.org/trunk@37892 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-28 20:30:15 +00:00
Dominik Schilling (ocean90) bded47a1b6 Posts: Introduce `WP_Post_Type` and use it in `register_post_type()` and `unregister_post_type()`.
This changes the global `$wp_post_types` to an array of `WP_Post_Type` objects. `WP_Post_Type` includes methods to handle post type supports, rewrite rules, meta boxes, hooks, and taxonomies.
Each post type argument becomes a property of `WP_Post_Type`.

Props swissspidy, flixos90.
Fixes #36217.

git-svn-id: https://develop.svn.wordpress.org/trunk@37890 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-28 16:40:33 +00:00
Dominik Schilling (ocean90) f147b02783 Nav Menus: Use `WP_Query` for quick searches.
`the_post()` sets the `$in_the_loop` property to true which is unexpected in the admin if you're using filters which should only affect real loops.

Props ruud@joyo.
Fixes #27042.

git-svn-id: https://develop.svn.wordpress.org/trunk@37881 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-27 11:50:31 +00:00
Jeremy Felt 421888d9f4 Multisite: Change `WP_Network` `id` property to an integer.
For consistency and developer sanity.

Props flixos90.
Fixes #37050.


git-svn-id: https://develop.svn.wordpress.org/trunk@37870 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-26 13:22:36 +00:00
Peter Wilson 9ea1a7eb4f Posts: Fix back-compat for filters in get the modified time and date functions after [37738].
When no valid post exists for `get_the_modified_time` or `get_the_modified_date` calls, the result (`false`) is passed through the functions respective filters to maintain back-compat.

Introduces unit tests to ensure filters are applied and for the `get_the_modified_date` function.

Fixes #37059.


git-svn-id: https://develop.svn.wordpress.org/trunk@37866 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-26 11:29:13 +00:00
Boone Gorges c97f234e6f Allow action and filter hooks to be deprecated.
When a filter or action hook is deprecated, the corresponding `apply_filters()`
or `do_action()` calls should be switched out with `apply_filters_deprecated()`
or `do_action_deprecated()`. The latter functions will throw a deprecation
before invoking the original hook.

Props solarissmoke, SergeyBiryukov, DrewAPicture.
Fixes #10441.

git-svn-id: https://develop.svn.wordpress.org/trunk@37861 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-25 19:56:19 +00:00
Boone Gorges 255aaa471e Fix orderby meta handling for `WP_Term_Query`.
In order to allow meta-related values of `orderby` to be handled properly,
the term query's `meta_query` object must run its `get_sql()` method before
`orderby` parsing.

Fixing this bug required addressing another bug in `WP_Meta_Query`, which
caused the table alias index not to be reset when calling `get_sql()`
multiple times on the same object.

Props littler.chicken.
Fixes #37151.

git-svn-id: https://develop.svn.wordpress.org/trunk@37860 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-25 16:22:55 +00:00
Pascal Birchler bdaede85d7 Posts: Add hooks for post sticky status changes.
This adds a new `post_stuck` action that fires when a post is made sticky and a `post_unstuck` action that fires when the sticky flag is removed again.

Props ojrask.
Fixes #35600.

git-svn-id: https://develop.svn.wordpress.org/trunk@37857 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-23 15:51:03 +00:00
Pascal Birchler d0555f9544 I18N: Enable unloading of text domains that have been loaded just in time.
[37415] removed the requirement to call `load_plugin_textdomain()` / `load_theme_textdomain()`. This caused `unload_textdomain()` to not work properly anymore in these cases.

With this change, unloaded text domains need to be explicitly loaded manually if you want to use them again.

Props swissspidy, ocean90.
Fixes #37113. See #34114.

git-svn-id: https://develop.svn.wordpress.org/trunk@37855 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-23 14:47:44 +00:00
Dominik Schilling (ocean90) a35a1a9c75 I18N: Add support for the Catalan flown dot in `remove_accents()`.
Props xavivars, SergeyBiryukov.
Fixes #37086.

git-svn-id: https://develop.svn.wordpress.org/trunk@37853 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-23 13:27:32 +00:00
Joe McGill 93cae978dd Media: Improve handling of extensionless filenames.
This ensures files retain a filename after sanitization.

Fixes 37111.

git-svn-id: https://develop.svn.wordpress.org/trunk@37756 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-21 13:43:59 +00:00
Pascal Birchler 3f050f87c3 Menus: Support nested array variables in POST data when saving menus.
[36510] allowed larger menus to be created in the Edit Menu screen by JSON-encoding the entire form into a single input field. However, it did not correctly handle nested arrays.

This introduces a new `_wp_expand_nav_menu_post_data()` helper function to handle this POST data which uses `array_replace_recursive()` internally. Since the latter is only available on PHP 5.3+, we add a compatibility function to ensure PHP 5.2 support.

Props ericlewis, neverything, swissspidy.
Fixes #36590 for trunk. See #14134.

git-svn-id: https://develop.svn.wordpress.org/trunk@37748 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-19 12:24:23 +00:00
Pascal Birchler d40f2eed2c Permalinks: Validate custom permalink structures.
Custom permalink structures require at least one valid structure tag, e.g. `%postname%`. If none is included, it would leave users with broken permalinks.
Let's make sure this won't happen by validating the permalink structure.

Adds unit tests.

Props rockwell15 for initial patch.
Fixes #35936.

git-svn-id: https://develop.svn.wordpress.org/trunk@37747 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-19 12:01:11 +00:00
Pascal Birchler db843d80ab L10n: Add unit tests for the `override_load_textdomain` filter.
Fixes #36398.

git-svn-id: https://develop.svn.wordpress.org/trunk@37746 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-18 10:09:26 +00:00
Peter Wilson 54f1c097a6 Posts: Add `$post` parameter to modified date and time functions.
Unifies the APIs for getting a post's modified date or time with getting a post's date or time.

Adds the `$post` parameter to the functions `get_the_modified_date` and `get_the_modified_time`.

Adds the `$post` parameter to the filters `get_the_modified_date` and `get_the_modified_time`.

Props Soean, lukecavanagh.
Fixes #37059.


git-svn-id: https://develop.svn.wordpress.org/trunk@37738 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-17 05:11:29 +00:00
Jeremy Felt 96d7eadb0c Multisite: Use `WP_Site_Query` to power `WP_MS_Sites_List_Table`.
`WP_Site_Query` provides for a cleaner `prepare_items()` method. It significantly improves the search experience in the sites list table:

* In a subdomain configuration, domain and path are searched for a provided terms.
* In a subdirectory configuration, path is searched for a provided term.
* The full domain is searched in a subdomain configuration rather than the portion not matching the network's domain.
* Terms are searched as `%term%` by default. Adding `*` in the middle of a term will search `%te%rm%`.

Props flixos90, Fab1en.
Fixes #33185, #24833, #21837, #36675.


git-svn-id: https://develop.svn.wordpress.org/trunk@37736 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-17 00:02:05 +00:00
Jeremy Felt 3d56328372 Multisite: Add search column support to `WP_Site_Query`.
`domain` and/or `path` can be used to specify which column(s) should be searched.

See #35791.


git-svn-id: https://develop.svn.wordpress.org/trunk@37735 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-16 23:08:30 +00:00
Pascal Birchler 931440e375 Embeds: Enforce a valid post ID when embedding a post from the current site.
Otherwise `wp_filter_pre_oembed_result()` could erroneously return the HTML of the current post instead of the intended result.

Props kraftbj.
See #36767.

git-svn-id: https://develop.svn.wordpress.org/trunk@37729 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-16 17:17:32 +00:00
Rachel Baker 7a4e523b5e REST API: Include X-Robots-Tag: noindex header in REST API responses to prevent endpoints from being indexed by search engines.
Prevent duplicate content issues with search engines and REST API endpoint response data.

Fixes #36390.
Props m_uysl for the initial patch.

git-svn-id: https://develop.svn.wordpress.org/trunk@37726 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-16 14:58:28 +00:00
Dominik Schilling (ocean90) 62bd8ecdd7 External Libraries: Update Backbone to version 1.3.3.
Changelog: https://cdn.rawgit.com/jashkenas/backbone/1.3.3/index.html#changelog
Diff: https://github.com/jashkenas/backbone/compare/1.2.3...1.3.3

Includes a unit test to ensure that the minified version doesn't include `sourceMappingURL`.

Props adamsilverstein.
Fixes #37099.

git-svn-id: https://develop.svn.wordpress.org/trunk@37723 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-16 09:26:06 +00:00