Commit Graph

1504 Commits

Author SHA1 Message Date
Boone Gorges ef99ae21be Comments: Restore the ability to bypass post_id filter using 0 or '0'.
The changes introduced in [36381], while logical and clearly awesome, introduce
the potential for much breakage. Those who want to query for comments with a
null `comment_post_ID` should use `'post_in' => array( 0 )` instead.

Reverts [36381], [36387].
See #35090.


git-svn-id: https://develop.svn.wordpress.org/trunk@36480 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-05 18:49:46 +00:00
Boone Gorges 3ec4faf6e3 Comments: Add 'parent__in' and 'parent__not_in' to query var defaults.
Query var defaults are used to calculate a cache key. The fact that these
params were not listed among the defaults was causing cache keys to be
insufficiently specific.

Props danielbachhuber.
Fixes #35677.

git-svn-id: https://develop.svn.wordpress.org/trunk@36479 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-05 18:35:47 +00:00
Gary Pendergast cdf27d383d Tests: Use the new `wpdb::close()` method for closing the DB connection.
Props markoheijnen.

Fixes #34903.



git-svn-id: https://develop.svn.wordpress.org/trunk@36478 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-05 01:05:47 +00:00
Dominik Schilling (ocean90) ce68dd0ec5 Better validation of the URL used in HTTP redirects.
git-svn-id: https://develop.svn.wordpress.org/trunk@36444 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-02 15:10:09 +00:00
Gary Pendergast 2918cca22c WPDB: Add a `close()` method to `wpdb`, for when the connection needs to be manually closed.
In the event that it was closed prematurely, `wpdb::query()` will re-open the connection automatically.

Fixes #34903.



git-svn-id: https://develop.svn.wordpress.org/trunk@36433 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-02 00:12:28 +00:00
Boone Gorges 7c1854aeb0 Fix set up/tear down of post types in comment query test.
Introduced in [31015].

Props kouratoras.
Fixes #35633.

git-svn-id: https://develop.svn.wordpress.org/trunk@36415 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-27 23:12:07 +00:00
Weston Ruter 304ab7c0e4 Customizer: Export `nonce`, `theme`, and `url` app settings in preview as exported in pane.
* Introduce `WP_Customize_Manager::get_nonces()` to consolidate logic for retrieving nonces.
* Export nonces centrally in `wp.customize.settings.nonce` with each request and update nav menus preview to utilize.
* Send updated nonces to preview upon `nonce-refresh`.
* Request full preview refresh if Nav Menu selective refresh request fails (e.g. due to bad nonce).
* Update nav menus and widgets in Customizer to utilize `customize_refresh_nonces` for exporting nonces and keeping them up to date.

See #27355.
Fixes #35617.


git-svn-id: https://develop.svn.wordpress.org/trunk@36414 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-27 17:54:39 +00:00
Eric Andrew Lewis 8d562e0d04 Build/Test Tools: Move class `WP_UnitTest_Factory` into its own file.
In [36347] we moved all PHP factory classes into their own files except the main class. The main class is now in its own file, and `factory.php` is solely an include manifest for all factory classes.


git-svn-id: https://develop.svn.wordpress.org/trunk@36409 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-27 03:26:15 +00:00
Boone Gorges 746f545f9a Query: Respect 'suppress_filters' when filtering search-related SQL.
Props 5um17.
Fixes #35594.

git-svn-id: https://develop.svn.wordpress.org/trunk@36404 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-26 03:11:12 +00:00
Boone Gorges 14b6dbebd2 Introduce `$comment_status` and `$ping_status` params for `WP_Query`.
Props birgire.
Fixes #35601.

git-svn-id: https://develop.svn.wordpress.org/trunk@36403 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-26 02:55:15 +00:00
Boone Gorges af5a3b663f Allow `is_post_type_viewable()` to accept a post type name.
Previously, it accepted only a post type object.

Props spacedmonkey.
Fixes #35609.

