Commit Graph

1104 Commits

Author SHA1 Message Date
Boone Gorges 504deb52fc Lazy-load comment meta on single post pages.
[34268] introduced cache priming for commentmeta, enabled by default. To
ensure performance on single post pages - where commentmeta is most likely
to cause performance issues - we disable up-front cache-priming. Instead, we
prime commentmeta caches for all comments in the loop the first time
`get_comment_meta()` is called on the page.

Props bradt, dd32, wonderboymusic, boonebgorges.
Fixes #16894.

git-svn-id: https://develop.svn.wordpress.org/trunk@34270 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-17 20:00:31 +00:00
Weston Ruter 5ea07785b3 Customize: Reduce peak memory usage by JSON-encoding settings and controls individually.
When there are hundreds of settings and controls (e.g. nav menu items and widget instances) the resulting object that is JSON-encoded can become very large, and `wp_json_encode()` can consume a lot of memory to serialize it. By breaking down the serialization into multiple calls the peak memory usage can be kept in line.

Moves logic out of `wp-admin/customize.php` into the `WP_Customize_Manager` class with new methods:

 * `is_ios()`
 * `get_document_title_template()`
 * `get_preview_url()`/`set_preview_url()`
 * `get_return_url()`/`set_return_url()`
 * `get_autofocus()`/`set_autofocus()`
 * `customize_pane_settings()`

Includes unit tests for these methods, for which the logic was formerly untestable in `customize.php`.

Fixes #33898.


git-svn-id: https://develop.svn.wordpress.org/trunk@34269 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-17 19:41:35 +00:00
Boone Gorges 12329f5ef8 Prime comment meta caches in `WP_Comment_Query`.
The new 'update_comment_meta_cache' parameter, which defaults to `true`, can
be used to disable this behavior.

`update_comment_cache()` has been updated to support an `$update_meta_cache`
parameter, which also updates to true; this matches the pattern we use for
priming post caches.

See #16894.

git-svn-id: https://develop.svn.wordpress.org/trunk@34268 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-17 19:29:46 +00:00
Scott Taylor 25710ecc67 In `wp_mime_type_icon()`, the length of the `$wilds` array varies depending on what is passed as `$mime`. Loop over `$wilds` instead of arbitrarily checking `$wilds[0]`.
Adds unit tests.

Fixes #33012.



git-svn-id: https://develop.svn.wordpress.org/trunk@34255 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-17 00:36:12 +00:00
Boone Gorges d26b868870 Don't notify post authors about spam comments.
[34106] moved post author notification to a hook, and in the process, missed
the 'spam' check. This changeset restores that check.

To make unit testing easier, the notification callbacks have been refactored
to return values: false when various conditions aren't met (eg, approved
comments should not trigger moderation emails), and the return value of the
`wp_notify_*()` function otherwise.

Props cfinke, kraftbj.
See #33587.

git-svn-id: https://develop.svn.wordpress.org/trunk@34250 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-16 21:59:16 +00:00
Boone Gorges 302e3d1116 Allow taxonomies to be non-public.
[13216] introduced the 'public' argument for `register_taxonomy()`. This param
was used to set defaults for 'show_ui' and a number of other params, but it
never did anything itself.

With this changeset, taxonomies registered with `public=false` will no longer
be queryable on the front end, ie via taxonomy archive queries.

Props wpsmith, ocean90, nacin, ericlewis, boonebgorges.
Fixes #21949.

git-svn-id: https://develop.svn.wordpress.org/trunk@34247 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-16 19:04:57 +00:00
Boone Gorges 1b016b6dc6 Failed `get_term_by()` lookups should always return `false`.
Previously, we sometimes returned `null`.

Props charlestonsw, tyxla.
Fixes #33281.

git-svn-id: https://develop.svn.wordpress.org/trunk@34246 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-16 18:49:28 +00:00
Drew Jaynes 7682e433fc Docs: Put "it's" in its place (again).
Props kitchin.
Fixes #33894.


