Commit Graph

1339 Commits

Author SHA1 Message Date
Boone Gorges 578134d4ff Use `wp_installing()` instead of `WP_INSTALLING` constant.
The `WP_INSTALLING` constant is a flag that WordPress sets in a number of
places, telling the system that options should be fetched directly from the
database instead of from the cache, that WP should not ping wordpress.org for
updates, that the normal "not installed" checks should be bypassed, and so on.

A constant is generally necessary for this purpose, because the flag is
typically set before the WP bootstrap, meaning that WP functions are not yet
available.  However, it is possible - notably, during `wpmu_create_blog()` -
for the "installing" flag to be set after WP has already loaded. In these
cases, `WP_INSTALLING` would be set for the remainder of the process, since
there's no way to change a constant once it's defined. This, in turn, polluted
later function calls that ought to have been outside the scope of site
creation, particularly the non-caching of option data. The problem was
particularly evident in the case of the automated tests, where `WP_INSTALLING`
was set the first time a site was created, and remained set for the rest of the
suite.

The new `wp_installing()` function allows developers to fetch the current
installation status (when called without any arguments) or to set the
installation status (when called with a boolean `true` or `false`). Use of
the `WP_INSTALLING` constant is still supported; `wp_installing()` will default
to `true` if the constant is defined during the bootstrap.

Props boonebgorges, jeremyfelt.
See #31130.

git-svn-id: https://develop.svn.wordpress.org/trunk@34828 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-05 15:05:26 +00:00
Drew Jaynes b1ed6b5f18 Widgets: Add more tests for registering and unregistering sidebars with 1) no ID, 2) a string ID, 3) a numeric ID.
See #17078.


git-svn-id: https://develop.svn.wordpress.org/trunk@34817 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-04 05:22:11 +00:00
Drew Jaynes 572fd0a45b Widgets: Add tests for `dynamic_sidebar()` where sidebars were registered with 1) no supplied ID, 2) a numeric ID, 3) a string ID.
See #17078.


git-svn-id: https://develop.svn.wordpress.org/trunk@34816 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-04 04:43:46 +00:00
Boone Gorges ffa997a342 Update the taxonomy relationship cache in `is_object_in_term()`.
This function attempts to read from the relationship cache, and uses any data
it finds. If it finds no data, it does a query for the data it needs. Since we
are going to the trouble to query for the relationships, and since we are
already using cached data when available, let's go ahead and cache it for
later use.

Props joehoyle, boonebgorges.
Fixes #32044.

git-svn-id: https://develop.svn.wordpress.org/trunk@34812 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 21:18:55 +00:00
Drew Jaynes 0ea2acb720 Tests: Permalink Structures Phase II: DRY up logic for setting permalink structures in test methods.
Renames `reset_permalinks()` to `set_permalink_structure()` (mimicking `$wp_rewrite->set_permalink_structure()`) and allows it to accept an optional permalink structure. In this way, we can double dip using it to both set and reset the permalink structure from anywhere.

Removes alot of duplicated code from tests.

See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@34810 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 20:54:11 +00:00
Boone Gorges eebe549408 When creating terms, avoid false dupe checks due to accented characters.
`wp_insert_term()` doesn't allow the creation of a term when the term `name`
is the same as another term in the same hierarchy level of the same taxonomy.
Previously, this duplicate check used `get_term_by( 'name' )`, which uses the
database collation to determine sameness. But common collations do not
distinguish between accented and non-accented versions of a character. As a
result, it was impossible to create a term 'Foo' if a sibling term with an
accented character existed.

We address this problem by using `get_terms()` to do the duplicate check. This
query returns all potentially matching terms. We then do a stricter check
for equivalence in PHP, before determining whether one of the matches is
indeed a duplicate.

Props boonebgorges, tyxla, geza.miklo, mehulkaklotar.
Fixes #33864.

git-svn-id: https://develop.svn.wordpress.org/trunk@34809 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 20:24:09 +00:00
Drew Jaynes 01f25fa247 Tests: Last try: It's redundant to reset permalinks on `tearDown()` if we're already doing it on every `setUp()`.
Removes the restoration logic, which leveraged a static property initialized with `get_option()`.

See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@34807 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 19:26:24 +00:00
Boone Gorges 3b89b3ca28 Use 'comments_per_page' option as fallback in `get_page_of_comment()`.
The function now uses the following order of precedence when calculating
comment pagination: 1. the 'per_page' value passed in the `$args` array,
2. the 'comments_per_page' query var in `$wp_query`, and 3. the
'comments_per_page' setting from options-discussion.php. This change allows
`get_page_of_comment()` to return an accurate value before the main query
has been run.

Props laceous.
See #13939.

git-svn-id: https://develop.svn.wordpress.org/trunk@34806 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 19:25:25 +00:00
Boone Gorges ddc75e22ee Only count top-level comments when calculating threaded pagination.
The change in [34535] did not properly account for threading.

See #13939, #11334.

git-svn-id: https://develop.svn.wordpress.org/trunk@34805 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 19:15:55 +00:00
Boone Gorges b240a2a939 Ensure that `WP_User_Query` vars are filled after 'pre_get_users'.
This prevents notices from being thrown when a 'pre_get_users' callback
removes required values from the list of `query_vars`.

For backward compatibility with previous uses of 'pre_get_users', default
values are parsed both before and after the action is fired.

Fixes #33449.

git-svn-id: https://develop.svn.wordpress.org/trunk@34804 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 18:44:40 +00:00
Drew Jaynes 9cdffaaed8 Tests: Move the global permalinks reset routine to only fire when running core tests.
Should fix intermittent mysqli response errors in the AJAX tests.

See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@34803 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 18:35:58 +00:00
Drew Jaynes adffdab161 Tests: Introduce `WP_UnitTestCase::reset_permalinks()`, an attempt to DRY up logic for resetting and restoring default permalinks on `setUp()` and `tearDown()`.
See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@34802 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 17:14:12 +00:00
Sergey Biryukov 4fc732d804 Add missing unit tests from [34799].
Props johnbillion.
See #34059.

