This is a revert of [30494], [30492], [30347], and [30334]. The latter
changeset was a revert of [30336], which was a revert of [30241].
Watch for Term Splitting, Version III in version 4.2, coming soon to a
WordPress trunk near you.
See #30335, #5809.
git-svn-id: https://develop.svn.wordpress.org/trunk@30585 602fd350-edb4-49c9-b593-d223f7449a82
These tests were written to use the `assertImageAtAlpha()` helper method, whose
internals were specific to GD. As a result, the tests could not pass. This
changeset introduces GD- and Imagick-specific versions of this method.
Props voldemortensen.
Fixes#24871.
git-svn-id: https://develop.svn.wordpress.org/trunk@30549 602fd350-edb4-49c9-b593-d223f7449a82
This change fixes broken builds on older versions of MySQL. See #30462.
Assertions regarding indeterminate secondary ORDER BY clauses will go in
separate test methods. See #30478.
git-svn-id: https://develop.svn.wordpress.org/trunk@30548 602fd350-edb4-49c9-b593-d223f7449a82
This fixes the unit tests that fail in earlier versions, see #30471 for fixing this globally in `wp_json_encode()`.
git-svn-id: https://develop.svn.wordpress.org/trunk@30534 602fd350-edb4-49c9-b593-d223f7449a82
This ensures that the test is not polluted by permalink structure changes in
earlier tests.
git-svn-id: https://develop.svn.wordpress.org/trunk@30529 602fd350-edb4-49c9-b593-d223f7449a82
It should be defined in a common library file so that all tests have access to
it, even when run in isolation.
See [30345], #21212.
git-svn-id: https://develop.svn.wordpress.org/trunk@30528 602fd350-edb4-49c9-b593-d223f7449a82
In general, skipped tests should live only in patches, which are committed at
the same time that the corresponding bug is fixed. In cases where it's
necessary to skip a test, use `markTestSkipped()` to declare this fact
explicitly.
We continue to check Trac when using `WP_UnitTestCase` to run non-core tests.
See #30284.
git-svn-id: https://develop.svn.wordpress.org/trunk@30526 602fd350-edb4-49c9-b593-d223f7449a82
* Provide sample data that is actually encoded in Big5.
* Do some actual assertions against that data.
Props akumria.
Fixes#30455.
git-svn-id: https://develop.svn.wordpress.org/trunk@30525 602fd350-edb4-49c9-b593-d223f7449a82
In `sanitize_title_with_dashes()` and `sanitize_user()` tests, we break large
test methods into smaller ones in order to isolate those that actually describe
the bug being reported in ticket #10823. The unit tests that are continuing to
fail have been attached as a patch to that ticket.
See #30284.
git-svn-id: https://develop.svn.wordpress.org/trunk@30515 602fd350-edb4-49c9-b593-d223f7449a82
Because `setUpBeforeClass()` is called statically and creates its own factory
object, the iterator logic from previous tests is not carried over to these
fixtures, and we risk the possibility of user_email clashes when the tests are
run in certain limited configurations.
git-svn-id: https://develop.svn.wordpress.org/trunk@30512 602fd350-edb4-49c9-b593-d223f7449a82
`test_revision_order()` was written ([28541], #26042) to ensure that revision
order was properly preserved in two different cases: (1) where the post_date
varied (in which case the revisions would be sorted by post_date DESC) and
(2) where the post_date was the same (in which case sorting would fall back on
ID DESC). In an attempt to ensure that both of these scenarios arose in the
context of a single test, 100 posts were created. We can make the process far
more efficient by manually creating the revisions with the post_dates
explicitly declared, and splitting the two different cases into two separate
test methods.
This test was previously the single worst offender in the entire suite, taking
upwards of 15 seconds to run. All that most maddens and torments; all that stirs
up the lees of things; all truth with malice in it; all that cracks the sinews
and cakes the brain; all the subtle demonisms of life and thought; all evil, to
crazy Boone, were visibly personified, and made practically assailable in
`test_revision_order()`.
See #30017.
git-svn-id: https://develop.svn.wordpress.org/trunk@30511 602fd350-edb4-49c9-b593-d223f7449a82
* If the split term ID is stored as 'default_category', 'default_link_category', or 'default_email_category', update it to the new ID.
* If the split term ID is associated with a nav menu item, update that piece of postmeta to the new ID.
Props mboynes.
See #30335.
git-svn-id: https://develop.svn.wordpress.org/trunk@30494 602fd350-edb4-49c9-b593-d223f7449a82
`wp_upload_dir()` includes some logic to fall back to the default site's upload directory if a specific directory for the requested site cannot be found. Because of this, if `wpmu_delete_blog()` is fired twice in a row for the same site, the main site's upload directory could be deleted as well.
This adds some checks in `wpmu_delete_blog()` so that we are confident in the site and it's upload directory's existence before dropping the site. Tests are added for when `ms_files_rewriting` is enabled or disabled.
Fixes#30121
git-svn-id: https://develop.svn.wordpress.org/trunk@30404 602fd350-edb4-49c9-b593-d223f7449a82
This behavior was broken when moving the internals to `WP_Comment_Query` in
[30098]. As a result, `get_approved_comments( 0 )` was fetching *all* approved
comments, causing performance issues.
Props dd32.
Fixes#30412.
git-svn-id: https://develop.svn.wordpress.org/trunk@30402 602fd350-edb4-49c9-b593-d223f7449a82
This improves data integrity when inserting and updating rows in the database, particularly when trying to insert emoji into posts stored with character sets that don't support emoji.
See #21212.
git-svn-id: https://develop.svn.wordpress.org/trunk@30400 602fd350-edb4-49c9-b593-d223f7449a82
* Support relative URL input.
* When the URL being made relative has another URL as a parameter, don't make the second URL relative.
Props voldemortensen.
Fixes#30373.
git-svn-id: https://develop.svn.wordpress.org/trunk@30383 602fd350-edb4-49c9-b593-d223f7449a82
The term itself does not have any cached values yet, but in some cases the new
term's taxonomy may need its cached hierarchy to be refreshed as a result of
the term splitting.
Props jorbin.
See #30335.
git-svn-id: https://develop.svn.wordpress.org/trunk@30347 602fd350-edb4-49c9-b593-d223f7449a82
Originally introduced in [30241] and reverted in [30336], term splitting is
back and better than ever. Now with *more unit tests* and *improved treatment
of child terms*!
See #30335.
git-svn-id: https://develop.svn.wordpress.org/trunk@30344 602fd350-edb4-49c9-b593-d223f7449a82
microtime is by default a string. Doing a greater then or less than check of that string is a bad idea since it uses the first part (the micro part of microtime) rather then the actual time. This adds a helper to convert microtime output into a float which we can then use to properly compare the output of microtime.
This fixes an intermittent test failure.
fixes#30336
git-svn-id: https://develop.svn.wordpress.org/trunk@30337 602fd350-edb4-49c9-b593-d223f7449a82
Splitting shared terms means assigning a new term_id to a given term_taxonomy_id.
It was uncovered that this change could cause problems for sites that have
cached the original term_id somehow - say, in postmeta - since future lookups
using that term_id will now fail.
Removing for 4.1-beta1. We'll look at improvements to backward compatibility
to try to get this back into a later beta.
Props mboynes.
See #30335.
git-svn-id: https://develop.svn.wordpress.org/trunk@30336 602fd350-edb4-49c9-b593-d223f7449a82
This test creates a dummy post and subsequently runs a query containing
`DROP PROCEDURE`. This latter query implies a `COMMIT`, which means that the
post is not cleaned up for later tests. Manually deleting the post with
`wp_delete_post()` solves this problem.
Fixes#28155.
git-svn-id: https://develop.svn.wordpress.org/trunk@30320 602fd350-edb4-49c9-b593-d223f7449a82
The external-http tests are very slow, and `Wp_Http` functionality is fairly
isolated, so the benefits of skipping these tests by default outweigh the
risks.
A `grunt phpunit:external-http` subtask has been added, to ensure that the
tests are executed during exhaustive runs of the test suite, such as in
continuous integration.
Fixes#30304.
git-svn-id: https://develop.svn.wordpress.org/trunk@30298 602fd350-edb4-49c9-b593-d223f7449a82
This change also allows stored procedures or queries made with `mysqli_multi_query()` to be flushed.
Includes unit tests.
Fixes#28155.
Props soulseekah.
git-svn-id: https://develop.svn.wordpress.org/trunk@30297 602fd350-edb4-49c9-b593-d223f7449a82
A notice was being thrown when `get_the_tags()` returned false, and `foreach()`
was run over that return value.
See [30283].
git-svn-id: https://develop.svn.wordpress.org/trunk@30295 602fd350-edb4-49c9-b593-d223f7449a82
The test has been added to #11946 and can be readded when that ticket is fixed.
Props MikeHansenMe for creating patch of current unit test
See #30284
git-svn-id: https://develop.svn.wordpress.org/trunk@30289 602fd350-edb4-49c9-b593-d223f7449a82
When the `ms_files_rewriting` flag is enabled, `ms_upload_constants()` is required to properly set upload directory constants. Once this fires, it is impossible to clean up for a non `ms_files_rewriting` test by turning the option back off.
Excluding these tests by default offer a more consistent environment overall. Any tests written for uploaded files in multisite should ideally have a correspondign test in this area.
This commit also moves existing `ms_files_rewriting` tests for `test_switch_upload_dir()`.
Fixes#30256
git-svn-id: https://develop.svn.wordpress.org/trunk@30286 602fd350-edb4-49c9-b593-d223f7449a82
It relied on the old _WPDataset technique, which is no longer used.
The test has been added to #UT30 as a patch, in case anyone wants to make
future use of it.
See #30284.
git-svn-id: https://develop.svn.wordpress.org/trunk@30285 602fd350-edb4-49c9-b593-d223f7449a82
* Better reference to post author, to avoid PHP notices.
* Code styling.
* More reliable checking of tags and categories.
Props kurtpayne.
Fixes #UT32. See #30284.
git-svn-id: https://develop.svn.wordpress.org/trunk@30283 602fd350-edb4-49c9-b593-d223f7449a82
`wp_delete_user()` doesn't remove the user from the database, which causes all
sorts of problems in certain cases.
Props jeremyfelt.
See [30277], #30017.
git-svn-id: https://develop.svn.wordpress.org/trunk@30278 602fd350-edb4-49c9-b593-d223f7449a82
Sharing these fixtures results in a speed improvement of almost one minute per
run of the test suite.
My hope is that future WordPress developers will spend this extra minute with
their loved ones, for life on this earth is short, my friends, and the moments
you spend watching WP generate test data can never again be reclaimed from the
grizzled clutches of Time, and none of us are really getting younger, I mean,
geez, have you looked in the mirror lately, Gandalf?
See #30017.
git-svn-id: https://develop.svn.wordpress.org/trunk@30277 602fd350-edb4-49c9-b593-d223f7449a82
Most of our unit tests that involve permalinks expect non-pretty permalinks;
this is the default setting for WP. However, when the test suite installs
multisite, `populate_network()` is run before WP recogizes itself as multisite,
which leads to pretty permalinks being set. This breaks a number of unit
tests in ways that are difficult to trace.
git-svn-id: https://develop.svn.wordpress.org/trunk@30267 602fd350-edb4-49c9-b593-d223f7449a82
This forcing appears to have been introduced to save unnecessary queries, but
(a) in some cases it appeared to be causing *more* queries, and (b) it caused
incorrect results when the 'exclude_tree' param of `get_terms()` called
`get_terms()` on each item in the tree using the 'child_of' param.
Fixes#30275.
git-svn-id: https://develop.svn.wordpress.org/trunk@30265 602fd350-edb4-49c9-b593-d223f7449a82
When updating an existing taxonomy term that shares its `term_id` with
another term, we generate a new row in `wp_terms` and associate the updated
term_taxonomy_id with the new term. This separates the terms, such that
updating the name of one term does not change the name of any others.
Note that this term splitting only occurs on installations whose database
schemas have been upgraded to version 30133 or higher. Note also that shared
terms are only split when run through `wp_update_term()`, as on edit-tags.php;
we will wait until a future release of WordPress to force the splitting of all
shared taxonomy terms.
Props boonebgorges, rmccue, greuben, garyc40, wonderboymusic, imath, jesin.
Fixes#5809.
git-svn-id: https://develop.svn.wordpress.org/trunk@30241 602fd350-edb4-49c9-b593-d223f7449a82
A "shared" term occurs when two entries in the `wp_term_taxonomy` table share a
single `term_id`, and thereby correspond to the same row in `wp_terms`. This
changeset stops the practice of creating shared terms: each new row in
`wp_term_taxonomy` will receive its own row in `wp_terms`. The new strategy
for term creation depends on whether the installation's database schema is up
to date for 4.1:
* If so, terms are allowed to be created with the same slug as an existing term, as long as they are in different taxonomies and do not share a parent. Thus, a new tag with the slug 'wordpress' can exist alongside a category with the slug 'wordpress'.
* If not, new terms will be forced to have unique slugs. Thus, on an installation containing a category with the slug 'wordpress', a new tag 'WordPress' will get the slug 'wordpress-2'.
Fixes#21950. See #5809.
git-svn-id: https://develop.svn.wordpress.org/trunk@30240 602fd350-edb4-49c9-b593-d223f7449a82
This parameter allows theme and plugin authors to specify the formatting they
would like on the term links as they are parsed into the taxonomy list.
Props hereswhatidid, dlh, davidjlaietta.
See #27238.
git-svn-id: https://develop.svn.wordpress.org/trunk@30209 602fd350-edb4-49c9-b593-d223f7449a82
The previous `in_array()` check was playing too loose with mixed types, such
that a string like '10_term_name' would incorrectly match a term_id 10.
Props nobinobi, realloc.
Fixes#29467.
git-svn-id: https://develop.svn.wordpress.org/trunk@30205 602fd350-edb4-49c9-b593-d223f7449a82
These tests check a number of the ways that different kinds of values for
`$terms` (integers that match term_id, strings that match term_id or name or
slug) are handled.
See #29467.
git-svn-id: https://develop.svn.wordpress.org/trunk@30204 602fd350-edb4-49c9-b593-d223f7449a82
* Rename method to `test_get_blog_details_when_site_does_not_exist()`.
* Always assume `MAX(blog_id)` is 1 and therefore always create a burner.
* Remove tests specific to `wpmu_delete_blog()` and cache, to be handled elsewhere.
* Remove extra asertions.
See #30080, #23405
git-svn-id: https://develop.svn.wordpress.org/trunk@30175 602fd350-edb4-49c9-b593-d223f7449a82
Test various arguments for `wp_get_sites()` in a more intentful way rather than in one large test. Leave tests for limit and offset together for convenience.
See #30080
git-svn-id: https://develop.svn.wordpress.org/trunk@30174 602fd350-edb4-49c9-b593-d223f7449a82
* Separate into smaller test methods.
* Remove incorrect tests. A number of assertions in the existing test have always incorrectly described the behavior of `current_theme_supports( 'post-thumbnails' )`, but no one ever noticed because the tests had been designed to bail when `_wp_render_title_tag()` did not exist. The failures finally became visible when that function was introduced in [30074].
See #18548.
git-svn-id: https://develop.svn.wordpress.org/trunk@30148 602fd350-edb4-49c9-b593-d223f7449a82
The initial `dayofweek` param sets day 1 to Sunday. This is out of step with
ISO standards, which calls Monday day 1. To maintain backward compatibility
with the existing parameter, we introduce the new `dayofweek_iso` for the
new, more compliant param.
Props mboynes.
Fixes#28063.
git-svn-id: https://develop.svn.wordpress.org/trunk@30142 602fd350-edb4-49c9-b593-d223f7449a82
Being explicit about resource type (taxonomy vs post_type) allows for the
proper resolution of conflicts when a taxonomy and post_type share a slug.
Props filosofo.
Fixes#15029.
git-svn-id: https://develop.svn.wordpress.org/trunk@30141 602fd350-edb4-49c9-b593-d223f7449a82
* Split existing tests for `domain_exists()` into many smaller tests.
* Make slightly fewer, more accurate assertions.
* Remove unnecessary site creation via factory.
See #30080
git-svn-id: https://develop.svn.wordpress.org/trunk@30114 602fd350-edb4-49c9-b593-d223f7449a82
* Fix cache key/group modification that was missed in [30073].
* Update unit tests to reflect new key/group format.
Props tollmanz.
Fixes#21760.
git-svn-id: https://develop.svn.wordpress.org/trunk@30108 602fd350-edb4-49c9-b593-d223f7449a82
The previous behavior resulted in descendant terms being improperly excluded
from the results when passing a 'parent', even when 'hierarchical' had been
set to true.
The patch also adds unit tests that demonstrate the various interactions
between the 'child_of', 'parent', and 'hierarchical' parameters of `get_terms()`.
Props landakram.
Fixes#29815.
git-svn-id: https://develop.svn.wordpress.org/trunk@30107 602fd350-edb4-49c9-b593-d223f7449a82
* Test cache after a site is deleted or flagged as deleted.
* Test tables after a site is deleted or flagged as deleted.
* Test tables and cache after the main site is deleted.
* Test site count after a site is deleted or flagged as deleted.
See #30080
git-svn-id: https://develop.svn.wordpress.org/trunk@30106 602fd350-edb4-49c9-b593-d223f7449a82
* Add support for an array of values in 'type'.
* Introduce `type__in` parameter. This duplicates 'type' but is added for better consistency with other query classes.
* Introduce `type__not_in`.
Among other things, these changes will make it easier for plugin authors to
manage the appearance of custom comment types in various WP interfaces.
Props dancameron, mordauk.
See #12668.
git-svn-id: https://develop.svn.wordpress.org/trunk@30096 602fd350-edb4-49c9-b593-d223f7449a82
If a user query includes a meta query together with a role argument,
nest the original meta query and append the role meta query with an
AND relationship.
fixes#23849, #27026.
git-svn-id: https://develop.svn.wordpress.org/trunk@30094 602fd350-edb4-49c9-b593-d223f7449a82
The changes in [30084] broke backward compatibility with interfaces that
manually passed an empty string for the value of 'status', such as on
wp-admin/edit-comments.php.
Fixes#29612.
git-svn-id: https://develop.svn.wordpress.org/trunk@30093 602fd350-edb4-49c9-b593-d223f7449a82
`setup_postdata()` is responsible for setting a number of global variables
that are used for post pagination (`$pages`, `$page`, `$nextpage`) and the
generation of post excerpts (`$more`). These variables should be sensitive to
the currently running instance of `WP_Query` - rather than the main query -
so that these features work properly inside of secondary `WP_Query` loops.
This changeset moves the logic of `setup_postdata()` into a method on `WP_Query`,
and converts `setup_postdata()` to a wrapper.
Props boonebgorges, wonderboymusic.
See #25349.
Fixes#9256, #20904.
git-svn-id: https://develop.svn.wordpress.org/trunk@30085 602fd350-edb4-49c9-b593-d223f7449a82
This change required turning the SQL concatenation into the generation of an
array, for greater flexibility.
Props karpstrucking, ebinnion.
Fixes#29612.
git-svn-id: https://develop.svn.wordpress.org/trunk@30084 602fd350-edb4-49c9-b593-d223f7449a82
When an empty string is passed as one of the clauses in the `$tax_query`
parameter, it should be discarded rather than parsed as a first-order clause.
Props tmtrademark.
Fixes#30117.
git-svn-id: https://develop.svn.wordpress.org/trunk@30031 602fd350-edb4-49c9-b593-d223f7449a82
* Don't create user during setUp(), as it's not used in every test.
* Create fewer users in `get_all` and `orderby` tests.
See #30017.
git-svn-id: https://develop.svn.wordpress.org/trunk@30017 602fd350-edb4-49c9-b593-d223f7449a82
This lets the results of a user query be sorted manually by the value of the
'include' param.
Props jipmoors.
Fixes#30064.
git-svn-id: https://develop.svn.wordpress.org/trunk@30016 602fd350-edb4-49c9-b593-d223f7449a82
Expand tests to cover additional cache and lookup scenarios. Explicitly test the reaction of `get_blog_id_from_url()` when `$drop = false` is passed to `wpmu_delete_blog()`. See #30080Fixes#30088
git-svn-id: https://develop.svn.wordpress.org/trunk@30007 602fd350-edb4-49c9-b593-d223f7449a82
* Split `test_create_and_delete_blog()` into two tests.
* Clean up number of sites created during tests.
* Remove test_getters(), move get_blog_address_by_name() test to `test_created_site_details()`
See #30080
git-svn-id: https://develop.svn.wordpress.org/trunk@30006 602fd350-edb4-49c9-b593-d223f7449a82
Disable ORDER BY by passing boolean false, an empty array, or the string
'none' to the 'orderby parameter. This mirrors the behavior of `WP_Query`.
Props psycleuk.
Fixes#29902.
git-svn-id: https://develop.svn.wordpress.org/trunk@30004 602fd350-edb4-49c9-b593-d223f7449a82
For better testability, the SQL string generated in `WP_Comment_Query::get_posts()`
is now stored as a 'request' property on the object.
See #29902.
git-svn-id: https://develop.svn.wordpress.org/trunk@30003 602fd350-edb4-49c9-b593-d223f7449a82
This prevents $current_user, $userdata, and other user-related globals from
being polluted if a previous test does not properly reset the current user.
Props nacin, mnelson4.
Fixes#29712.
git-svn-id: https://develop.svn.wordpress.org/trunk@30001 602fd350-edb4-49c9-b593-d223f7449a82
By creating less dummy data and eliminating redundant tests, we cut group
execution time by more than 50%.
See #30017.
git-svn-id: https://develop.svn.wordpress.org/trunk@29993 602fd350-edb4-49c9-b593-d223f7449a82
This old test is too resource-intensive, and duplicates the more precise
tests introduced in [29980].
See #30017.
git-svn-id: https://develop.svn.wordpress.org/trunk@29981 602fd350-edb4-49c9-b593-d223f7449a82
`comments_template()` is used by most themes to display a post's comments. It
shows all comments that have been approved, and also shows all pending comments
by the current visitor (as determined by the comment cookies). However, the
comments API previously had no way of querying for "all comments that are
either approved, or are unapproved but written by foo@example.com". The
workaround was a direct SQL query: uncached, not subject to the same filters as
other comment queries, and just generally icky.
The new `include_unapproved` parameter for `WP_Comment_Query` accepts an array
of user IDs or email addresses. Pending comments associated with users in this
array will be included in query results, regardless of the value of the 'status'
parameter. In `comments_template()`, we leap from direct SQL queries to
`get_comments()` plus `include_unapproved', striving to put right what once
went wrong.
Props boonebgorges, simonwheatley, hardy101, jesin.
Fixes#19623.
git-svn-id: https://develop.svn.wordpress.org/trunk@29965 602fd350-edb4-49c9-b593-d223f7449a82
Passing orderby=meta_value and meta_key=foo to WP_Query should require that
each matched post have a meta value with the key 'foo'. To make this
requirement compatible with meta_query params that have the relation OR, we
nest the meta_query param, and join it using AND to a meta_query clause
generated from the meta_key/meta_compare/meta_type query vars.
Fixes#25538.
git-svn-id: https://develop.svn.wordpress.org/trunk@29964 602fd350-edb4-49c9-b593-d223f7449a82
This fixes an issue that if you change WP_DEFAULT_THEME and run core unit tests, the tests fail since your theme isn't one of the hard coded lists of default themes. We need to keep this test to make sure that we update the array of default themes for use in other tests.
If we ever change the naming convention for default themes, this will need to be updated.
props nacin for initial idea
fixes#29925
git-svn-id: https://develop.svn.wordpress.org/trunk@29946 602fd350-edb4-49c9-b593-d223f7449a82
The logic used to generate clause SQL in `WP_Meta_Query` is somewhat arcane,
stemming mostly from an ongoing effort to eliminate costly table joins when
they are not necessary. By systematizing the process of looking for shareable
joins - as was done in `WP_Tax_Query` [29902] - it becomes possible to simplify
the construction of SQL queries in `get_sql_for_clause()`. Moreover, the
simplified logic is actually considerably better at identifying shareable
joins, such that certain uses of `WP_Meta_Query` will see joins reduced by 50%
or more.
Includes integration tests for a representative cross-section of the query
clause combinations that result in shared table aliases.
Props boonebgorges, sc0ttkclark.
See #24093.
git-svn-id: https://develop.svn.wordpress.org/trunk@29940 602fd350-edb4-49c9-b593-d223f7449a82
* Create half as many factory sites. See #30017
* Test the removal of a user from multiple sites.
* Expand tests to include second parameter for flagged sites.
* Remove duplicate test for deleted user.
Fixes#29996
git-svn-id: https://develop.svn.wordpress.org/trunk@29937 602fd350-edb4-49c9-b593-d223f7449a82
The 'inclusive' parameter for WP_Date_Query determines whether non-precise
dates for 'before' and 'after' will be rounded up or down. Previously, this was
supported only when 'before' and 'after' were arrays; string-formatted dates
were run through strtotime(), which rounded them all down (inclusive in the
case of after, non-inclusive in the case of before). Now, we attempt to parse
formats that look like MySQL-formatted date strings, and apply inclusive logic
to them if we recognize them successfully.
Fixes#29908.
string values. Array values support the 'inclusive
git-svn-id: https://develop.svn.wordpress.org/trunk@29936 602fd350-edb4-49c9-b593-d223f7449a82
The use of non-aliased column names (eg 'post_date' instead of 'wp_posts.post_date')
in WP_Date_Query causes SQL notices and other failures when queries involve
table joins, such as date_query combined with tax_query or meta_query. This
changeset modifies WP_Date_Query::validate_column() to add the table alias when
it can be detected from the column name (ie, in the case of core columns).
A side effect of this change is that it is now possible to use WP_Date_Query
to build WHERE clauses across multiple tables, though there is currently no
core support for the automatic generation of the necessary JOIN clauses. See
Props ew_holmes, wonderboymusic, neoxx, Viper007Bond, boonebgorges.
Fixes#25775.
git-svn-id: https://develop.svn.wordpress.org/trunk@29933 602fd350-edb4-49c9-b593-d223f7449a82
Since [29925], passing an invalid date to WP_Date_Query will generate a
_doing_it_wrong() notice. The current changeset adds the
`@expectedIncorrectUsage` flag to those existing unit tests that generate
invalid dates, such as those that test canonical redirect and is_404()
conditionals.
Fixes#25834.
git-svn-id: https://develop.svn.wordpress.org/trunk@29932 602fd350-edb4-49c9-b593-d223f7449a82
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
The shortcode callbacks for `gallery` and `playlist` check for `'RAND' == $atts['order']`, which isn't a valid value for `order`. Remove those checks and update the docs.
In `WP_Query`, if the value of `orderby` is `rand`, `order` is irrelevant and should be unset.
Adds unit tests.
Fixes#29629.
git-svn-id: https://develop.svn.wordpress.org/trunk@29760 602fd350-edb4-49c9-b593-d223f7449a82
* Expand the `wptexturize()` RegEx to include the list of registered shortcodes.
* Avoid backtracking after `[` chars by not filtering params in registered shortcodes. This will cause escaped shortcodes and their params to become texturized if not registered.
* Registered shortcode params will never be texturized, even when escaped.
* Move all tests involving unregistered shortcodes to a new and improved unit.
* Update one test involving HTML within shortcode params.
Props miqrogroove.
See #29557.
git-svn-id: https://develop.svn.wordpress.org/trunk@29748 602fd350-edb4-49c9-b593-d223f7449a82
Introduces a new get( $token ) method. get_token() would not have made sense and spurred the overall renaming. Public methods are now get, get_all, verify, create, update, destroy, destroy_others, and destroy_all.
The protected abstract methods designed for alternative implementations remain the same.
props mdawaffe.
see #20276.
git-svn-id: https://develop.svn.wordpress.org/trunk@29635 602fd350-edb4-49c9-b593-d223f7449a82
- Fixed bug where sometimes the resize rectangles wouldn't properly render on images on WebKit/Blink. 9a2d01cc14
- Fixed nodeChanged selection issue where the image selection wouldn't be removed if you clicked right after/before it. dd729c67e0
- Fixed bug in list plugin where delete/backspace would merge empty LI elements in lists incorrectly. caadfb05dd
See #29310
git-svn-id: https://develop.svn.wordpress.org/trunk@29576 602fd350-edb4-49c9-b593-d223f7449a82
Sessions are stored in usermeta via WP_User_Meta_Session_Tokens, which extends the abstract WP_Session_Tokens class. Extending WP_Session_Tokens can allow for alternative storage, such as a separate table or Redis.
Introduces some simple APIs for session listing and destruction, such as wp_get_active_sessions() and wp_destroy_all_sessions().
This invalidates all existing authentication cookies, as a new segment (the session token) has been added to them.
props duck_, nacin, mdawaffe.
see #20276.
git-svn-id: https://develop.svn.wordpress.org/trunk@29221 602fd350-edb4-49c9-b593-d223f7449a82