git-svn-id: https://develop.svn.wordpress.org/trunk@36402 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-26 02:36:32 +00:00
Boone Gorges 81d3d79c1f Add tests for `is_post_type_viewable()`.
See #35609.

git-svn-id: https://develop.svn.wordpress.org/trunk@36401 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-26 02:26:21 +00:00
Boone Gorges dbac8968ed Allow comment query results to be limited to comments with comment_post_ID = 0.
Previously, this was not possible due to an overly broad `empty()` check.

Passing `null`, `false`, or `''` to 'post_id', or omitting 'post_id'
altogether, will continue to return comments regardless of `comment_post_ID`,
as before. Passing `0` or `'0'` will limit results to comments with no
associated post.

Props danielbachhuber.
Fixes #35090.

git-svn-id: https://develop.svn.wordpress.org/trunk@36381 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-22 20:19:49 +00:00
Jeremy Felt 77f8c5fc07 Themes: Enhance filtering options for allowed themes on a network.
* Move the legacy `allowed_themes` filter to `WP_Theme::get_allowed_on_network()`, where it will continue to filter themes allowed on the network.
* Add `network_allowed_themes` filter to `WP_Theme::get_allowed()` and pass `$blog_id` to provide context.
* Add `site_allowed_themes` filter to `WP_Theme::get_allowed_on_site()` and pass `$blog_id` to provide context.

Props pauldewouters, lamosty, michalzuber, dmsnell, johnnypea, rob.
Fixes #28436.


git-svn-id: https://develop.svn.wordpress.org/trunk@36366 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-20 18:28:33 +00:00
Jeremy Felt 18d9640a5a Themes: Add initial tests for the `allowed_themes` filter.
We'll be adjusting the placement of this filter and adding two other related filters, so we should make sure it continues to work as expected after the change.

See #28436.


git-svn-id: https://develop.svn.wordpress.org/trunk@36350 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-19 23:57:46 +00:00
Boone Gorges 5eee5cfc3c Don't double-escape the 'name' param in `get_terms()`.
[32353] changed the way the 'name' param in `get_terms()` is sanitized, by
running it through `sanitize_term_field( 'name' )` before performing the SQL
query. An unintentional side effect of this change was that the string is
double-escaped: once by `wp_filter_kses()`, and once by `esc_sql()`. The
double-escaping was causing 'name' queries to fail when the param contained
apostrophes or other escaped characters.

Fixes #35493.

git-svn-id: https://develop.svn.wordpress.org/trunk@36348 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-19 04:09:32 +00:00
Eric Andrew Lewis d36d6cc630 Build/Test Tools: Move PHP factory classes into their own files.
This makes the code easier to browse.

`factory.php` loads the new files, so this is backwards compatible in case `factory.php` is loaded directly for access to one of the classes.

See #35492.


git-svn-id: https://develop.svn.wordpress.org/trunk@36347 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-19 03:55:19 +00:00
Boone Gorges 7ae3adfb80 Share post fixture in `WP_Comment_Query` tests.
See #30017.

git-svn-id: https://develop.svn.wordpress.org/trunk@36346 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-19 03:02:42 +00:00
Boone Gorges 1b8e03bd89 Ignore false values of 'search' in `WP_Comment_Query`.
Props danielbachhuber.
Fixes #35513.

git-svn-id: https://develop.svn.wordpress.org/trunk@36345 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-19 02:54:28 +00:00
Ella Iseulde Van Dorpe 342d132b37 Fix unit tests after [36336]
git-svn-id: https://develop.svn.wordpress.org/trunk@36337 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-17 23:37:51 +00:00
Pascal Birchler 3541f7b90b Posts: Correctly pass `$post` to `post_password_required()` in `get_the_excerpt()`.
Corrects the relevant test.

Props sebastian.pisula for initial patch.
Fixes #35486.