git-svn-id: https://develop.svn.wordpress.org/trunk@34801 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 15:09:57 +00:00
John Blackbourn 48300f62b3 Introduce support for array format field names in `WP_Widget::get_field_name()` and `WP_Widget::get_field_id()`.
Fixes #12133
Props ch1902, welcher


git-svn-id: https://develop.svn.wordpress.org/trunk@34780 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 20:23:54 +00:00
Jeremy Felt 464f857316 MS: Introduce `*_network_option` functions.
Introduces `add_network_option()`, `update_network_option()`, `get_network_option()`, and `delete_network_option()`, which use the internals previously found in the `*_site_option()` functions and allow for a network ID to enable cross network storage and retrieval of network options.

* `*_site_option()` functions are now wrappers for `*_network_option()` and will interact with options for the current network in a multisite environment.
* All will continue to fallback to `*_option()` for non-multisite uses.
* Adds basic tests for cross network storage and retrieval.
* Existing tests for `*_site_option()` functions provide coverage for storage and retrieval of current network options.

Props spacedmonkey, DrewAPicture, jeremyfelt.
See #28290.


git-svn-id: https://develop.svn.wordpress.org/trunk@34777 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 18:00:30 +00:00
Boone Gorges 44d021b686 More explicit tests for `image_get_intermediate_size()`.
After [33807], `Tests_Image_Intermediate_Size::test_get_intermediate_sizes_by_array_zero_width()`
was failing intermittently. This failure was due to the use of a random number
for the image height. When the height was sufficiently large - $height >= 202 -
to change the aspect ratio of the cropped image (based on WP's threshold of a
1px difference), the test passed. And when the height was exactly 200, the
medium image size was hit exactly. The failure occurred only with a height of
201, which is close enough to 200 so that WP determined that the aspect ratio
of the potential crop was close enough to match.

The current changeset splits the test into two, in order to demonstrate the
failure.

See #17626. Fixes #34087.

git-svn-id: https://develop.svn.wordpress.org/trunk@34775 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 14:13:15 +00:00
Boone Gorges 991feb7043 Pinking shears in shortcode test file.
git-svn-id: https://develop.svn.wordpress.org/trunk@34774 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 13:50:18 +00:00
Boone Gorges f408407620 Improvements to PCRE benchmarking tests.
* Add test file accidentally omitted from [34761].
* Bail properly from benchmarker when a `preg_last_error()` is found.

Props miqrogroove.
See #34121.

git-svn-id: https://develop.svn.wordpress.org/trunk@34773 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 13:50:12 +00:00
Boone Gorges 19df309491 Fix `preg_match_all()` syntax in PCRE benchmark test util.
In versions of PHP earlier than 5.4, the `$matches` parameter was required.
Excluding it here meant that PCRE benchmarking tests were erroring on older
versions of PHP without cleaning up the PCRE ini settings, causing various
problems on later tests.

Props miqrogroove, dd32, boonebgorges.

And to the cosmic forces that cause bugs like this. The best part of waking up
is diagnosing leakage between automated tests.

See #34121.

git-svn-id: https://develop.svn.wordpress.org/trunk@34772 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 13:50:04 +00:00
Dion Hulse b20695ed9f Skip two `wp_json_encode()` tests when mbstring is unavailable.
git-svn-id: https://develop.svn.wordpress.org/trunk@34771 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 08:54:52 +00:00
Scott Taylor 79dc7efc73 Unit Tests: when `wp_using_ext_object_cache()`, mark some transient tests as skipped.
Props ocean90.
See #31491.


git-svn-id: https://develop.svn.wordpress.org/trunk@34767 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 05:09:03 +00:00
Scott Taylor c6571bcfad Unit Tests: tests that want to flush the cache should use their instance method instead of calling `wp_cache_flush()` - more properties need to be wiped out in between tests.
Props ocean90.
See #31491.


git-svn-id: https://develop.svn.wordpress.org/trunk@34766 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 05:08:13 +00:00
Scott Taylor cae64c5e13 Unit Tests: in `Tests_Cache::test_wp_cache_init()`, when `wp_using_ext_object_cache()`, just check that the global is an instance of `WP_Object_Cache`. External object cache instances of `WP_Object_Cache` will contain resources as props that will always have differing internal IDs, so strict comparison won't work.
See #31491.


git-svn-id: https://develop.svn.wordpress.org/trunk@34765 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 05:05:26 +00:00
Scott Taylor a31e54344c Posts: In `wp_insert_post()`, don't set `post_date` to current time if it can be derived from a passed value for `post_date_gmt`.
Adds unit tests.

Props oso96_2000, kawauso.
Fixes #15946.


git-svn-id: https://develop.svn.wordpress.org/trunk@34762 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 04:35:34 +00:00
Scott Taylor 5a24a0a4f8 Shortcodes/Formatting: Add PCRE Performance Testing
* Move pattern from `wptexturize()` into a separate function.
* Move pattern from `wp_html_split()` into a separate function.
* Beautify code for `wp_html_split()`.
* Remove unnecessary instances of `/s` modifier in patterns that don't use dots.
* Add `tests/phpunit/data/formatting/whole-posts.php` for testing larger strings.
* Add function `benchmark_pcre_backtracking()`.
* Add tests for `wp_html_split()`.
* Add tests for `wptexturize()`.
* Add tests for `get_shortcode_regex()`.

Props miqrogroove.
Fixes #34121.


git-svn-id: https://develop.svn.wordpress.org/trunk@34761 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 04:25:40 +00:00
Jeremy Felt 319818a408 Tests: Clarify site option tests storing and retrieving serialized data.
See #28290.


git-svn-id: https://develop.svn.wordpress.org/trunk@34759 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 02:05:23 +00:00
Jeremy Felt b9e1b4ab7c Tests: Split `test_default_filter()` Site Option test into multiple tests.
See #28290.


