Commit Graph

1051 Commits

Author SHA1 Message Date
Scott Taylor 0111ecef55 Canonical/Rewrite: sanity check posts that are paged with `<!--nextpage-->`. Page numbers past the max number of pages are returning the last page of content and causing infinite duplicate content.
Awesome rewrite bug: the `page` query var was being set to `'/4'` in `$wp`. When cast to `int`, it returns `0` (Bless you, PHP). `WP_Query` calls `trim( $page, '/' )` when setting its own query var. The few places that were checking `page`	before posts were queried now have sanity checks, so that these changes work without flushing rewrites.	

Adds/updates unit tests.

Props wonderboymusic, dd32.
See #11694.


git-svn-id: https://develop.svn.wordpress.org/trunk@34492 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 14:03:05 +00:00
Dominik Schilling (ocean90) 1efbe10b47 Customizer: Update tests for [34487].
Fixes #33634.

git-svn-id: https://develop.svn.wordpress.org/trunk@34488 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 11:31:30 +00:00
Scott Taylor e366584fae Unit Tests: after [34477], make `Tests_Link_GetPostCommentsFeedLink` more respectable.
See #33693.


git-svn-id: https://develop.svn.wordpress.org/trunk@34479 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 04:31:58 +00:00
Scott Taylor 158aecc3ec Feeds/Links: after [34336], use a different meat cleaver to fix Rewrite spillage across test cases.
Fixes #33693.


git-svn-id: https://develop.svn.wordpress.org/trunk@34477 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 04:19:56 +00:00
Scott Taylor bab2316129 Date/Time: Add unit tests for `the_date()`.
Props jubstuff.
Fixes #33750.


git-svn-id: https://develop.svn.wordpress.org/trunk@34474 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 03:33:21 +00:00
Gary Pendergast c47ef29b34 Tests: Remove a `var_dump()` added in [34373].
See #33070.



git-svn-id: https://develop.svn.wordpress.org/trunk@34468 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 03:07:20 +00:00
Scott Taylor d92723a33f Users: in `WP_User::__unset()`, don't reset the deprecated prop `id` to `ID`. Still throw the deprecated notice.
Update unit test.

Fixes #20043.


git-svn-id: https://develop.svn.wordpress.org/trunk@34466 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 00:48:23 +00:00
Scott Taylor c1c93f1e95 Widgets: when passing a string arg value to `dynamic_sidebar()`, don't reset `$index` when the arg's sanitized value matches the sanitized name of a sidebar.
Adds unit test.

Props tyxla, fjarrett.
Fixes #23423.


git-svn-id: https://develop.svn.wordpress.org/trunk@34465 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 00:29:54 +00:00
Boone Gorges daadd27ed4 Allow `comment_exists()` to match based on GMT date.
The `comment_date_gmt` field of the `wp_comments` table is indexed, which makes
`WHERE` matches against the field much faster than against the unindexed
`comment_date`. For bulk operations like data import, the speed difference can
be meaningful.

We continue to default to 'blog' for `$timezone`, to preserve compatibility
with existing uses.

Props apokalyptik.
Fixes #33871.

git-svn-id: https://develop.svn.wordpress.org/trunk@34460 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-23 18:15:39 +00:00
Boone Gorges cf3042389d Fix `comment_exists()` unit test introduced in [34456].
See #33871.

git-svn-id: https://develop.svn.wordpress.org/trunk@34457 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-23 14:46:36 +00:00
Boone Gorges 01c8e7a8e1 Add unit test for `comment_exists()`.
See #33871.

git-svn-id: https://develop.svn.wordpress.org/trunk@34456 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-23 14:34:37 +00:00
Boone Gorges e6b7c6b2d4 Bail early when invalid ID is passed to `get_comment_class()`.
This helps to avoid PHP notices later in the function.

Props walterebert, dipesh.kakadiya, DrewAPicture.
Fixes #33947.

git-svn-id: https://develop.svn.wordpress.org/trunk@34454 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-23 14:08:47 +00:00
Boone Gorges b23a1fc613 Add a few simple tests for `get_comment_class()`.
Props walterebert, dipesh.kakadiya.
See #33947.

git-svn-id: https://develop.svn.wordpress.org/trunk@34453 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-23 14:04:55 +00:00
John Blackbourn 9dd4680d2f Add tests for some missing capabilities, including `do_not_allow`.
See #32394.


git-svn-id: https://develop.svn.wordpress.org/trunk@34450 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-22 22:17:30 +00:00
John Blackbourn f1191d2e6e Correct a capability name in the roles and capabilities mapping. The `delete_others_pages` key was missing, and the `delete_others_posts` key was duplicated.
Introduced in [32812].