git-svn-id: https://develop.svn.wordpress.org/trunk@36329 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-16 10:13:27 +00:00
Boone Gorges ac9e991dc8 Respect all post-related filters in `WP_Comment_Query`.
The refactor of `WP_Comment_Query`'s SQL generation in [34542] introduced a bug
that caused only the last post-related filter to be respected in comment
queries. In other words, if querying for comments using params
`post_status=draft&post_author=3`, only the last-processed of these params
would be respected. The current changeset fixes the logic so that these clauses
don't overwrite each other.

Props chriscct7.
Fixes #35478.

git-svn-id: https://develop.svn.wordpress.org/trunk@36326 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 20:09:36 +00:00
Rachel Baker 63e9eb7e5e Comments: Use TEXT column type in fallback for `wp_get_comment_column_max_length()`.
Fixes #10377.


git-svn-id: https://develop.svn.wordpress.org/trunk@36325 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 20:09:08 +00:00
Boone Gorges 4d17d22a47 Populate term cache with proper clone of term objects.
[34999] modified the cache strategy for terms in the context of
`wp_get_object_terms()`. As part of these changes, the `object_id` property of
term objects had to be unset before being cached. To avoid modifying passed-by-
reference terms, `update_term_cache()` attempted to make a copy of the terms
passed to the function; however, it failed to use the `clone` keyword, and thus
only created a reference instead of a copy.

Props berengerzyla.
Fixes #35462.

git-svn-id: https://develop.svn.wordpress.org/trunk@36323 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 19:34:16 +00:00
Pascal Birchler 13e7e78ddd Add tests missed and announced in [36319].
See #27246.

git-svn-id: https://develop.svn.wordpress.org/trunk@36320 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 14:49:54 +00:00
Pascal Birchler 63e442bbb8 Comments: Add a new `pre_wp_update_comment_count_now` filter.
This allows filtering a post's comment count before it is queried and updated in the database.

Props peterwilsoncc for initial patch.
Fixes #35060.

git-svn-id: https://develop.svn.wordpress.org/trunk@36318 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 13:41:35 +00:00
Pascal Birchler a111eafd41 Post Types: Introduce `unregister_post_type()`.
This new function can be used to completely unregister non built-in post types.

Fixes #14761.

git-svn-id: https://develop.svn.wordpress.org/trunk@36316 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 12:19:15 +00:00
Pascal Birchler c7ae3fb3ee Users: Deprecate the `get_currentuserinfo()` pluggable function.
It encourages an ugly pattern like `global $userdata; get_currentuserinfo();` in plugins/themes. `wp_get_current_user()` should be used instead, e.g. `$current_user = wp_get_current_user();`.

Props scribu for initial patch.
Fixes #19615.

git-svn-id: https://develop.svn.wordpress.org/trunk@36311 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 10:15:21 +00:00
Pascal Birchler 44db9bccf4 Taxonomy: Fix unit tests after [36308].
See #34988.

git-svn-id: https://develop.svn.wordpress.org/trunk@36309 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 09:12:18 +00:00
Pascal Birchler d80a3c7ccd Embeds: Allow embedding static front pages and pages having a child page with an `embed` slug.
This makes `embed` a special slug that can't be used for new pages/posts. When `https://example.com/foo/embed/` is an existing page, embeds fall back to `https://example.com/foo/?embed=true`.
Adds unit tests.

Fixes #34971.

git-svn-id: https://develop.svn.wordpress.org/trunk@36307 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-15 07:55:19 +00:00
John Blackbourn b8b68a6a9e I18N: Introduce tests for `WP_Locale`.
Props realloc, swissspidy
Fixes #34688


git-svn-id: https://develop.svn.wordpress.org/trunk@36292 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 23:49:52 +00:00
Boone Gorges 5a545bbe90 Use `assertEqualSets()` in `comment_author` test.
The previous assertion was too specific, resulting in race conditions.

See #35377.

git-svn-id: https://develop.svn.wordpress.org/trunk@36279 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 04:42:59 +00:00
Boone Gorges 0b564d48df Support searching for `'0'` in `WP_Query`.
Props swissspidy.
See #31025.

