Commit Graph

747 Commits

Author SHA1 Message Date
Sergey Biryukov 12156f6fab Add a unit test that expects wp_parse_args() to treat `'true'` and `'false'` in a query string as strings.
props voldemortensen for initial patch.
see #30753.

git-svn-id: https://develop.svn.wordpress.org/trunk@31310 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-31 02:01:46 +00:00
Boone Gorges 057c428346 Introduce 'show_in_quick_edit' parameter for `register_taxonomy()`.
Setting 'show_in_quick_edit' to false when registering a custom taxonomy will
hide the taxonomy when editing posts using Quick Edit.

The new 'quick_edit_show_taxonomy' filter allows this behavior to be filtered
on a finer scale, as when you want a given taxonomy to be hidden for one post
type but not for others.

Props hlashbrooke.
Fixes #26948.

git-svn-id: https://develop.svn.wordpress.org/trunk@31307 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-30 19:17:51 +00:00
Boone Gorges 2fb8562a97 Introduce `setExpectedDeprecated()` and `setExpectedIncorrectUsage()` methods to `WP_UnitTestCase.
These methods provide a procedural alternative to the `@expectedDeprecated`
and `@expectedIncorrectUsage` test annotations, and parallel PHPUnit's native
`setExpectedException()`.

Props prasoon2211, jdgrimes.
Fixes #28486.

git-svn-id: https://develop.svn.wordpress.org/trunk@31306 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-30 16:47:44 +00:00
Boone Gorges 9cb4d3c1ce In `get_adjacent_post()`, return private post if the current user has the capacity to read it.
This mirrors the check that happens post-query in `WP_Query`. See #30911.

Props bswatson.
Fixes #30287.

git-svn-id: https://develop.svn.wordpress.org/trunk@31302 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-30 02:19:46 +00:00
Boone Gorges 9f8e5d3c17 Add unit tests for 'show_option_all' behavior of `wp_list_categories()`.
See #21881.

git-svn-id: https://develop.svn.wordpress.org/trunk@31301 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-30 01:39:31 +00:00
Boone Gorges bb0ca6f111 Add tests for `get_category_parents()`.
See #30415.

git-svn-id: https://develop.svn.wordpress.org/trunk@31299 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-29 20:48:03 +00:00
Dion Hulse db3a49f8c8 HTTP API: Fix an issue where the `limit_response_size` parameter wasn't working properly with large documents and the cURL transport.
Fixes #31172


git-svn-id: https://develop.svn.wordpress.org/trunk@31290 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-29 03:57:42 +00:00
Boone Gorges 465e66e2cd Add basic unit tests for `get_page_of_comment()`.
See #11334.
Props jeremyfelt.

git-svn-id: https://develop.svn.wordpress.org/trunk@31289 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-29 02:30:22 +00:00
Boone Gorges 2e848072eb Don't use term IDs for array indexes when caching object terms.
Uncached results pulled from `wp_get_object_terms()` are zero-indexed (ie 0,
1, 2...). As a result, `get_the_terms()` was returning a strictly different
array when pulling from the cache and when the cache was empty.

Props joshlevinson.
Fixes #31086.

git-svn-id: https://develop.svn.wordpress.org/trunk@31287 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-28 20:42:25 +00:00
Boone Gorges a57a612c95 Improve organiation of tax_query and meta_query unit tests.
`meta_query` tests have been moved to `tests/phpunit/tests/query/metaQuery.php` and `tax_query` tests to `tests/phpunit/tests/query/taxQuery.php`. This is an improvement because (a) it better corresponds to the way that other `WP_Query` parameter tests are organized, (b) splitting meta and tax tests into separate classes simplifies the required `@group` annotations, and (c) the tests have nothing to do with posts per se, and so do not belong in the `post` subdirectory.

The tests previously found at `tests/phpunit/tests/query/taxQuery.php` have been moved to `isTerm.php` in the same directory. These tests are related to the `is_*` functions that have to do with taxonomy terms, like `is_category()`.

See #26999.

git-svn-id: https://develop.svn.wordpress.org/trunk@31286 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-27 20:03:50 +00:00
Boone Gorges 9d3a6394fb Ensure that 'hierarchical' is respected in `get_terms()` when multiple taxonomies are passed.
Previously, attempts to descend the family tree of each term were done using
the first taxonomy in the `$taxonomies` array, with the result that terms not
belonging to that taxonomy were not found and their children not properly
parsed. We fix this bug by fetching each term's taxonomy with the SQL query,
and then using that taxonomy to get the correct children for each term.

Fixes #31118.

git-svn-id: https://develop.svn.wordpress.org/trunk@31285 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-26 19:03:09 +00:00
Boone Gorges fed49d226c Ensure that 'pad_counts' is not discarded when the first of multiple taxonomies passed to `get_terms()` is non-hierarchical.
See #31118.

git-svn-id: https://develop.svn.wordpress.org/trunk@31284 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-26 18:08:59 +00:00
Boone Gorges 1eee61f31a Do not run certain cache-hit tests on multisite.
These tests fail on multisite if run after a test that creates
`wpmu_create_blog()`, because `wpmu_create_blog()` defines `WP_INSTALLING`,
which results in unexpected cache misses. See [28965] for a similar fix.

git-svn-id: https://develop.svn.wordpress.org/trunk@31280 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-25 12:59:00 +00:00
Andrew Nacin 4857c6996c Allow $autoload in add_option() to receive false.
props dllh.
fixes #31119.


git-svn-id: https://develop.svn.wordpress.org/trunk@31278 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-25 07:50:31 +00:00
Boone Gorges 4e3e98698f In `Tests_Ajax_ReplytoComment::test_blocked_comment()`, don't stop blocking comments until test is complete.
The test uses the `_block_comments()` method to prevent comment inserts from
happening. Since [31263], failed comment inserts lead to the comment content's
being stripped of invalid characters and inserted again. By immediately
unhooking itself after first being run, `_block_comments()` was causing the
INSERT block to work only for the first attempt, while the second attempt was
going through, causing the test to fail. As a fix, we move the
`remove_filter()` call to the class's `tearDown()` method - sufficient for
cleanup, but late enough that *all* comment inserts will be blocked for the
test method in question.

See #21212.
Since [31263], comment INSERT queries that were pseudo-bl

git-svn-id: https://develop.svn.wordpress.org/trunk@31277 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-25 03:38:10 +00:00
Boone Gorges 5bcee9e939 In `get_terms()`, check hierarchy for all `$taxonomies` before bailing early from 'parent' or 'child_of'.
There is a pre-check in `get_terms()` that prevents an unnecessary database
query if the 'parent' or 'child_of' parameter is not found in the cached term
hierarchy (since a term without an index in the hierarchy cache has no
descendants). Previously, only the first item in the `$taxonomies` array was
being checked, with the result that an empty array was being erroneously
returned in cases where the 'parent' or 'child_of' term is in a subsequent
taxonomy.

See #31118.

git-svn-id: https://develop.svn.wordpress.org/trunk@31276 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-25 02:45:11 +00:00
Boone Gorges c67e5da8c9 Introduce 'childless' parameter to `get_terms()`.
This new parameter allows developers to limit queried terms to terminal nodes -
ie, those without any descendants.

As part of the improvement, some internal logic in `get_terms()` has been
consolidated. Parameters that resolve to a NOT IN clause containing term IDs
('exclude', 'exclude_tree', and 'childless') are now parsed into a single
"exclusions" array before the SQL clause is generated.

Props theMikeD, horike.
Fixes #29839.

git-svn-id: https://develop.svn.wordpress.org/trunk@31275 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-24 18:47:30 +00:00
Boone Gorges 8ec0792557 Add classes for custom taxonomy terms in `get_post_class()`.
Props sillybean.
Fixes #16223.

git-svn-id: https://develop.svn.wordpress.org/trunk@31271 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-23 15:40:31 +00:00
Boone Gorges 10d3b42211 Introduce 'parent' parameter to `wp_get_object_terms()`.
Props mikeschinkel.
Fixes #15675.

git-svn-id: https://develop.svn.wordpress.org/trunk@31270 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-23 14:56:04 +00:00
Boone Gorges be28a2c9c5 A few more wordpress.com https assets in unit tests.
See #31091.

git-svn-id: https://develop.svn.wordpress.org/trunk@31259 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-21 18:57:17 +00:00
Boone Gorges cabab6c140 Use https URLs for wordpress.com assets in `Tests_HTTP_Functions`.
The http->https redirects were breaking some of the tests.

Fixes #31091.

git-svn-id: https://develop.svn.wordpress.org/trunk@31258 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-21 18:43:03 +00:00
Boone Gorges ab551d8dac Move GD-specific resize test to GD-specific resize test file.
This makes it so that we don't have to mark the test as skipped when running
through Imagick tests.

See #30284.

git-svn-id: https://develop.svn.wordpress.org/trunk@31257 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-21 18:27:44 +00:00
Boone Gorges 4dd59fd9ce Remove skipped unit tests related to proposed `map_deep()`.
The tests have been added as a patch to #22300.

See #30284.

git-svn-id: https://develop.svn.wordpress.org/trunk@31256 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-21 17:57:15 +00:00
Boone Gorges 5fdc8a8364 Remove `WP_Post_IDs_Iterator` tests.
The tests have been moved to a patch on the ticket where the class has been
proposed, #22435.

See #30284.

git-svn-id: https://develop.svn.wordpress.org/trunk@31254 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-20 21:59:24 +00:00
Boone Gorges 70eee8514b Remove skipped tests related to the proposed Export API.
These tests have been added as a patch to #22435.

See #30284.

git-svn-id: https://develop.svn.wordpress.org/trunk@31253 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-20 20:57:08 +00:00
Boone Gorges f1771073dc `WP_Date_Query` date validation should not fail for hour = 0.
Props ChriCo, tyxla.
Fixes #31067 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@31251 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-20 19:12:48 +00:00
Gary Pendergast 3a87ef36e2 Texturize: Add "em" as a cockney term, so that "'em" is texturized with an apostrophe, instead of an open quote.
Fixes #29813.

Props miqrogroove.



git-svn-id: https://develop.svn.wordpress.org/trunk@31249 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-20 18:43:30 +00:00
Boone Gorges d80ca82693 Better loop detection for `_pad_term_counts()`.
The `$ancestors` check must be reset for each term in order for term counts
to be correct.

Fixes #20635.

git-svn-id: https://develop.svn.wordpress.org/trunk@31248 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-19 16:51:44 +00:00
Sergey Biryukov a036114a4d attachment_url_to_postid() should always return an integer.
props nathan_dawson, ashfame.
fixes #31044.

git-svn-id: https://develop.svn.wordpress.org/trunk@31239 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-18 20:32:50 +00:00
Boone Gorges 9501fb3213 Additional 'orderby' values for `wp_get_object_terms()`.
Adds support for ordering by 'taxonomy', 'term_taxonomy_id', and 'parent'.

Props ChriCo.
Fixes #28688.

git-svn-id: https://develop.svn.wordpress.org/trunk@31236 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-18 18:56:38 +00:00
Boone Gorges 68283f5fb3 Add unit tests for 'orderby' and 'order' param of `wp_get_object_terms()`.
git-svn-id: https://develop.svn.wordpress.org/trunk@31233 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-17 20:38:25 +00:00
Boone Gorges 108e85314b Move `wp_get_object_terms()` tests into their own file.
See #26999.

git-svn-id: https://develop.svn.wordpress.org/trunk@31230 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-17 20:08:04 +00:00
Andrew Ozz f18854e866 Add support for IE conditional comments for WP_Scripts to match the functionality of WP_Styles, including unit tests. Props filosofo, aaroncampbell, ethitter, georgestephanis, valendesigns. Fixes #16024.
git-svn-id: https://develop.svn.wordpress.org/trunk@31223 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-17 01:36:55 +00:00
Boone Gorges 60f2983b2e Bail out of hierarchy loops in `_get_term_children()`.
This prevents infinite loops that lead to PHP nesting limit fatal errors.

Props boonebgorges, sgrant.
Fixes #24461.

git-svn-id: https://develop.svn.wordpress.org/trunk@31207 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-16 17:09:11 +00:00
Boone Gorges 8ae64f6384 Bail out of hierarchy loops in `_pad_term_counts()`.
Taxonomy hierarchy loops should not occur naturally, but when they do, the
logic of `_pad_term_counts()` could result in infinite loops, leading to
timeouts. We avoid this by breaking when a loop is detected.

Fixes #20635.

git-svn-id: https://develop.svn.wordpress.org/trunk@31206 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-16 16:45:21 +00:00
Boone Gorges af146fef8c In `paginate_links()`, don't override custom format arguments when setting up default 'add_args'.
Since 4.1 [29780], the default value of the 'add_args' argument in
`paginate_links()` has been determined by parsing the current URL. This change
had the side effect of overriding custom values of 'format' that changed the
pagination query var, with the result that plugins using `paginate_links()`
with a custom format generated the incorrect links unless explicitly
declaring 'add_args=false' to prevent the default values from overriding. We
fix this behavior by parsing URL query vars into the 'add_args' array only
after the explicit function params have been parsed, and by skipping the
current page's pagination query var when doing this parsing (to avoid the
override).

Props obenland.
Fixes #30831 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@31203 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-16 15:48:24 +00:00
Gary Pendergast c8c8b66bae When a hyphen `-` or double hyphen `--` was at the start or the end of a string, it wasn't texturized correctly.
Fixes #31030



git-svn-id: https://develop.svn.wordpress.org/trunk@31199 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-16 03:54:00 +00:00
Gary Pendergast 58d931dfc7 Allow `comment_post_ID` to be passed to `wp_update_comment()`, so that a comment can be moved to a different post.
Props tyxla, rachelbaker

Fixes #30946



git-svn-id: https://develop.svn.wordpress.org/trunk@31195 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-16 02:38:30 +00:00
Scott Taylor acbf60c9a6 After [31186], remove `figcaption` from the list of inline elements that are autop'd in `Tests_Formatting_Autop::test_that_wpautop_treats_inline_elements_as_inline()`.
See #29219.


git-svn-id: https://develop.svn.wordpress.org/trunk@31191 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-16 01:50:47 +00:00
Scott Taylor bcc7f9e093 In `WP_User`, `->get_role_caps()` and `->update_user_level_from_caps()` must be called inside `->add_cap()` and `->remove_cap()` after updating user meta. `->has_cap()` checks are currently failing directly after calling `->add_cap()`.
Adds unit test.

Props rachelbaker.
Fixes #28374.


git-svn-id: https://develop.svn.wordpress.org/trunk@31190 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-16 01:48:36 +00:00
Boone Gorges 4b6957c852 Support array values in `WP_Date_Query::validate_date_values()`.
Introduced in [29925], `validate_date_values()` throws `_doing_it_wrong()`
notices when values passed as part of a `WP_Date_Query` do not reflect actual
dates. However, the validation did not account properly for the case where an
array of multiple values is passed, as when doing IN or BETWEEN queries.

Props dlh.
Fixes #31001 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@31179 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-14 16:50:09 +00:00
Sergey Biryukov 819a53be46 Add 'user_id' to the list of fields wp_update_comment() can update.
props jphase.
fixes #30307.

git-svn-id: https://develop.svn.wordpress.org/trunk@31172 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-13 06:47:33 +00:00
Sergey Biryukov a744bb9a5f Add 'comment_type' to the list of fields wp_update_comment() can update.
props desaiuditd.
fixes #30627.

git-svn-id: https://develop.svn.wordpress.org/trunk@31171 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-13 06:41:19 +00:00
Jeremy Felt 0eb9f7e414 Use a less complex approach for enforcing path slashes in `update_blog_details()`
Ensure leading and traling slashes are in place and don't touch anything in the middle. Validating with `array_filter()` would have missed a possible valid falsy path - `/my-path/0/`.

Props nacin.

Fixes #18117.


git-svn-id: https://develop.svn.wordpress.org/trunk@31158 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-12 04:20:47 +00:00
Jeremy Felt d759c0ef23 Check for existence of data from `get_blogaddress_by_id()` before returning a URL
* Prevent a notice when an invalid ID is used with `get_blogaddres_by_id()`.
* Return a falsy empty string rather than the previous "http://".
* Add unit tests for `get_blogaddress_by_id()`.

Props nerrad.

Fixes #30566.


git-svn-id: https://develop.svn.wordpress.org/trunk@31157 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-12 02:23:43 +00:00
Jeremy Felt f9e9287875 Enforce leading and trailing slashes on paths updated with `update_blog_details()`
In multisite, core expects the stored value for a site's path to have leading and trailing slashes. When these slashes are missing, it becomes impossible to visit the site.

This enforces proper `/path/` creation in `update_blog_details()`, most likely used when updating an existing site through `site-info.php`.

Props earnjam, simonwheatley.

Fixes #18117. Fixes #23865.


git-svn-id: https://develop.svn.wordpress.org/trunk@31155 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-12 01:42:46 +00:00
Gary Pendergast 69f8b26d89 In `get_avatar_data()`, there's no need to return `false` if we couldn't find an avatar, as Gravatar can handle being given an empty email hash. This allows the default avatar to show when no email address is given.
See #21195



git-svn-id: https://develop.svn.wordpress.org/trunk@31153 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-12 00:19:34 +00:00
Gary Pendergast d0fab598e7 In `get_avatar()`, revert the `<img>` tag attributes to using single quotes, instead of double quotes. This behaviour was changed in [31107], but caused problems for code that attempted to parse the `<img>` tag.
See #21195



git-svn-id: https://develop.svn.wordpress.org/trunk@31152 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-12 00:02:31 +00:00
Boone Gorges 77128eb048 Default `$parent` in `category_exists()` should default to null rather than 0.
[29863] made the corresponding change in `term_exists()`. Failure to change the
default value in `category_exists()` meant that an unspecified value for
`$parent` would limit results to top-level categories.

Includes unit tests and corrected function documentation.

Props hissy.
Fixes #30975 for trunk.

git-svn-id: https://develop.svn.wordpress.org/trunk@31140 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-11 01:25:19 +00:00
Boone Gorges d5c9eb41d7 In `get_permalink()`, don't resolve to pretty permalink if post has 'future' status.
We already do this for other non-public statuses, to prevent leaking non-public
information about unpublished posts.

Props e.mazovetskiy, CalEvans.
Fixes #30910.

git-svn-id: https://develop.svn.wordpress.org/trunk@31114 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-09 16:39:56 +00:00