git-svn-id: https://develop.svn.wordpress.org/trunk@34234 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-16 12:45:51 +00:00
Boone Gorges 0adb6877b2 Improve validation of `user_login` and `user_nicename` length.
The `user_login` field only allows 60 characters, and `user_nicename` allows
50. However, there are no protections in the interface, and few in the code,
that prevent the creation of users with values in excess of these limits. Prior
to recent changes in `$wpdb`, users were generally created anyway, MySQL
having performed the necessary truncation. More recently, the `INSERT`s and
`UPDATE`s simply fail, with no real feedback on the nature of the failure.

This changeset addresses the issue in a number of ways:
* On the user-new.php and network/user-new.php panels, don't allow input in excess of the maximum field length.
* In `wp_insert_user()`, throw an error if the value provided for `'user_login'` or `'user_nicename'` exceeds the maximum field length.
* In `wp_insert_user()`, when using `'user_login'` to generate a default value for `'user_nicename'`, ensure that the nicename is properly truncated, even when suffixed for uniqueness (username-2, etc).

Props dipesh.kakadiya, utkarshpatel, tommarshall, boonebgorges.
Fixes #33793.

git-svn-id: https://develop.svn.wordpress.org/trunk@34218 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-15 22:13:51 +00:00
Scott Taylor 28426c041c In `WP::parse_request()`, don't add query vars of non-viewable post types to `WP::public_query_vars`. In `register_post_type()`, don't add query vars of non-viewable post types to `WP::public_query_vars`.
In `_unregister_post_type()` (unit tests), don't add query vars of non-viewable post types to `WP::public_query_vars`.

Adds unit test.

Fixes #30018.


git-svn-id: https://develop.svn.wordpress.org/trunk@34215 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-15 18:53:12 +00:00
Scott Taylor 6493d211d2 After [34188], fix unit test for image header.
See #33319.


git-svn-id: https://develop.svn.wordpress.org/trunk@34214 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-15 18:43:51 +00:00
Scott Taylor 7b93c40830 `WP_Comment_Query`: add `comment__in` to allowed values for `$orderby`.
Adds unit tests.

Fixes #33883.


git-svn-id: https://develop.svn.wordpress.org/trunk@34212 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-15 16:34:14 +00:00
Scott Taylor 72bc9d3227 Add `parent__in` and `parent__not_in` query vars to `WP_Comment_Query`.
Adds unit tests.

Fixes #33882.


git-svn-id: https://develop.svn.wordpress.org/trunk@34205 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-15 16:22:34 +00:00
John Blackbourn 0402bac392 Missed files from [34172].
See #33877


git-svn-id: https://develop.svn.wordpress.org/trunk@34173 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-15 08:08:15 +00:00
John Blackbourn c29412abf9 Initialise `$_SERVER[ 'REMOTE_ADDR' ]` during the test bootstrap so individual tests need not.
Fixes #33877
Fixes #25162


git-svn-id: https://develop.svn.wordpress.org/trunk@34172 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-15 08:04:33 +00:00
Scott Taylor c702a71ad1 Update post thumbnail functions to allow a `WP_Post` to be passed.
Adds unit tests.

Props swissspidy, Rahe.
Fixes #33723.


git-svn-id: https://develop.svn.wordpress.org/trunk@34167 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-15 03:45:23 +00:00
Scott Taylor 5c85369bb6 In `_wp_ajax_delete_comment_response()`, read the new `'all'` prop returned by `get_comment_count()` via `wp_count_comments()` when setting `$total`. `'all'` doesn't include `spam` in its count.
Updates unit tests.

Props dipesh.kakadiya.
Fixes #32362.


git-svn-id: https://develop.svn.wordpress.org/trunk@34161 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-15 01:46:51 +00:00
Scott Taylor 8cb6843170 Ensure that the count cache for `all` is in sync with `comment-{$post_id}` values. These are the values most often relied-upon by the list table for comments.
Adds unit tests.

See #33875.


