This was leftover code from the previous implementation, which used a `foreach()`
loop. See [29901].
Props nofearinc.
See #29738, #29718.
git-svn-id: https://develop.svn.wordpress.org/trunk@29931 602fd350-edb4-49c9-b593-d223f7449a82
`_doing_it_wrong()` notices are now generated when passing out-of-range values
(`month=13`) or invalid dates (`2014-02-29`).
Includes unit tests.
Props ChriCo.
Fixes#25834.
git-svn-id: https://develop.svn.wordpress.org/trunk@29925 602fd350-edb4-49c9-b593-d223f7449a82
This enhancement makes it possible to filter post, comment, and other queries
by date in ways that are arbitrarily complex, using mixed AND and OR relations.
Includes unit tests for the new syntax. In a few places, the existing unit
tests were slightly too strict (such as when checking the exact syntax of a SQL
string); these existing tests have been narrowed.
Props boonebgorges.
Fixes#29822.
git-svn-id: https://develop.svn.wordpress.org/trunk@29923 602fd350-edb4-49c9-b593-d223f7449a82
* Move `ms.php` to `multisite.php`
* Create `multisite.php` under directories `option/` and `user/` to better match existing structure.
* Create a `multisite/` directory containing `bootstrap.php`, `site.php`, and `network.php` for very multisite specific testing.
* Add unit test groups ms-site, ms-user, ms-option, ms-network, and ms-bootstrap.
Fixes#29896
git-svn-id: https://develop.svn.wordpress.org/trunk@29916 602fd350-edb4-49c9-b593-d223f7449a82
* Add a helper function, `wp_get_last_changed()`, to retrieve a last-modified timestamp by cache group
* When caching a term, also make cache entries for slug and name via `slug:{$term_id}` and `name:{$term_id}` keys in the `$taxonomy:$last_changed` bucket that reference the term_id
* In `clean_term_cache()` and `update_term_cache()`, respect `$_wp_suspend_cache_invalidation`
* Original term cache entries maintain BC
Adds unit tests.
Props wonderboymusic, tollmanz, boonebgorges.
Fixes#21760.
git-svn-id: https://develop.svn.wordpress.org/trunk@29915 602fd350-edb4-49c9-b593-d223f7449a82
IN clauses that are connected by OR require only a single table join. To avoid
extraneous joins, keep track of generated table aliases, and let sibling
clauses piggy-back on those aliases when possible.
Introduces WP_Tax_Query::sanitize_relation() to reduce some repeated code.
Adds unit tests to verify the JOIN consolidation, and integration tests for
cases where JOINS are being combined.
Props boonebgorges, otto42, jakub.tyrcha.
Fixes#18105.
git-svn-id: https://develop.svn.wordpress.org/trunk@29902 602fd350-edb4-49c9-b593-d223f7449a82
These new values for the 'operator' parameter make it possible to filter items
that have no term from a given taxonomy, or any term from a given taxonomy.
Includes unit tests.
Fixes#29181.
git-svn-id: https://develop.svn.wordpress.org/trunk@29896 602fd350-edb4-49c9-b593-d223f7449a82
The test assumed that the active theme either had no menu locations, or a subset of 'primary' and 'secondary'. see #26900.
git-svn-id: https://develop.svn.wordpress.org/trunk@29894 602fd350-edb4-49c9-b593-d223f7449a82
Previously, tax query arguments could be joined by a single AND or OR relation.
Now, these queries can be arbitrarily nested, allowing clauses to be linked
together with multiple relations.
In a few places, WP_Query runs through a list of clauses in a tax_query in order
to set certain query vars for backward compatibility. The necessary changes have
been made to WP_Query to support this feature with the new complex structure of
tax_query. Unit tests are included for these backward compatibility fixes.
Unit tests for the new nesting syntax are included.
Props boonebgorges.
Fixes#29718. See #29738.
git-svn-id: https://develop.svn.wordpress.org/trunk@29891 602fd350-edb4-49c9-b593-d223f7449a82
Mixing LEFT and INNER JOIN in these cases results in posts with no metadata
being improperly excluded from results.
Props johnrom.
Fixes#29062.
git-svn-id: https://develop.svn.wordpress.org/trunk@29890 602fd350-edb4-49c9-b593-d223f7449a82
assertEquals() was causing problems in environments where the tests take more
than one second to run, thereby causing results to be returned in the incorrect
order.
git-svn-id: https://develop.svn.wordpress.org/trunk@29888 602fd350-edb4-49c9-b593-d223f7449a82
Previously, meta query arguments could be joined by a single AND or OR relation.
Now, these queries can be arbitrarily nested, allowing clauses to be linked
together with multiple relations.
Adds unit tests for the new nesting syntax. Modifies a few existing unit tests
that were overly specific for the old SQL syntax. Backward compatibility with
existing syntax is fully maintained.
Props boonebgorges, DrewAPicture.
See #29642.
git-svn-id: https://develop.svn.wordpress.org/trunk@29887 602fd350-edb4-49c9-b593-d223f7449a82
The integration tests for using date_query in WP_Query require the creation of
dummy post data, much of which is common between a number of tests. However,
newer tests do not require as much data, so to reduce overhead we create the
data explicitly only when we need it, instead of in the setUp() method.
See #29781.
git-svn-id: https://develop.svn.wordpress.org/trunk@29885 602fd350-edb4-49c9-b593-d223f7449a82
After using `_setup_host_request()` to test multiple domain and path combinations, use the same to set the global stack back to a domain of `WP_TESTS_DOMAIN` and path of `/`.
Fixes#29930
git-svn-id: https://develop.svn.wordpress.org/trunk@29881 602fd350-edb4-49c9-b593-d223f7449a82
A growing number of plugins and other WP-based projects use the core test
tools, such as WP_UnitTestCase, as the basis of their own tests and continuous
integration setups. At the same time, many of these third-party plugins use
custom post types and taxonomies, which are generally registered a single time
during a run of the tests: at 'init', before the testcases have run. Wiping out
these globals between tests will mess with these third-party builds.
Best practice for plugin developers is probably to clean up their own post types
and taxonomies and then reinitialize before each test. But, in the interest of
not breaking everyone's builds, the core test suite will not enforce this.
Fixes#29827.
git-svn-id: https://develop.svn.wordpress.org/trunk@29869 602fd350-edb4-49c9-b593-d223f7449a82
This change brings return values for failures of this sort in line with other
failed lookups in term_exists(): a null value is now returned in all cases
where the queried term is not found.
Adds unit test for the sanitization issue. Modifies existing unit test to
reflect the change in return value for empty term strings.
Props boonebgorges, georgestephanis.
Fixes#29589.
git-svn-id: https://develop.svn.wordpress.org/trunk@29865 602fd350-edb4-49c9-b593-d223f7449a82
These unit tests cover the expected vehaviour of certain combinations of URL's, but makes no attempt to test invalid URL structures, as PHP's behavious for invalid URL's is undefined (Some will be treated as paths, others fail, and it varies between PHP 5.4.7+ and <5.4.7).
This change also makes WP_HTTP::parse_url() protected in order to allow unit testing.
See #28001, #29886
git-svn-id: https://develop.svn.wordpress.org/trunk@29864 602fd350-edb4-49c9-b593-d223f7449a82
Passing a 0 (or '0') as the 'parent' param of term_exists() should limit
results to terms with no parent.
Adds unit test.
Fixes#29851.
git-svn-id: https://develop.svn.wordpress.org/trunk@29863 602fd350-edb4-49c9-b593-d223f7449a82
Using get_term_by() rather than direct SQL queries to fetch the alias term
fixes a number of issues:
* Object cache for aliased term is properly cleared after update.
* If the aliased term is in the object cache, it's served from there, saving a database query.
* Duplicate 'edit_terms' and 'edited_terms' hooks can be removed.
* Fix a PHP notice when the 'alias_of' term is not found.
* Prevent the incorrect creation of a new term group for the primary term when the 'alias_of' term is not found.
Adds unit tests for 'alias_of' functionality in both functions.
Fixes#29848.
git-svn-id: https://develop.svn.wordpress.org/trunk@29862 602fd350-edb4-49c9-b593-d223f7449a82
Registering a post type or taxonomy during a unit test causes modifications to
global variables. If the test fails to clean up these globals - either by
neglecting to call _unregister_post_type()/_unregister_taxonomy() at all or by
failing before getting a chance to do so - tests that run later in the suite
can fail, leading to much gnashing of teeth. Wiping all taxonomies and
restoring to the defaults before each test ensures that we always start with a
clean slate.
Fixes#29827.
git-svn-id: https://develop.svn.wordpress.org/trunk@29860 602fd350-edb4-49c9-b593-d223f7449a82
When using legacy `meta_key`, `meta_value`, etc. arguments in `WP_Query`,
they're converted into the first clause of a `meta_query`. By using that
clause instead of the original arguments, we make sure that behavior is
consistent between the two available formats.
props boonebgorges.
fixes#16814.
git-svn-id: https://develop.svn.wordpress.org/trunk@29855 602fd350-edb4-49c9-b593-d223f7449a82
A valid relative URL could be mistaken for an absolute url if it contained a :// in any position of the url.
Fixes#28001
git-svn-id: https://develop.svn.wordpress.org/trunk@29850 602fd350-edb4-49c9-b593-d223f7449a82
Not having the count caused queries with 'fields' values of 'id=>name' and
'id=>slug' to return incorrect results when querying a hierarchical taxonomy
with 'hide_empty=true'.
Includes unit tests for get_terms() when using various combinations of 'fields',
'hide_empty', and 'hierarchical' arguments.
Props technical_mastermind.
Fixes#29859.
git-svn-id: https://develop.svn.wordpress.org/trunk@29845 602fd350-edb4-49c9-b593-d223f7449a82
Previously, a 'user_nicename' parameter passed into the function was
unsanitized. This could result in a mismatch between the sanitized nicename
generated automatically at user creation, resulting in broken author archive
permalinks.
Props joemcgill.
Fixes#29696.
git-svn-id: https://develop.svn.wordpress.org/trunk@29819 602fd350-edb4-49c9-b593-d223f7449a82
* Exhaustive tests for publicly available functionality of WP_Tax_Query.
* For tests that are related to the tax_query argument as used in WP_Query, move to tests/post/query.php.
* Add some tax_query tests to cover single vs multiple queries using AND and OR; various values for 'field'; various values for 'operator'.
* Improve test names.
* Correct @group annotations.
* Improve performance of some WP_Query-related tests by declaring 'update_post_meta/term_cache' false.
Fixes#29718
git-svn-id: https://develop.svn.wordpress.org/trunk@29805 602fd350-edb4-49c9-b593-d223f7449a82
* More complete test coverage for publicly available methods of WP_Meta_Query.
* Move tests that rely on WP_Query (via the meta_query parameter) to tests/post/query.php.
* Better coverage for basic use cases of 'meta_query', including all values of 'compare' and default values of 'key', 'value', and 'compare'.
* Improve performance for tests that run WP_Query, by retrieving only post IDs and not prefetching postmeta and post terms.
* Add 'public' visibility keywords to test methods.
* Whitespace cleanup.
Fixes#29560
git-svn-id: https://develop.svn.wordpress.org/trunk@29799 602fd350-edb4-49c9-b593-d223f7449a82
These include an exhaustive set of tests for term_exists(), as well as tests
for wp_insert_term() that demonstrate failure when attempting to create a
duplicate term.
Props simonwheatley for an initial patch.
See #22023.
git-svn-id: https://develop.svn.wordpress.org/trunk@29798 602fd350-edb4-49c9-b593-d223f7449a82
* Don't run non-numeric values through intval() for sanitization; this transforms them into 1s and 0s, which can cause unintended results.
* Be more generous about numeric array keys (don't require 0 and 1) in BETWEEN and NOT BETWEEN clauses.
Fixes#29801.
git-svn-id: https://develop.svn.wordpress.org/trunk@29797 602fd350-edb4-49c9-b593-d223f7449a82
- Unit tests for all publicly available functionality in WP_Date_Query
- Improve performance of date_query tests that use WP_Query
Fixes#29781
git-svn-id: https://develop.svn.wordpress.org/trunk@29793 602fd350-edb4-49c9-b593-d223f7449a82
* Revert parts of [28773] and [28727] and [29748].
* Do not crash PHP. Make the shortcode quantifier possessive to avoid backtracks.
* Reduce backtracking in long HTML comments by 100x.
* Do not ignore unclosed HTML comments.
* Do not break unregistered shortcodes, e.g. `[hello attr="value"]`.
* Do not break HTML in shortcode attributes, e.g. `[hello attr="<"]`.
* Do not match for shortcodes when there is extra whitespace, e.g. `[ hello ]`.
* Add unit tests to show #12690 was not fully resolved.
* Tested PHP 5.2.4, 5.2.13, 5.4.32, and 5.5.8.
Adds/modifies unit tests.
Props miqrogroove.
See #29557.
git-svn-id: https://develop.svn.wordpress.org/trunk@29781 602fd350-edb4-49c9-b593-d223f7449a82
Adds unit tests that use `DOMDocument` since `assertTag` is being deprecated - see #29545, [29746].
Props obenland, wonderboymusic.
Fixes#29636.
git-svn-id: https://develop.svn.wordpress.org/trunk@29780 602fd350-edb4-49c9-b593-d223f7449a82