See #32394.


git-svn-id: https://develop.svn.wordpress.org/trunk@34449 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-22 22:15:18 +00:00
Aaron Jorbin dd25cc9a7c Add test image for test_exif_keywords test
[34374] added a test that relies on a new test image. This test image wasn't included in the commit.  This fixes the broken Tests_Image_Meta::test_exif_keywords test.

Props swissspidy, SteveHoneyNZ.
Fixes #33772.



git-svn-id: https://develop.svn.wordpress.org/trunk@34448 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-22 21:42:45 +00:00
johnbillion 50226ada19 Implement a test for capabilities for a custom post type that uses `capability_type => page`.
See #17253


git-svn-id: https://develop.svn.wordpress.org/trunk@34447 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-22 21:00:03 +00:00
Scott Taylor 0ad726ef4d Users: add `__unset` to `WP_User`.
Adds unit tests.

Props johnjamesjacoby, MikeHansenMe, wonderboymusic.
Fixes #20043.


git-svn-id: https://develop.svn.wordpress.org/trunk@34380 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-22 04:59:35 +00:00
wonderboymusic 70b90490fd Media: In `wp_read_image_metadata()`, include IPTC Keywords when available in `$meta`.
Adds unit test.

Props swissspidy, dbru, SteveHoneyNZ.
Fixes #33772.


git-svn-id: https://develop.svn.wordpress.org/trunk@34374 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-22 04:18:02 +00:00
Scott Taylor 1352d3473a Media: Add new functions, `get_the_post_thumbnail_url()` and `the_post_thumbnail_url()`.
Adds unit tests.

Props dipesh.kakadiya, swissspidy, atomicjack.
Fixes #33070.


git-svn-id: https://develop.svn.wordpress.org/trunk@34373 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-22 04:14:15 +00:00
Scott Taylor 3c0ecff16e Media: Add a new function, `wp_get_attachment_image_url()`, which is a shortcut for `wp_get_attachment_image_src()` - same function signature, but returns just the URL based on `$size`.
Adds unit test.

Props dipesh.kakadiya, swissspidy, sebastian.pisula.
Fixes #33878.


git-svn-id: https://develop.svn.wordpress.org/trunk@34372 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-22 04:12:44 +00:00
Scott Taylor f9d1856805 Help Tabs: when returning help tabs, return them in order of priority, but also return the items in each priority in the order that they were added.
Fixes #33941.


git-svn-id: https://develop.svn.wordpress.org/trunk@34370 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-22 03:36:27 +00:00
Scott Taylor e75c7651b2 HTTP: Add some new Cookie helper functions:
* `wp_remote_retrieve_cookies( $response )`
* `wp_remote_retrieve_cookie( $response, $name )`
* `wp_remote_retrieve_cookie_value( $response, $name )`

Adds unit tests.

Props johnbillion.
Fixes #33711.


git-svn-id: https://develop.svn.wordpress.org/trunk@34369 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-22 03:13:13 +00:00
Scott Taylor b55de4e5f8 Feeds/Links: fix feed links for unattached attachments.
Adds unit tests.

Props wonderboymusic, iworks.
Fixes #33693.


git-svn-id: https://develop.svn.wordpress.org/trunk@34336 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-19 20:09:05 +00:00
Scott Taylor d258115a28 After [34334], update unit tests.
See #33930.


git-svn-id: https://develop.svn.wordpress.org/trunk@34335 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-19 20:06:52 +00:00
Boone Gorges 2fd81992bc Split the comment query.
`WP_Comment_Query` now fetches comments in two stages: (1) a query to get the
IDs of comments matching the query vars, and (2) a query to populate the
objects corresponding to the matched IDs. The two queries are cached
separately, so that sites with persistent object caches will continue to have
complete cache coverage for normal comment queries.

Splitting the query allows our cache strategy to be more modest and precise, as
full comment data is only stored once per comment. It also makes it possible
to introduce logic for paginated threading, which is necessary to address
certain performance problems.

See #8071.
data is only stored once per comment, instead of along with

git-svn-id: https://develop.svn.wordpress.org/trunk@34310 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-18 19:27:39 +00:00
Scott Taylor d5e5ca8e93 Comments: in `wp_rel_nofollow_callback()`, account for the fact that a link might already have a `rel` attribute. Currently, if a link already has a `rel`, it will result it duplicate attributes on the element with conflicting values.
Adds unit tests.

Props junsuijin, wonderboymusic.
Fixes #9959.


git-svn-id: https://develop.svn.wordpress.org/trunk@34277 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-18 04:35:37 +00:00
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