git-svn-id: https://develop.svn.wordpress.org/trunk@34136 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-14 22:38:02 +00:00
Scott Taylor 545da32217 The "counts" cache for comments by post id is never invalidated. Neither `wp_update_comment_count()` nor `wp_update_comment_count_now()` touch the cache.
Adds unit test.
See #33875.


git-svn-id: https://develop.svn.wordpress.org/trunk@34131 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-14 22:03:23 +00:00
John Blackbourn 0c38f660e1 Implement unit tests which use reflection to test functions in pluggable.php. This means any changes to these functions will need explicit changes to their corresponding tests, which helps prevent unintentional breakage.
Fixes #33867


git-svn-id: https://develop.svn.wordpress.org/trunk@34126 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-14 19:14:38 +00:00
Boone Gorges 974517d2bc Accept 'ID' as a valid `$field` in `get_user_by()`.
We already accept 'id'. `ID` more closely matches the database and
`WP_User` schemas.

Props Shelob9.
Fixes #33869.

git-svn-id: https://develop.svn.wordpress.org/trunk@34125 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-14 18:57:15 +00:00
Scott Taylor 2c91a4d1e0 Fix the case-sensitivity of some HTTP class usage.
See #33413.


git-svn-id: https://develop.svn.wordpress.org/trunk@34123 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-14 17:36:37 +00:00
John Blackbourn 811e538325 Update links to the user profile editing screen in the admin toolbar when the current logged in user has no role on the current site. Covers single site and Multisite and introduces tests.
Fixes #25162


git-svn-id: https://develop.svn.wordpress.org/trunk@34122 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-14 17:09:58 +00:00
Dominik Schilling (ocean90) 08098026ce Passwords: Deprecate second parameter of `wp_new_user_notification()`.
The second parameter `$plaintext_pass` was removed in [33023] and restored as `$notify` in [33620] with a different behavior. If you have a plugin overriding `wp_new_user_notification()` which hasn't been updated you would get a notification with your username and the password "both".
To prevent this the second parameter is now deprecated and reintroduced as the third parameter.

Adds unit tests.

Props kraftbj, adamsilverstein, welcher, ocean90.
Fixes #33654.