git-svn-id: https://develop.svn.wordpress.org/trunk@36278 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 04:36:54 +00:00
Boone Gorges bf2f6f8104 Use the post-filter WHERE clause when querying for comment descendants.
The descendant query in `WP_Comment_Query::fill_descendants()` uses the clauses
of the main `get_comment_ids()` query as a basis, discarding the `parent`,
`parent__in`, and `parent__not_in` clauses. As implemented in WP 4.4 [34546],
the WHERE clause was assembled in such a way that any modifications applied
using the `comments_clauses` filter were not inherited by `fill_descendants()`.
This resulted in descendant queries that did not always properly filter
results, and sometimes contained syntax errors.

The current changeset fixes the problem by using the post-filter WHERE clause
as the basis for the `fill_descendants()` query. This change requires a new
approach for eliminating the unneeded parent-related clauses: instead of
eliminating values in an associative array, we must use regular expressions.

Props boonebgorges, firebird75.
Fixes #35192.

git-svn-id: https://develop.svn.wordpress.org/trunk@36277 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 04:00:36 +00:00
Boone Gorges 1880b466c7 Always respect `$comments` array passed to `wp_list_comments()`.
[36157] fixed a bug whereby `wp_list_comments()` would not properly recognize
custom pagination arguments. See #35175. However, it inadvertently introduced
a bug that caused any `$comments` array explicitly passed to the function to be
ignored, when that array was accompanied by pagination arguments that differ
from those in `$wp_query`. We address this bug by moving the logic introduced
in [36157] inside a block that only fires when no `$comments` array has been
provided to the function.

Props ivankristianto.
Fixes #35356.

git-svn-id: https://develop.svn.wordpress.org/trunk@36276 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 03:26:31 +00:00
Boone Gorges f7d238dfe3 Ignore hierarchy in pagination calculation when comment threading is disabled.
In order to calculate comment pagination when newest comments are displayed
first, `comments_template()` must perform a separate query to determine the
total number of paginating comments available on a post. See [34729], #8071,
pagination calculation - can be defined as a top-level comment, or a comment
with `parent=0`. However, when comment threading is disabled, yet comments
exist in the database that have parents, all comments - even those with a
parent - are "paginating". (This typically happens when comments threading was
once enabled, but has since been turned off.) As such, the total-paginating-
comments query should only be limited to top-level comments when
'thread_comments' is disabled.

Props jmdodd.
Fixes #35419.

git-svn-id: https://develop.svn.wordpress.org/trunk@36275 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 03:12:34 +00:00
Rachel Baker 0e85f45cb4 Comments: Restrict the maximum characters for input fields within the comments template.
Added hardcoded maxlength attributes on the author, author_email, author_url, and comment_field input markup. These can be modified via the comment_form_defaults filter. Added logic in wp_handle_comment_submission() to return a WP_Error when the comment_author, comment_author_url, or comment_content values exceed the max length of their columns. Introduces wp_get_comment_column_max_length() which returns the max column length for a given column name, and is filterable. Unit tests included for the error conditions in wp_handle_comment_submission()

Fixes #10377.

Props westonruter rachelbaker.


git-svn-id: https://develop.svn.wordpress.org/trunk@36272 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-13 01:24:46 +00:00
Pascal Birchler 3a358c33d3 Introduce `wp_get_raw_referer()` to retrieve unvalidated referer.
For things like redirects `wp_get_referer()` should be used instead.

Props voldemortensen for initial patch.
Fixes #27152.

git-svn-id: https://develop.svn.wordpress.org/trunk@36266 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-12 08:31:10 +00:00
Weston Ruter 2fa620e4c3 Customizer: Prevent erroneously directing user to login screen when closing.
Fixes issue where user gets stuck at login screen after trying to close the app if previously they had to first login to access the Customizer. Prevents `WP_Customize_Manager::get_return_url()` from using `wp-login.php` as a referer.

Props chandrapatel.
See #32637.
Fixes #35355.