git-svn-id: https://develop.svn.wordpress.org/trunk@34758 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 01:55:52 +00:00
Jeremy Felt e261546a61 Tests: Split `test_the_basics()` Site Option test into many tests.
Many assertions in one test are now many tests with one assertion.

See #28290.


git-svn-id: https://develop.svn.wordpress.org/trunk@34757 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-02 01:32:09 +00:00
Scott Taylor e0b34f44a3 Shortcodes: Fix PCRE performance bugs in `get_shortcode_regexp()` and related to `wptexturize()`, `do_shortcode()`, and `strip_shortcodes()`
Alters unit tests.

Props miqrogroove.
Fixes #33517.


git-svn-id: https://develop.svn.wordpress.org/trunk@34747 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 18:04:13 +00:00
Scott Taylor 1b70f27b04 Shortcodes: prevent registration of invalid shortcode names.
Adds unit tests.

Props miqrogroove.
Fixes #34090.


git-svn-id: https://develop.svn.wordpress.org/trunk@34745 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 17:33:58 +00:00
Boone Gorges 2828042b6e Make sure permastruct is set in `comments_template()` tests.
After [34735].

git-svn-id: https://develop.svn.wordpress.org/trunk@34741 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 12:26:33 +00:00
Gary Pendergast f9f56fb942 WPDB: Allow `null` values in the CRUD functions.
Specifically, `::insert()`, `::replace()`, `::update()`, and `::delete()` can now set a column to `NULL`, or add the `IS NULL` condition to the `WHERE` clause.

This is based on [backpress 279].

Props pento, nbachiyski, sorich87.

Fixes #15158.



git-svn-id: https://develop.svn.wordpress.org/trunk@34737 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 05:36:15 +00:00
Boone Gorges ee2c079ade Ensure that comment permalinks reflect pagination.
After [34561], `wp_list_comments()` no longer passed all of a post's comments
to `Walker_Comments`. As a result, calls to `get_comment_link()` occurring
inside the comment loop had insufficient context to determine the proper
'cpage' value to use when generating comment permalinks. This, in turn, caused
comment permalinks to behave erratically.

The current changeset addresses the problem as follows:

* `get_comment_link()` now accepts a 'cpage' parameter. When present, 'cpage' will be used to build the comment permalink - no automatic calculation will take place.
* When called within the main loop, `wp_list_comments()` calculates the proper 'cpage' value for comments in the loop, and passes it down to `get_comment_link()`.
* `cpage` and `comment-page-x` query vars are generally required in comment permalinks (see #34068), but an exception is made when 'default_comment_page=oldest': the bare post permalink will always be the same as `cpage=1`, so `cpage` is excluded in this case.

Props peterwilsoncc for assiduous spreadsheeting.
Fixes #34073.

git-svn-id: https://develop.svn.wordpress.org/trunk@34735 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 05:12:39 +00:00
Boone Gorges f14dc03ad6 Simplify pagination logic in `comments_template()`.
[34561] "fixed" the problem of newest-first comments showing fewer than
'per_page' comments on the post permalink when the total number of comments
was not divisible by 'per_page'. See #29462. But this fix caused numerous
other problems. First, comment pages reported by `get_page_of_comment()`
(which expects comment pages to be filled oldest-first) were no longer correct.
Second, and more seriously, the new logic caused comments to be shifted
between pages, making their permalinks non-permanent.

The current changeset reverts the changed behavior. In order to preserve the
performance improvements introduced in [34561], an additional query must be
performed when 'default_comments_page=newest' and 'cpage=0' (ie, you're viewing
the post permalink). A nice side effect of this revert is that we no longer
need the hacks required to determine proper comment pagination, introduced in
[34561].

See #8071. See #34073.

git-svn-id: https://develop.svn.wordpress.org/trunk@34729 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-01 03:10:13 +00:00
Boone Gorges 9dd6f369cf Fix db_version juggling during non-multisite tests.
Continuing with the "code is poetry" theme after [34719], we need to continue
to update the option in the database on non-multisite in this
`wp_insert_term()` test.

See #31130.

git-svn-id: https://develop.svn.wordpress.org/trunk@34720 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-30 13:27:09 +00:00
Boone Gorges 13e28a6d34 Prevent Multisite term tests from hitting database for 'db_version'.
[34718] introduced a 'db_version' check to term meta functions, to ensure that
they don't run when the term meta schema is not yet in place. This call to
`get_option()` causes a database hit during Multisite tests, due to the
presence of the `WP_INSTALLING` constant. See #31130. The extra database
queries are causing cache tests to fail.

In similar cases, we have `markTestSkipped()` when `is_multisite()`. Because
the term meta API is so extensive - term meta caches can be primed anywhere a
`WP_Query` loop is fired up - we implement a more generous workaround in this
case. To prevent `get_option( 'db_version' )` from hitting the database during
multisite unit tests, we use a 'pre_option_' filter.

Heaven help us.

See #34091.

git-svn-id: https://develop.svn.wordpress.org/trunk@34719 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-30 13:08:49 +00:00
Boone Gorges 30a165a1a5 Fix logical errors in some comment pagination tests.
The tests included in [34669] contained a couple of problems:

* Comments were not always created in the expected order, due to the incorrect use of 'comment_date_gmt'.
* 'asc'/'desc' and 'older'/'newer' were confused.
* 'default_comments_page=newest' ('last') didn't properly account for the cpage=1 offset.

The code itself powering this pagination was correct; it's only the tests that
were wrong.

See #8071.

git-svn-id: https://develop.svn.wordpress.org/trunk@34713 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-30 03:06:22 +00:00
Boone Gorges 283c38c022 Improve lazyloading of comment meta in `WP_Query` loops.
Lazy-loading logic is moved to a method on `WP_Query`. This makes it possible
for comment feeds to take advantage of metadata lazyloading, in addition to
comments loaded via `comments_template()`.

This new technique parallels the termmeta lazyloading technique introduced in
[34704].

Fixes #34047.

git-svn-id: https://develop.svn.wordpress.org/trunk@34711 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-30 01:34:54 +00:00
Scott Taylor 427f4fe063 Rewrite: allow `add_rewrite_rule|WP_Rewrite::add_rule()` to accept an associative array for the value of `$redirect` instead of requiring a query string.
Adds unit tests.

Props scribu, DrewAPicture.
Fixes #16840.


git-svn-id: https://develop.svn.wordpress.org/trunk@34708 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-30 01:10:03 +00:00
Boone Gorges e75f2c024f Improve lazyloading of term metadata in `WP_Query` loops.
[34529] introduced lazyloading for the metadata belonging to terms matching
posts in the main `WP_Query`. The current changeset improves this technique
in the following ways:

* Term meta lazyloading is now performed on the results of all `WP_Query` queries, not just the main query.
* Fewer global variable touches and greater encapsulation.
* The logic for looping through posts to identify terms is now only performed once per `WP_Query`.

Props dlh, boonebgorges.
See #34047.

git-svn-id: https://develop.svn.wordpress.org/trunk@34704 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 21:59:44 +00:00
John Blackbourn 601ace8b25 `force_ssl_login()` has been functionally identical to `force_ssl_admin()` since 4.0 (#10267), so its test assertions can be removed as the function has been deprecated in [34700]. The remaining assertions suitably cover `force_ssl_admin()`.
See #34011


git-svn-id: https://develop.svn.wordpress.org/trunk@34703 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 21:43:04 +00:00
Drew Jaynes c226bff80b Tests: Add two tests for the current behavior of the 'hierarchical' and 'child_of' arguments in `get_pages()`.
See #18701.


git-svn-id: https://develop.svn.wordpress.org/trunk@34699 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 21:27:03 +00:00
Drew Jaynes 49f4196f12 Tests: Add two tests for the current 'hierarchical' argument behavior in `get_pages()`.
See #18701.


git-svn-id: https://develop.svn.wordpress.org/trunk@34698 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 20:49:32 +00:00
Boone Gorges 49063d8e14 `WP_Query` should not ignore an offset of `0`.
Props mazurstas.
Fixes #34060.

git-svn-id: https://develop.svn.wordpress.org/trunk@34697 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 19:36:16 +00:00
Boone Gorges 3b7187eade Fix 'exclude_tree' in `wp_list_categories()`.
The 'exclude_tree' parameter must be compatible with 'hierarchical';
previously, 'hierarchical' canceled it out. This changeset also makes it so
that 'exclude_tree' is compatible with 'exclude'. When both are passed, and
'hierarchical' is true, the descendant trees of terms in both parameters will
be excluded from matched terms.

Props tott, webord, MikeHansenMe.
Fixes #12981.

git-svn-id: https://develop.svn.wordpress.org/trunk@34696 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 19:11:12 +00:00
Aaron Jorbin f765605336 Cleanup image size in unit tests
This helps prevent test leakage that can cause Tests_Media::test_add_image_size to break.

See #33968



git-svn-id: https://develop.svn.wordpress.org/trunk@34694 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 17:47:24 +00:00
Gary Pendergast ce14a63214 Permalinks: Add pretty permalinks for unattached attachments.
Previously, unattached attachments would have unsightly `/?attachment_id=1` URLs. As we've moved away from attachments being specifically attached to posts, instead being Media items, this has made the unattached URLs a more common occurrence.

We can breath easy once more, knowing that the world is a little bit safer from the horror of unnecessarily ugly URLs.

Props SergeyBiryukov, wonderboymusic, pento.

Fixes #1914.



git-svn-id: https://develop.svn.wordpress.org/trunk@34690 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 09:41:14 +00:00
Drew Jaynes f270e7a03e Tests: Relocate tests for general-template.php to a more logically-placed (and named) file, tests/general/template.php.
See #34070.


git-svn-id: https://develop.svn.wordpress.org/trunk@34688 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 05:51:14 +00:00
Drew Jaynes 6f6f62b6e5 Tests: Consolidate author-template tests into a single, more logically-placed file, tests/user/author.php.
See #34070.


git-svn-id: https://develop.svn.wordpress.org/trunk@34687 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 05:37:00 +00:00
Scott Taylor 1ac3ba0828 Allow `wp_get_archives()` to accept `post_type` as an arg.
Adds unit test.

Fixes #21596.


git-svn-id: https://develop.svn.wordpress.org/trunk@34686 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 05:10:10 +00:00
Gary Pendergast 070b65dcfc Rewrite: Redirect attachment URLs when their slug changes.
Using the same logic that we use to redirect posts when their slug changes, we can provide the same functionality for attachments. Attachment pages are posts, too.

Props swissspdy.

Fixes #34043.



git-svn-id: https://develop.svn.wordpress.org/trunk@34685 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 04:57:02 +00:00
Scott Taylor 9bffa403dd XML-RPC: add a unit test for `mw.editPost`.
See #16980.


git-svn-id: https://develop.svn.wordpress.org/trunk@34682 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 04:27:57 +00:00
Scott Taylor 948ab018d2 XML-RPC: calculate the proper offset for GMT in `wp.newPost`, `mw.newPost`, and `mw.editPost` when `post_date` is set, `wp.editComment` when `comment_date` is set. `post|comment_date` is assumed to be GMT. This is only true if the timezone string for the site matches GMT.
Adds unit tests for each.

Props smerriman, justdaiv, wonderboymusic.
Fixes #30429.


git-svn-id: https://develop.svn.wordpress.org/trunk@34681 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 04:04:16 +00:00
Boone Gorges 16e0cc873b Add unit tests for `post_exists()`.
Props MikeHansenMe.
See #34012.

git-svn-id: https://develop.svn.wordpress.org/trunk@34680 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 04:02:00 +00:00
Boone Gorges 36af857315 Don't require explicit taxonomy when getting terms by term_taxonomy_id.
Props wonderboymusic.
Fixes #30620.

git-svn-id: https://develop.svn.wordpress.org/trunk@34679 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 03:51:11 +00:00
Drew Jaynes 58d7f89bf7 Tests: Flush rewrite rules between tests in an attempt to avoid permalinks pollution in `Tests_Author_Template`.
See #30355.


git-svn-id: https://develop.svn.wordpress.org/trunk@34678 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 02:18:55 +00:00
Drew Jaynes 3edc3b46f2 Introduce `get_the_author_posts_link()`, which returns the HTML link to the author page for the current post's author.
`the_author_posts_link()` has in-turn been converted into a wrapper, with most of its logic moved to the new function.

Adds tests for the new function.

Props chipbennett, zrothauser, wonderboymusic, DrewAPicture.
Fixes #30355.


git-svn-id: https://develop.svn.wordpress.org/trunk@34677 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 01:48:47 +00:00
John Blackbourn f0200152be Revert r34674 due to failures on PHP < 5.4.
See #16859


git-svn-id: https://develop.svn.wordpress.org/trunk@34675 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 01:00:17 +00:00
John Blackbourn 2183725c54 Avoid stripping square brackets from URLs, and instead correctly encode them.
Square brackets must be encoded in the path, path parameters, query parameters, and fragment, but must not be encoded in anything up to the domain and port.

Adds a bunch of tests, including square brackets in query parameters, IPv6 URLs, and several other permutations.

See #16859


git-svn-id: https://develop.svn.wordpress.org/trunk@34674 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 00:40:30 +00:00
Helen Hou-Sandi 94f596278c Sample permalink: Buttons still need the `.button` class.
Also fixes unit tests post-[34670]. The test methods have been slightly renamed because it is no longer a button. Hopefully this name will be more future-proof.

see #18306.


git-svn-id: https://develop.svn.wordpress.org/trunk@34671 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 22:06:15 +00:00
Boone Gorges f261d3ac8a Fix comment_order for single page comment threads.
The old comment pagination logic had a separate block for comment threads that
appeared on a single page. After the refactoring in [34561], all comment
pagination logic is unified.

This change ensures that 'comment_order' is respected in all scenarios.

Fixes #8071.

git-svn-id: https://develop.svn.wordpress.org/trunk@34669 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 19:29:22 +00:00
John Blackbourn ac85963ad4 Correctly slash post fields when trashing and untrashing posts.
Fixes #27550
Props dmenard, Denis-de-Bernardy


git-svn-id: https://develop.svn.wordpress.org/trunk@34668 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 19:25:05 +00:00
John Blackbourn 06caa4bb37 Avoid using `assertNotFalse()` which is only available in phpunit >= 4.0.0
See #33070


git-svn-id: https://develop.svn.wordpress.org/trunk@34664 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 16:27:18 +00:00
John Blackbourn 8823432749 Update `get_the_post_thumbnail_url()` so it returns false on failure, to bring it inline with `wp_get_attachment_image_url()`. Correct and introduce new tests.
Fixes #33070


git-svn-id: https://develop.svn.wordpress.org/trunk@34663 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 15:33:12 +00:00
Boone Gorges 05e0a3b97e Use correct 'page_id' parameter in `get_page_of_comment()`.
See #34057.

git-svn-id: https://develop.svn.wordpress.org/trunk@34660 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 15:09:34 +00:00
Gary Pendergast 6d87c4cecb Rewrite: When redirecting old slugs, include URL endpoints.
Historically, `wp_old_slug_redirect()` has only ever redirected the old slug of posts, it hasn't included URL endpoints, or worked with comment feed URLs. By adding support for these, we ensure a greater range of URLs aren't killed when the slug changes.

Props swissspdy.

Fixes #33920.



git-svn-id: https://develop.svn.wordpress.org/trunk@34659 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 06:56:54 +00:00
Aaron Jorbin 963e92a7dc Exclude external HTTP tests from multisite run
In [30298] the unit tests default confirguration was modified to exclude external-http tests.  This change was never migrated to the multisite XML configuration. The external HTTP code doesn't follow different logic in multisite, so the logic to exclude the tests then ( The external-http tests are very slow, and Wp_Http functionality is fairly isolated ) holds true here as well.

See #33968


git-svn-id: https://develop.svn.wordpress.org/trunk@34656 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 02:36:23 +00:00
Gary Pendergast 2b78c9579a WPDB: Make sure we don't run sanity checks on DB dropins.
Previously, we'd run the sanity checks if `is_mysql` was not set to `false`. This caused problems for DB drop-ins that didn't define `is_mysql` at all. Instead, we can just check if `is_mysql` is `empty()`.

Also fix some unit tests that accidently ran correctly because of the strict `false ===` comparison.

Fixes #33501.



git-svn-id: https://develop.svn.wordpress.org/trunk@34655 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 01:16:29 +00:00
Drew Jaynes 416dc6642a Tests: Add a test for the 'before' and 'after' arguments in `wp_page_menu()` when used as a fallback for `wp_nav_menu()`.
When `wp_page_menu()` is used as a fallback for `wp_nav_menu()`, the `before` and `after` arguments should be set and output as `<ul>` and `</ul>`, respectively.

See #11095. See [34653].


git-svn-id: https://develop.svn.wordpress.org/trunk@34654 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-28 00:46:19 +00:00
John Blackbourn cb66358b9b Switch several assertions to `assertNotWPError()` so more context is provided when the assertion fails.
git-svn-id: https://develop.svn.wordpress.org/trunk@34646 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-27 22:26:16 +00:00
John Blackbourn a0be6bbb12 Don't set `CURLOPT_CAINFO` when `sslverify` is false when sending HTTP API requests through cURL. This avoids sending redundant information to cURL, and avoids a bug in Apple's SecureTransport library which causes a request to fail when a CA bundle is set but certificate verification is disabled.
This fixes issues with local HTTPS requests (eg. WP Cron) on OS X where cURL is using SecureTransport instead of OpenSSL.

Fixes #33978


git-svn-id: https://develop.svn.wordpress.org/trunk@34639 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-27 21:37:00 +00:00
John Blackbourn 5ff16465f2 Introduce `WP_UnitTestCase::assertNotWPError()` for when a test needs to assert that something is, well, not a `WP_Error`.
See #33978


git-svn-id: https://develop.svn.wordpress.org/trunk@34638 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-27 21:28:26 +00:00
Scott Taylor 51b3eb592d After [34629], update unit tests to reflect this change.
See #32093.


git-svn-id: https://develop.svn.wordpress.org/trunk@34633 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-27 18:29:53 +00:00
Boone Gorges eb6430708b Add test for `get_term_by( 'slug' )` behavior with accented chars.
When passing a value of 'slug' to `wp_insert_term()` that contains non-ASCII
characters, WordPress converts accented characters to non-accented versions.
(See `sanitize_title()` and `remove_accents()`.) The same conversion happens
when fetching when fetching a term using a slug. In this way, it's possible to
create a term and fetch it using the same accented string, even though the slug
is actually stored with non-accented characters.

See #16282.

git-svn-id: https://develop.svn.wordpress.org/trunk@34628 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-27 16:31:47 +00:00
Boone Gorges 148d6a37fe Move `get_term_by()` tests to their own file.
git-svn-id: https://develop.svn.wordpress.org/trunk@34627 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-27 16:09:12 +00:00
Boone Gorges 8dc7bd8091 Add unit test verifying that 60 char `user_login` is valid.
Props ruudjoyo.
Fixes #33793.

git-svn-id: https://develop.svn.wordpress.org/trunk@34626 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-27 15:41:11 +00:00
Boone Gorges 307c3ca81f `WP_Comment::get_children()` test should be order-agnostic.
See #8071.

git-svn-id: https://develop.svn.wordpress.org/trunk@34623 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-27 02:00:49 +00:00
John Blackbourn 7e5f54d5ef Add function signature tests for the pluggable functions in wp-admin/includes/schema.php and wp-admin/includes/upgrade.php.
See #33867


git-svn-id: https://develop.svn.wordpress.org/trunk@34608 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 22:03:53 +00:00
John Blackbourn 4196a0751c Add function signature tests for the pluggable functions in `wp-includes/cache.php`.
See #33867


git-svn-id: https://develop.svn.wordpress.org/trunk@34607 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 22:02:15 +00:00
Aaron Jorbin 7894562b50 Revert change from true to false in multisite upload test
This change was introduced in [34601]. 0 is a special snowflake. The code treats it as if it should fall back to the default, rather than respecting 0 as 0.  Essentially, 0 means 100.  WAT? This has been discussed previusly in https://core.trac.wordpress.org/ticket/19538#comment:10.  This test should return True right now, but the behavior should be discussed and in the future 0 may mean 0.

See #34037
Props jorbin, boonebgorges



git-svn-id: https://develop.svn.wordpress.org/trunk@34606 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 20:58:22 +00:00
Boone Gorges 19b0ea5a8c Remove failing xmlrpc upload test.
This test was added [34577], but shouldn't have been, because the bug it
describes has not been fixed.

See #21292.

git-svn-id: https://develop.svn.wordpress.org/trunk@34604 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 20:31:57 +00:00
Scott Taylor 7cd7d4622c After [34601], some more cleanup.
git-svn-id: https://develop.svn.wordpress.org/trunk@34602 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 19:28:34 +00:00
Scott Taylor 4470cbf7e3 After [34577] (not because of), uncover and fix some horrifying anomalies in `Tests_Multisite_Site`.
git-svn-id: https://develop.svn.wordpress.org/trunk@34601 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 19:10:12 +00:00
Aaron Jorbin aedc063418 Use an http URL rather then an https URL for tests
Travis doesn't properly support SSL on older versions of PHP. Since we don't test for SSL support in all of the tests, this can cause these tests to fail.  This changes a URL introduced in [34568]

See #33968



git-svn-id: https://develop.svn.wordpress.org/trunk@34600 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 17:47:24 +00:00
Boone Gorges eb8b241559 Improve post field lazyloading for comments.
[34583] modified comment queries so that all post fields are no longer loaded
by default. Instead, they are loaded only when requested on individual comment
objects. This changeset improves that flow:

* `WP_Comment` magic methods `__isset()` and `__get()` should only load the post when a post field is being requested.
* The new `update_comment_post_cache` argument for `WP_Comment_Query` allows developers to specify that, when comments are queried, all of the posts matching those comments should be loaded into cache with a single DB hit. This parameter defaults to false, since typical comment queries are linked to a single post.

Fixes #27571.

git-svn-id: https://develop.svn.wordpress.org/trunk@34599 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 16:01:05 +00:00
Scott Taylor 881808bb11 XML-RPC: in `wp_xmlrpc_server::wp_editTerm()`, check `! empty` when applying `parent` logic.
Adds unit tests.

Props hrishiv90, markoheijnen, sam2kb.
Fixes #21977.


git-svn-id: https://develop.svn.wordpress.org/trunk@34580 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 05:30:34 +00:00
Scott Taylor 97a84eb7a7 XML-RPC: add a `wp_uploadFile` unit test.
Props MikeHansenMe.
See #21292.


git-svn-id: https://develop.svn.wordpress.org/trunk@34577 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 04:57:29 +00:00
Scott Taylor 9cf6b6f2d0 XML-RPC: In `wp_xmlrpc_server::mw_newPost()`, if `$dateCreated` is not set, don't set `post_date` and `post_date_gmt`. It calls `wp_insert_post()`, which will handle it correctly. The problem was drafts being created and GMT date being set. It shouldn't be.
Adds unit test.

Fixes #16985.


git-svn-id: https://develop.svn.wordpress.org/trunk@34572 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 03:37:53 +00:00
Scott Taylor 0d3da57a9a XML-RPC: `wp.getComments` should be allowed to return approved comments to those without the `'moderate_comments'` cap.
Adds (rewrites) unit tests from 4 years ago that we never committed because....

Props wonderboymusic, koke, ericmann, nprasath002.
Fixes #17981.


git-svn-id: https://develop.svn.wordpress.org/trunk@34570 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 02:48:47 +00:00
Scott Taylor e09edc2d7f Comments: in `WP_Comment::get_children()`, accept an array so that the values for `format`, `status`, `hierarchical`, and `orderby` can be passed, instead of just `format`. The defaults for `get_comments()` include `status = 'all'` and `orderby = ''` - which is no bueno.
For threaded comments, we need comments to be retrieved within bounds, so logged-out users don't see unmoderated comments on the front end, etc.

Updates unit tests.

See #8071.


git-svn-id: https://develop.svn.wordpress.org/trunk@34569 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 02:24:17 +00:00
Aaron Jorbin bc451880e5 Stop hitting SVN for http tests
The automated tests can fail due to svn. Change the tests to use a WordPress CDN image.

see #33968



git-svn-id: https://develop.svn.wordpress.org/trunk@34568 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-26 00:39:51 +00:00
Weston Ruter 78b73c8906 Customizer: Defer embedding widget controls to improve DOM performance and initial load time.
The Menu Customizer feature includes a performance technique whereby the controls for nav menu items are only embedded into the DOM once the containing menu section is expanded. This commit implements the same DOM deferral for widgets but goes a step further than just embedding the controls once the widget area's Customizer section is expanded: it also defers the embedding of the widget control's form until the widget is expanded, at which point the `widget-added` event also fires to allow any additional widget initialization to be done. The deferred DOM embedding can speed up initial load time by 10x or more. This DOM deferral also yields a reduction in overall memory usage in the browser process.

Includes changes to `wp_widget_control()` to facilitate separating out the widget form from the surrounding accordion container; also includes unit tests for this previously-untested function. Also included are initial QUnit tests (finally) for widgets in the Customizer.

Fixes #33901.


git-svn-id: https://develop.svn.wordpress.org/trunk@34563 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 21:01:46 +00:00
Boone Gorges 0b7e8399b0 Force comment pagination on single posts.
Previously, the 'page_comments' toggle allowed users to disable comment
pagination. This toggle was only superficial, however. Even with
'page_comments' turned on, `comments_template()` loaded all of a post's
comments into memory, and passed them to `wp_list_comments()` and
`Walker_Comment`, the latter of which produced markup for only the
current page of comments. In other words, it was possible to enable
'page_comments', thereby showing only a subset of a post's comments on a given
page, but all comments continued to be loaded in the background. This technique
scaled poorly. Posts with hundreds or thousands of comments would load slowly,
or not at all, even when the 'comments_per_page' setting was set to a
reasonable number.

Recent changesets have addressed this problem through more efficient tree-
walking, better descendant caching, and more selective queries for top-level
post comments. The current changeset completes the project by addressing the
root issue: that loading a post causes all of its comments to be loaded too.

Here's the breakdown:

* Comment pagination is now forced. Setting 'page_comments' to false leads to evil things when you have many comments. If you want to avoid pagination, set 'comments_per_page' to something high.
* The 'page_comments' setting has been expunged from options-discussion.php, and from places in the codebase where it was referenced. For plugins relying on 'page_comments', we now force the value to `true` with a `pre_option` filter.
* `comments_template()` now queries for an appropriately small number of comments. Usually, this means the `comments_per_page` value.
* To preserve the current (odd) behavior for comment pagination links, some unholy hacks have been inserted into `comments_template()`. The ugliness is insulated in this function for backward compatibility and to minimize collateral damage. A side-effect is that, for certain settings of 'default_comments_page', up to 2x the value of `comments_per_page` might be fetched at a time.
* In support of these changes, a `$format` parameter has been added to `WP_Comment::get_children()`. This param allows you to request a flattened array of comment children, suitable for feeding into `Walker_Comment`.
* `WP_Query` loops are now informed about total available comment counts and comment pages by the `WP_Comment_Query` (`found_comments`, `max_num_pages`), instead of by `Walker_Comment`.

Aside from radical performance improvements in the case of a post with many
comments, this changeset fixes a bug that caused the first page of comments to
be partial (`found_comments` % `comments_per_page`), rather than the last, as
you'd expect.

Props boonebgorges, wonderboymusic.
Fixes #8071.

git-svn-id: https://develop.svn.wordpress.org/trunk@34561 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 20:39:18 +00:00
Scott Taylor a9e30d8e94 XML-RPC: Introduce the concept of unit testing to `wp_xmlrpc_server::wp_newComment()`:
* Don't allow comments to be created for posts that have `comment_status` set to `'closed'`
* Set some magic props on `WP_User` to vars before passing them to `wp_xmlrpc_server::escape()`

Props wonderboymusic, jesin.
Fixes #27471.


git-svn-id: https://develop.svn.wordpress.org/trunk@34559 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 20:19:19 +00:00
Boone Gorges a6d1621736 Hierarchical comment query tests should be order-agnostic.
Travis-CI and other test environments can create weird race conditions.

See #8071.

git-svn-id: https://develop.svn.wordpress.org/trunk@34550 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 15:28:56 +00:00
Boone Gorges e1b44f5203 Introduce hierarchical query support to `WP_Comment_Query`.
Comments can be threaded. Now your query can be threaded too! Bonus: it's
not totally insane.

* The new `$hierarchical` parameter for `WP_Comment_Query` accepts three values:
  * `false` - Default value, and equivalent to current behavior. No descendants are fetched for matched comments.
  * `'flat'` - `WP_Comment_Query` will fetch the descendant tree for each comment matched by the query paramaters, and append them to the flat array of comments returned. Use this when you have a separate routine for constructing the tree - for example, when passing a list of comments to a `Walker` object.
  * `'threaded'` - `WP_Comment_Query` will fetch the descendant tree for each comment, and return it in a tree structure located in the `children` property of the `WP_Comment` objects.
* `WP_Comment` now has a few utility methods for fetching the descendant tree (`get_children()`), fetching a single direct descendant comment (`get_child()`), and adding anothing `WP_Comment` object as a direct descendant (`add_child()`). Note that `add_child()` only modifies the comment object - it does not touch the database.

Props boonebgorges, wonderboymusic.
See #8071.

git-svn-id: https://develop.svn.wordpress.org/trunk@34546 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 15:12:09 +00:00
Boone Gorges 8e955c4805 Improve pagination internals in `WP_Comment_Query`.
`WP_Comment_Query` will now report the total number of comments matching the
query params (`comments_found`), as well as the total number of pages required
to display these comments (`max_num_pages`). Because `SQL_CALC_FOUND_ROWS`
queries can introduce a lot of overhead in some cases, we disable the feature
by default. Pass `no_found_rows=false` to `WP_Comment_Query` to enable the
count. (We use the negative parameter name 'no_found_rows' for parity with
`WP_Query`.)

Props wonderboymusic, boonebgorges.
See #8071.

git-svn-id: https://develop.svn.wordpress.org/trunk@34544 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 14:34:20 +00:00
boonebgorges 4b83b005d2 Don't run `get_page_of_comment()` cache test on Multisite.
`get_page_of_comment()` uses `get_option()`, and WP_INSTALLING earlier in the
test suite causes `get_option()` to miss the cache. See #31130.

See #11334.

git-svn-id: https://develop.svn.wordpress.org/trunk@34540 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 13:54:02 +00:00
Boone Gorges a160be35b1 Bust term query cache when modifying term meta.
The 'last_changed' incrementor is used to invalidate the `get_terms()` query
cache. Since `get_terms()` queries may reference 'meta_query', changing term
metadata could change the results of the queries. So we invalidate the cache
on add, delete, and update.

See #10142.

git-svn-id: https://develop.svn.wordpress.org/trunk@34538 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 13:46:36 +00:00
Boone Gorges 7e44a2fef7 Use `WP_Comment_Query` in `get_page_of_comment()`.
This change allows `get_page_of_comment()` to use `WP_Comment_Query`'s native
caching mechanisms.

Props boonebgorges, Viper007Bond, wmertens, jeremyfelt.
Fixes #11334.

git-svn-id: https://develop.svn.wordpress.org/trunk@34535 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 05:10:40 +00:00
Boone Gorges 4da03f3cfc Allow metadata to be attached to comment at time of creation.
The new `$comment_meta` parameter of `wp_insert_comment()` allows an array of
key/value pairs to be passed when creating a comment. These pairs are then
stored as commentmeta when the comment has been created.

Props tellyworth, wonderboymusic.
Fixes #12431.

git-svn-id: https://develop.svn.wordpress.org/trunk@34533 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 04:40:30 +00:00
Boone Gorges 0dc1f270ec After [34529], fix multisite site creation test.
The test `Tests_Multisite_Site::test_created_site_details()` checks for tables
that should be empty on a newly created MS site. `termmeta` is now one of those
tables.

See #10142.

git-svn-id: https://develop.svn.wordpress.org/trunk@34532 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 04:31:52 +00:00
Boone Gorges 039955d5cd Introduce 'paged' parameter for `WP_User_Query`.
This is an alternative to using 'offset', and manually calculating pagination.
Note that 'paged' works only in conjunction with 'number', the latter of which
provides the per-page value.

Props sebastian.pisula.
Fixes #25145.

git-svn-id: https://develop.svn.wordpress.org/trunk@34531 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 04:25:20 +00:00
Boone Gorges 3425177325 Introduce metadata for taxonomy terms.
Adds a new table to the database schema (`wp_termmeta`), and a set of
`*_term_meta()` API functions. `get_terms()` and `wp_get_object_terms()`
now also support 'meta_query' parameters, with syntax identical to other
uses of `WP_Meta_Query`.

When fetching terms via `get_terms()` or `wp_get_object_terms()`, metadata for
matched terms is preloaded into the cache by default. Disable this behavior
by setting the new `$update_term_meta_cache` paramater to `false`.

To maximize performance, within `WP_Query` loops, the termmeta cache is *not*
primed by default. Instead, we use a lazy-loading technique: metadata for all
terms belonging to posts in the loop is loaded into the cache the first time
that `get_term_meta()` is called within the loop.

Props boonebgorges, sirzooro.
See #10142.

git-svn-id: https://develop.svn.wordpress.org/trunk@34529 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-25 03:58:59 +00:00
Scott Taylor 3e46dd8b92 Comments: In `get_comment_statuses()`, also return `trash`.
XML-RPC: In `wp_xmlrpc_server::wp_editComment()`, allow comments to be trashed.

Introduce unit tests for `wp_editComment` in `xmlrpc/*` #NeverForget

Props tyxla, wonderboymusic.
Fixes #30965.


git-svn-id: https://develop.svn.wordpress.org/trunk@34524 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 21:47:51 +00:00
Scott Taylor 55bb8b8c0b Comments: add a `'comment_excerpt_length'` filter to `get_comment_excerpt()`.
Create the first ever unit tests for `get_comment_excerpt()`.

Props dannydehaan, wonderboymusic.
Fixes #27526.


git-svn-id: https://develop.svn.wordpress.org/trunk@34520 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 21:04:16 +00:00
John Blackbourn c5a336d664 Use `WP_TESTS_DOMAIN` where it should be used in tests in place of hard-coded uses of `example.org`.
Also corrects a test value in the data provider for `Tests_Sanitize_Option::test_sanitize_option()` which was only consequentially passing.

Fixes #34000


git-svn-id: https://develop.svn.wordpress.org/trunk@34519 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 21:01:10 +00:00
John Blackbourn b415937e4a Another missed file from [34172].
See #33877


git-svn-id: https://develop.svn.wordpress.org/trunk@34518 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-24 20:32:49 +00:00
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