(Don't ask for new pluggables kthxbye)

git-svn-id: https://develop.svn.wordpress.org/trunk@34116 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-14 12:42:34 +00:00
Scott Taylor c16e8b5616 Add sanity checks in `map_meta_cap()`, return `'do_not_allow'` when posts don't exist.
Adds unit test.

Props ocean90, nerrad, filosofo.
Fixes #23162.


git-svn-id: https://develop.svn.wordpress.org/trunk@34113 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-14 04:43:48 +00:00
Dion Hulse 9555882e90 When running on windows systems, normalise the capitalisation of the drive letter for more reliable string comparisons.
Props tyxla
Fixes #33265


git-svn-id: https://develop.svn.wordpress.org/trunk@34104 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-14 01:58:03 +00:00
Scott Taylor 184e058681 Objects are passed by-reference since PHP 5. In `_get_custom_object_labels()`, cast `$object->labels` back to `object` before returning. This function is weird.
Adds unit test.

Props Toro_Unit.
Fixes #33023.


git-svn-id: https://develop.svn.wordpress.org/trunk@34102 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-14 01:22:23 +00:00
Scott Taylor 5d0bc76040 Check if the `$post_type` passed to `get_post_type_object()` is a `scalar` value. Non-scalars were producing PHP warnings.
Adds unit tests.

Props Kloon.
Fixes #30013.


git-svn-id: https://develop.svn.wordpress.org/trunk@34100 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-14 00:02:05 +00:00
Jeremy Felt 276fa7cd09 Tests: Update `Tests_Feed_RSS::test_items` to expect new comment permalink structure.
Introduced in [34075] for posts without comments.

Props netweb.
Fixes #19893.


git-svn-id: https://develop.svn.wordpress.org/trunk@34092 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-12 23:30:11 +00:00
Boone Gorges 829ae5f4ce Fail gracefully when checking mapped cap against unregistered post type.
Post type objects are reponsible for mapping their capabilities to core caps.
As a result, when the post type is no longer registered, the caps are no
longer mapped. This causes problems when a post is left in the database after
the post type is no longer present, and WP does an 'edit_post' or other cap
check against it: a PHP notice is thrown, and the cap check always fails.

As a more graceful fallback, we map all post-type-dependent caps onto
'edit_others_posts', which allows highly privileged users to be able to
access orphaned content (such as comments belonging to disabled post types),
while minimizing the possibility of unintended privilege escalation.

We also add a `_doing_it_wrong()` notice, so that developers and site
administrators are aware that the cap mapping is failing in the absence of
the registered post type.

Props mitchoyoshitaka, DrewAPicture, imath, codeelite, boonebgorges, nofearinc, SergeyBiryukov, jorbin, dlh.
Fixes #16956.

git-svn-id: https://develop.svn.wordpress.org/trunk@34091 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-12 21:26:57 +00:00
Boone Gorges dcbd8c6c3d Allow `setup_postdata()` to accept a post ID.
Previously, it accepted only a full post object.

Props sc0ttclark, mordauk, wonderboymusic.
Fixes #30970.

git-svn-id: https://develop.svn.wordpress.org/trunk@34089 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-12 20:57:06 +00:00
Boone Gorges 4ebab4dc16 Remove extraneous table join in `get_adjacent_post()`.
Since [29248], a table join has not been necessary to process the
`$excluded_terms` parameter of `get_adjacent_post()`. Aside from adding extra
overhead, this join meant that post records that don't have any corresponding
rows in `wp_term_relationships` were erroneously excluded from results.

Fixes #32833.

git-svn-id: https://develop.svn.wordpress.org/trunk@34088 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-12 20:33:07 +00:00
Scott Taylor db3a7133f2 In `wp_insert_post()`, when setting `$post_author`, use `isset()` instead of `! empty()` to allow `0` to be passed as the value for `$post_author`.
Adds unit tests.

Props ericdaams, wonderboymusic.
Fixes #32585.


git-svn-id: https://develop.svn.wordpress.org/trunk@34085 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-12 18:53:56 +00:00
Boone Gorges b7c8dbf4a2 Better default values in `WP_Query::get_queried_object()`.
Setting the default value of the `queried_object_id` property to `0` meant
that, when called early enough in the WP bootstrap, `get_queried_object()`
could short-circuit the normal query by fooling it into thinking that the
request was for a page with id 0. Setting the default value to `null` instead
avoids this problem.

Props gradyetc, jazbek.
Fixes #31355.

git-svn-id: https://develop.svn.wordpress.org/trunk@34073 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-12 03:36:12 +00:00
Boone Gorges 0546d4ea57 Add unit tests for `get_term()`.
These tests will be useful as we begin to refactor in favor of `WP_Term`.

See #14162.

git-svn-id: https://develop.svn.wordpress.org/trunk@34035 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-11 03:10:47 +00:00
Boone Gorges 5b9d9c7c07 Require numeric IDs in user deletion functions.
`wp_delete_user()` and `wpmu_delete_user()` both require an `$id` parameter.
Previously, the functions did not verify that the value passed was, in fact,
a number. As such, passing an object or any other entity that would be cast
to int `1` would result in user 1 being deleted. We fix this by enforcing
the requirement that `$id` be numeric.

Props dipesh.kakadiya, utkarshpatel, juliobox.
Fixes #33800.

git-svn-id: https://develop.svn.wordpress.org/trunk@34034 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-11 02:24:03 +00:00
Boone Gorges 40a0d1f3cb Move `wp_delete_user()` tests to their own file.
See #33800.


git-svn-id: https://develop.svn.wordpress.org/trunk@34033 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-11 01:50:40 +00:00
Scott Taylor ad163d3547 In `get_page_uri()`, do not add parent slugs to orphaned pages.
Adds unit test.

Props filosofo, MikeHansenMe, MikeHansenMe, chriscct7.
Fixes #15963. 


git-svn-id: https://develop.svn.wordpress.org/trunk@34001 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-10 16:53:52 +00:00
Jeremy Felt ef1f697564 Multisite: Allow users with `manage_network_users` to edit network users.
Other users in a network can now be given capabilities to manage users without also having global super admin privileges.

* Users with `manage_network_users` can not edit super admins.
* Users with `manage_network_users` can not promote users to super admin.
* Uses of `is_super_admin()` in `user-new.php` are now updated to `manage_network_users`.

Props daniellandau, chriscct7.
Fixes #16860.


git-svn-id: https://develop.svn.wordpress.org/trunk@33988 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-10 03:33:22 +00:00
Jeremy Felt c89822ebe0 Multisite: Test `edit_user` capabilities for multisite administrators
An administrator in multisite can not edit users other than itself.

Props daniellandau for the initial patch.
See #16860.


git-svn-id: https://develop.svn.wordpress.org/trunk@33987 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-10 03:20:11 +00:00
Scott Taylor 6bc498c0e6 Implement a priority system for Help Tabs to add them at specific positions.
Adds unit tests.

Props swissspidy.
Fixes #19828.


git-svn-id: https://develop.svn.wordpress.org/trunk@33985 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-10 01:26:26 +00:00
Andrew Ozz cc18f258cb TinyMCE: update to 4.2.5, changelog: http://www.tinymce.com/develop/changelog/?ctrl=version&act=index&pr_id=1.
Fixes #33782 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@33981 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-09 19:44:09 +00:00
Scott Taylor 9eefbd1999 Deprecate `wp_get_http()` - function isn't used anywhere (apart from itself).
Props swissspidy.
Fixes #33709.


git-svn-id: https://develop.svn.wordpress.org/trunk@33969 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-09 04:25:24 +00:00
Andrew Ozz bb6dee64ae Formatting: maintain the content of HTML comments when they contain `<object>` tags. Add more tests for wpaitop().
Props miqrogroove.
Fixes #33645 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@33955 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-08 22:54:08 +00:00
Scott Taylor 6d0c15836b After [33840], JS regex needs the `g` modifier.
Add another unit test case.

Props kitchin.
Fixes #22781.


git-svn-id: https://develop.svn.wordpress.org/trunk@33947 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-08 16:43:27 +00:00
Gary Pendergast f921391922 Tests: Check that `readme.html` is recommending an actively supported version of MySQL.
Per the MySQL support guidelines (https://www.mysql.com/support/), Oracle provides active support for MySQL releases for 5 years from the General Availality release.

See #33758.



git-svn-id: https://develop.svn.wordpress.org/trunk@33946 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-08 03:23:29 +00:00
Gary Pendergast 65156c6fc5 Tests: Add an extra warning message when checking the recommended PHP version.
See #33758.



git-svn-id: https://develop.svn.wordpress.org/trunk@33944 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-07 07:27:34 +00:00
Gary Pendergast 0b6454bac5 Readme: Update the recommended PHP version to 5.6.
This also includes a unit test to ensure we're only recommending actively supported versions of PHP in the future.

Fixes #33758.



git-svn-id: https://develop.svn.wordpress.org/trunk@33937 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-07 05:22:03 +00:00
Scott Taylor 2d68434dff After [33925], rename the unit test class to `Tests_Comment_Meta_Cache` to avoid collisions on the PHP 5.2 superhighway.
See #16894.


git-svn-id: https://develop.svn.wordpress.org/trunk@33926 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-05 22:29:59 +00:00
Scott Taylor 542ac152fc In `wp_list_comments()`, update the comment meta cache when the comments derive from `WP_Query` and the new `->comment_meta_cached` prop is `false`.
There are no uses of `wp_list_comments()` in Core where `$comments` are passed as the 2nd argument.

Adds unit tests.

Props wonderboymusic, bradt.
Fixes #16894.


git-svn-id: https://develop.svn.wordpress.org/trunk@33925 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-05 22:24:16 +00:00