git-svn-id: https://develop.svn.wordpress.org/trunk@36261 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-11 18:50:30 +00:00
Pascal Birchler 94992e25ae Rewrite: Ensure `WP_Rewrite::flush_rules()` does not delete the 'rewrite_rules' option.
Instead, the option gets updated to an empty string.
Adds unit tests.

Props SergeyBiryukov, jesin, voldemortensen.
Fixes #29107.

git-svn-id: https://develop.svn.wordpress.org/trunk@36254 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-10 19:01:13 +00:00
Pascal Birchler 519051b305 Permalinks: Ensure the page hierarchy is correct for sample permalinks.
Fixes #35368.

git-svn-id: https://develop.svn.wordpress.org/trunk@36253 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-10 18:27:06 +00:00
Boone Gorges 28818255c2 Don't reset index keys when trimming results of term queries.
`array_slice()` must be told to preserve keys when the query results exceed the
limit specified the 'number' parameter, so that `id=>parent` and other
id-indexed return value formats don't get mangled.

Props fantasyworld, wpdelighter.
Fixes #35382.

git-svn-id: https://develop.svn.wordpress.org/trunk@36252 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-10 04:05:26 +00:00
Boone Gorges e75a1f5ab3 Avoid invalid SQL when building ORDER BY clause using long search strings.
The introduction of negative search terms in 4.4 [34934] introduced the
possibility that the ORDER BY clause of a search query could be assembled in
such a way as to create invalid syntax. The current changeset fixes this by
ensuring that the ORDER BY clause corresponding to the search terms is
excluded when it would otherwise be empty.

Props salvoaranzulla.
Fixes #35361.

git-svn-id: https://develop.svn.wordpress.org/trunk@36251 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-10 03:25:15 +00:00
John Blackbourn 6681e9701c Taxonomy: More tests for `unregister_taxonomy()`.
See #35227


git-svn-id: https://develop.svn.wordpress.org/trunk@36247 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-09 23:34:27 +00:00
Pascal Birchler eafbcb3b6e Taxonomy: Introduce `unregister_taxonomy()`.
This new function can be used to completely unregister non built-in taxonomies.

Fixes #35227.

git-svn-id: https://develop.svn.wordpress.org/trunk@36243 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-09 14:57:22 +00:00
Pascal Birchler d92ead50c8 Ensure `wp_get_referer()` returns `false` when the referrer URL is the current URL.
Adds unit tests.

Fixes #19856.

git-svn-id: https://develop.svn.wordpress.org/trunk@36242 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-09 14:35:03 +00:00
Pascal Birchler 54134dd49b Media: Fix `wp_audio_shortcode` and `wp_video_shortcode` attributes handling.
Although documented, the `class` and `style` attributes were simply ignored.
Adds unit tests.

Fixes #35367.

git-svn-id: https://develop.svn.wordpress.org/trunk@36240 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-09 14:17:02 +00:00
Dion Hulse 0e73cc3da4 Tests: Add more paged canonical tests for page_on_front.
See #35344.


git-svn-id: https://develop.svn.wordpress.org/trunk@36238 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-09 08:08:47 +00:00
Dion Hulse 5f55910b5c Tests: Remove some debug that's slipped in at some point.
git-svn-id: https://develop.svn.wordpress.org/trunk@36236 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-09 06:11:58 +00:00
Boone Gorges 8dbc62d267 In `comments_template()`, don't run hierarchical queries if comment threading is disabled.
When hierarchical=true, `WP_Comment_Query` will always fetch comments according
to the comment hierarchy, even if 'thread_comments' is disabled for the site.
This can cause problems when comment threading is disabled after threaded
comments have been recorded on the site; comments will no longer be returned in
a strictly chronological order.

We address the issue by refraining from querying hierarchically when comment
threading is disabled.

Props jmdodd.
Fixes #35378.

git-svn-id: https://develop.svn.wordpress.org/trunk@36226 602fd350-edb4-49c9-b593-d223f7449a82
2016-01-08 22:16:11 +00:00