Commit Graph

961 Commits

Author SHA1 Message Date
Gary Pendergast 0152b8f49b In [32299], we should be using `mb_strlen()` for our string size checks.
git-svn-id: https://develop.svn.wordpress.org/trunk@32306 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-27 14:41:48 +00:00
Gary Pendergast 45b0abbef1 WPDB: Sanity check that any strings being stored in the DB are not too long to store correctly.
git-svn-id: https://develop.svn.wordpress.org/trunk@32299 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-27 14:02:45 +00:00
Boone Gorges c3ea088948 When priming the cache for taxonomy term nav items, don't fetch term descendants.
Descending the term tree causes unnecessary database queries when priming the
cache for a term with many descendants.

Fixes #31724.

git-svn-id: https://develop.svn.wordpress.org/trunk@32294 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-24 18:57:07 +00:00
Boone Gorges 7add279793 Allow rewrite endpoints to be registered without also registering query vars.
Passing `false` to `add_rewrite_endpoint()` will now allow you to take
advantage of the rewrite API without thereby modifying the way that WP sets up
the main query from the request URI.

This new functionality allows developers to work around certain edge-case bugs,
such as when a proper endpoint request (such as `/test/1/`) would short-
circuit `is_home()` calculation when a static front page is set.

Props mordauk, boonebgorges.
Fixes #25143.

git-svn-id: https://develop.svn.wordpress.org/trunk@32293 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-24 16:37:12 +00:00
Boone Gorges 000f4f98b4 In `wp_list_categories()`, 'All' link should point to post type archive if taxonomy is not registered for 'post' or 'page'.
Instead, we point to the post type archive of the first registered
object_type that supports archives.

Props stevegrunwell, hrishiv90, boonebgorges.
Fixes #21881.

git-svn-id: https://develop.svn.wordpress.org/trunk@32292 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-24 14:56:37 +00:00
Gary Pendergast cc8a9824c5 WPDB: When sanity checking a string by sending it to MySQL for conversion checks, the incorrect data structure was being returned from `wpdb::strip_invalid_text()`, causing all write queries to fail for some character sets when the query contained non-ASCII characters.
See #32051.



git-svn-id: https://develop.svn.wordpress.org/trunk@32261 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-22 15:01:25 +00:00
Gary Pendergast afe046a84c WPDB: When deciding if a query needs extra sanity checking based on collation, we can quickly return if the query is entirely ASCII characters.
See #32029.



git-svn-id: https://develop.svn.wordpress.org/trunk@32233 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-21 05:23:44 +00:00
Gary Pendergast 0fe5a64e56 WPDB: When deciding if a query needs extra sanity checking based on collation, we can quickly return if it's a query that will never return user data.
Fixes #32029.



git-svn-id: https://develop.svn.wordpress.org/trunk@32232 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-21 05:10:11 +00:00
Boone Gorges 80ca5b2b53 In term-splitting unit tests, correct incorrect wording in an inline comment.
Props dlh.
Fixes #32014.

git-svn-id: https://develop.svn.wordpress.org/trunk@32208 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-20 15:17:24 +00:00
Boone Gorges 1a38d95e83 Ensure that 'who' param is respected when generating meta_query in `WP_User_Query`.
Since [31669], the 'who' param had been parsed after meta_query was generated,
so that 'who' was effectively ignored.

Props imath.
Fixes #32019.

git-svn-id: https://develop.svn.wordpress.org/trunk@32207 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-20 15:15:14 +00:00
Gary Pendergast c9774eac69 Unit Tests: The `get_smilies_combinations` test was failing when the tests were run with a non-default domain.
Props netweb.

Fixes #32025.



git-svn-id: https://develop.svn.wordpress.org/trunk@32178 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-20 10:10:53 +00:00
Gary Pendergast 8453d41a44 Fix the unit test added in [32173] to run correctly in PHP 5.2.
git-svn-id: https://develop.svn.wordpress.org/trunk@32177 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-20 09:40:11 +00:00
Gary Pendergast 94f02ef8b1 In Multisite, prevent plugins from unintentionally switching sites.
Props mdawaffe.



git-svn-id: https://develop.svn.wordpress.org/trunk@32173 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-20 07:26:05 +00:00
Gary Pendergast 332750a40d Revert [30640], as it was incorrectly checking some filenames.
git-svn-id: https://develop.svn.wordpress.org/trunk@32171 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-20 06:38:08 +00:00
Gary Pendergast 96f12cc588 Clean up some edge cases in `sanitize_sql_orderby()`.
Props vortfu, dd32.



git-svn-id: https://develop.svn.wordpress.org/trunk@32164 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-20 05:41:37 +00:00
Gary Pendergast faa66d8145 WPDB: When sanity checking read queries, there are some collations we can skip, for improved performance.
Props pento, nacin.

See #21212.



git-svn-id: https://develop.svn.wordpress.org/trunk@32162 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-20 04:45:12 +00:00
Boone Gorges bf3773dbfb During PHPUnit tests, don't autodetect permalink structure during WP installation.
The unit tests expect non-pretty permalinks, so there's no benefit to detecting
the ability to have pretty permalinks. Moreover, the `wp_remote_get()` call can
cause installation to hang when there are DNS issues.

Fixes #31994.

git-svn-id: https://develop.svn.wordpress.org/trunk@32139 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-16 23:59:01 +00:00
Sergey Biryukov 3b6ff03136 `wp_update_term()` should check if `get_term()` returned null.
props dlh.
fixes #31954.

git-svn-id: https://develop.svn.wordpress.org/trunk@32117 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-13 01:20:57 +00:00
Gary Pendergast b806e118c6 When `dbDelta()` is checking whether an index is defined in a `CREATE TABLE` statement, don't worry if MySQL has a subpart defined on an index, but the `CREATE TABLE` doesn't.
Fixes #31869.



git-svn-id: https://develop.svn.wordpress.org/trunk@32108 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-11 10:39:49 +00:00
Gary Pendergast 1de9bc1670 Smilies: Tweak which smiley matches which emoji.
Props iseulde.

See #31709.



git-svn-id: https://develop.svn.wordpress.org/trunk@32105 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-10 06:29:49 +00:00
Gary Pendergast 3bd66eff61 Smilies: Update our few remaining smilies to better align with Twemoji, and add frownie.png until Twemoji provide a build containing it.
Props joen.

See #31709.



git-svn-id: https://develop.svn.wordpress.org/trunk@32104 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-10 06:19:39 +00:00
Boone Gorges bffb632183 Improve handling of incomplete From and Content-Type headers in `wp_mail()`.
When an incomplete header is provided (eg, 'From' with an email address but no
name), ensure that the WP defaults are filled in properly.

Props valendesigns.
Fixes #30266.

git-svn-id: https://develop.svn.wordpress.org/trunk@32070 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-07 20:09:46 +00:00
Boone Gorges ddb33c9aed After [31114] and [31323], 'View Post' generated in `get_sample_permalink_html()` should go to pretty permalink.
`get_permalink()` will return a non-pretty permalink for future posts, which
breaks some user workflows that expect View Post to lead to a page with the
pretty permalink.

Fixes #30910.

git-svn-id: https://develop.svn.wordpress.org/trunk@32002 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-04 01:26:08 +00:00
Boone Gorges 468da41811 `WP_User_Query`: When querying users with 'fields=all', ensure that caps and roles are filled for the current site.
See [15566] for a parallel fix for 'fields=all_with_meta'.

Fixes #31878.

git-svn-id: https://develop.svn.wordpress.org/trunk@32001 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-03 14:13:19 +00:00
Boone Gorges 86f074ffde Unit tests verifying the filling of the 'roles' and 'caps' user properties during `WP_User_Query`.
See #31878.

git-svn-id: https://develop.svn.wordpress.org/trunk@32000 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-03 14:13:11 +00:00
John Blackbourn d92cc07d91 Correctly set the post author in `wp_xmlrpc_server::mw_editPost()` when the current user is not the author of the post.
Props redsweater, markoheijnen, DrewAPicture
Fixes #24916


git-svn-id: https://develop.svn.wordpress.org/trunk@31983 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-02 15:48:41 +00:00
Sergey Biryukov 4738590d5e Avoid duplicate classes for different terms with UTF-8 slugs in `post_class()` and `body_class()`.
Fall back to term ID if the sanitized slug is numeric or only contains hyphens.

props SergeyBiryukov, A5hleyRich, sgrant, davideugenepratt.
fixes #30883.

git-svn-id: https://develop.svn.wordpress.org/trunk@31979 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-02 01:04:22 +00:00
Gary Pendergast b9537f9488 Unit Tests added in [31970] need to be restricted to run in Multisite only.
See #17904, #26784.



git-svn-id: https://develop.svn.wordpress.org/trunk@31978 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-02 00:12:07 +00:00
Boone Gorges 4201382267 Unit tests for `wpmu_validate_user_signup()`.
See #17904, #26784.

git-svn-id: https://develop.svn.wordpress.org/trunk@31970 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-01 21:37:34 +00:00
Scott Taylor d1235e323e Respect numerical keys in `add_query_arg()`, use `array_replace()` instead of `array_merge()`.
Adds unit test.

Props tyxla.
Fixes #31306.


git-svn-id: https://develop.svn.wordpress.org/trunk@31966 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-01 19:14:46 +00:00
Scott Taylor bcf98c7742 Alter the regex in `wptexturize()` to properly handle input like: `<> "Hello world" <>`.
Updates unit test data.

Props miqrogroove.
Fixes #30344.


git-svn-id: https://develop.svn.wordpress.org/trunk@31965 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-01 19:08:31 +00:00
Scott Taylor 2418711c47 When updating the email address for an existing user, make sure the email address is not already in use.
Adds unit tests.

Props rittesh.patel, DrewAPicture.
Fixes #30647.


git-svn-id: https://develop.svn.wordpress.org/trunk@31963 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-01 18:22:16 +00:00
Gary Pendergast ed374ae10e WPDB: Due to PHP 5.2's internal string handling, strings in Windows are encoded using UTF-16, instead of UTF-8. With the addition of the many character set tests in [30345], a couple of them were tripping up in PHP 5.2 under Windows, because of this behaviour.
This marks those tests as skipped.

See #31262 for more discussion.



git-svn-id: https://develop.svn.wordpress.org/trunk@31953 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-01 12:33:39 +00:00
Gary Pendergast 4e6cb8a5e2 Emoji: Fix a unit test which was incorrectly failing after [31926] fixed emoji being incorrectly encoded.
git-svn-id: https://develop.svn.wordpress.org/trunk@31940 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-31 09:36:29 +00:00
Dion Hulse 9ce354f534 Tests: Clean up the resulting /tmp/foo* files from the `tempnam` call.
git-svn-id: https://develop.svn.wordpress.org/trunk@31937 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-31 02:10:52 +00:00
Dion Hulse 842d6a9b39 Add some logic into `wp_tempnam` to prevent it creating 'falsey' directory names that might get used elsewhere within WordPress.
Although this logic looks a little strange at this low level, it's the best location within the Upgrades code for it to happen.
Fixes #31811


git-svn-id: https://develop.svn.wordpress.org/trunk@31936 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-31 02:10:06 +00:00
Gary Pendergast eced539d8b Emoji: [31864] changed emoji image's inline style from `height` to `max-height`. Unfortunately, anything using `feedparser.py` (for example, NewsBlur) strips out `max-height`, which gives us massive emoji in feeds.
This re-adds `height`, and also reminds us why we can't have nice things.

See #31719.



git-svn-id: https://develop.svn.wordpress.org/trunk@31909 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-27 02:11:45 +00:00
Gary Pendergast b3e3766233 Emoji: Gmail doesn't obey an `<img>`'s inline CSS `height` rule, transforming it to `min-height`. To avoid giant smiley faces everywhere, we're changing the `height` rule to `max-height`, which Gmail plays nicer with.
Props janhenckens.

Fixes #31719.



git-svn-id: https://develop.svn.wordpress.org/trunk@31864 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-23 12:07:47 +00:00
Boone Gorges 6d7c4f39f0 Use shared fixtures in RSS2 unit tests.
See #31705, #30017.

git-svn-id: https://develop.svn.wordpress.org/trunk@31848 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-20 12:34:28 +00:00
Boone Gorges bb2ddebec9 Enforce non-pretty permalinks in RSS2 tests.
Previously, the tests were using '/feed/' in their `go_to()` statements, but
testing nodes for URLs like '?p='. This mismatch created unpredictable results
when the run in certain sequences with other groups of unit tests.

See #31705.

git-svn-id: https://develop.svn.wordpress.org/trunk@31846 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-20 12:25:27 +00:00
Boone Gorges 6de5ae56dd Ensure that fixtures in RSS2 tests have an author.
This makes the 'dc:creator' assertions more meaningful.

Props ianmjones.
See #31705.

git-svn-id: https://develop.svn.wordpress.org/trunk@31845 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-20 12:25:18 +00:00
Boone Gorges 819ea5cabe Move and tests to their own files.
git-svn-id: https://develop.svn.wordpress.org/trunk@31812 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-18 13:27:15 +00:00
Boone Gorges 12784e13d4 Improve method consistency in `WP_Comment_Query`.
* Introduce a `__construct()` method, which can accept an array of query vars.
* Move query logic out of `query()` method and into a new `get_comments()` method.
* Ensure that `$this->comments` is set whenever `get_comments()` returns a value.
* Introduce a `parse_query()` method, where query vars are parsed with default values and the 'parse_comment_query' action is fired.

These changes bring `WP_Comment_Query` syntax closer to that of `WP_Query`.

Props westonruter, morganestes, boonebgorges.
Fixes #24826.

git-svn-id: https://develop.svn.wordpress.org/trunk@31793 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-16 14:23:33 +00:00
Boone Gorges ec49827b0b In `wp_insert_term()`, allow a term with an existing name if a unique `$slug` has been provided.
`wp_insert_term()` protects against the creation of terms with duplicate names
at the same level of a taxonomy hierarchy. However, it's historically been
possible to override this protection by explicitly providing a value of `$slug`
that is unique at the hierarchy tier. This ability was broken in [31734], and
the current changeset restores the original behavior.

A number of unit tests are added and refactored in support of these changes.

See #17689 for discussion of a fix that was superceded by [31734]. This commit
retains the fix for the underlying bug described in that ticket.

See #31328.

git-svn-id: https://develop.svn.wordpress.org/trunk@31792 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-16 11:15:34 +00:00
Gary Pendergast 1c63c533b1 Tests: Since [31733], we now encode emoji in posts, instead of removing them (when they're being stored in versions of MySQL that don't support `utf8mb4`).
git-svn-id: https://develop.svn.wordpress.org/trunk@31782 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-15 11:50:54 +00:00
Gary Pendergast 3503aa4820 Smilies: The new smilies added in [31733] and [31745] are larger than the old smilies. While this is taken care of by the CSS on normal pages, it means they're disproportionally large when seen in RSS and email.
By adding a little bit of inline style to them, we get pleasingly sized smilies everywhere. :-)

See #31242



git-svn-id: https://develop.svn.wordpress.org/trunk@31781 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-15 11:40:16 +00:00
Boone Gorges 13e66393f1 Don't run `wp_get_archives()` cache test on multisite.
The introduction of a Customizer test that creates a new blog [31707] causes
`WP_INSTALLING` to be set by the time the `wp_get_archives()` tests run. This,
in turn, causes the query counts to vary in unpredictable ways.

See #31130.

git-svn-id: https://develop.svn.wordpress.org/trunk@31764 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-12 23:29:21 +00:00
Helen Hou-Sandi 21134a0c89 Allow `is_page_template()` to accept an array, as many other conditional tags do.
props morganestes, tyxla, DrewAPicture.
fixes #31271.


git-svn-id: https://develop.svn.wordpress.org/trunk@31754 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-12 16:27:06 +00:00
Gary Pendergast 1357e7fc2e Add emoji URL support, and Twemoji fallback for displaying slugs in wp-admin, when the browser doesn't natively support emoji.
Props pento, SergeyBiryukov and boonebgorges.

Fixes #31328



git-svn-id: https://develop.svn.wordpress.org/trunk@31734 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-11 22:54:49 +00:00
Gary Pendergast ae391ec226 Add emoji support, with Twemoji fallback.
Replace exisiting smilies with equivalent emoji, or with shiny new smiley images where no emoji existed.

Props batmoo, joen and mkaz for the original plugin upon which this is based.

Props pento, iseulde, kraftbj and peterwilsoncc for making the internet's dreams come true.

See #31242



git-svn-id: https://develop.svn.wordpress.org/trunk@31733 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-11 22:48:16 +00:00
John Blackbourn 82ac76c0a7 Introduce a new algorithm for displaying a hierarchical list of post objects in the `WP_Posts_List_Table`. This reduces processing time, reduces database queries, and substantially reduces memory use on sites with a high number of Pages.
Props nofearinc, rodrigosprimo, nacin, johnbillion.
Fixes #15459


git-svn-id: https://develop.svn.wordpress.org/trunk@31730 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-11 20:45:17 +00:00
Helen Hou-Sandi 22f174c106 Fix a unit test after [31721].
props jipmoors.
see #22329.


git-svn-id: https://develop.svn.wordpress.org/trunk@31728 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-11 20:11:38 +00:00
Dominik Schilling (ocean90) 32a124a884 Customizer: Return the original value when filtering theme mods/options and the current blog has changed.
props westonruter.
fixes #31428.

git-svn-id: https://develop.svn.wordpress.org/trunk@31707 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-10 23:04:12 +00:00
Dominik Schilling (ocean90) 63502a8a01 Customizer: Fix previewing and applying widgets when previewing another theme.
* Unset `wp_get_sidebars_widgets()`' non-admin cache var `$_wp_sidebars_widgets` in Customize theme preview.
* Add `WP_Customize_Setting::$dirty` so that settings can be initially-dirty when the Customizer loads.
* Mark `old_sidebars_widgets_data` setting initially-dirty.
* Mark all `sidebars_widgets` settings as initially-dirty during theme switch.

props westonruter.
see #31484.

git-svn-id: https://develop.svn.wordpress.org/trunk@31705 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-10 22:38:30 +00:00
Andrew Ozz 9aba4766fc TinyMCE: update to 4.1.9. Fixes #31551.
git-svn-id: https://develop.svn.wordpress.org/trunk@31700 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-10 19:19:56 +00:00
Boone Gorges 8072fe7db6 Improved customizability for the Submit button in `comment_form()`.
The new 'submit_button' and 'submit_field' parameters for `comment_form()`
allow developers to modify the markup of the submit button and its wrapper.
These params are accompanied by targeted 'comment_form_submit_button' and
'comment_form_submit_field' filters on the concatenated markup.

Props coffee2code, morpheu5, DrewAPicture, boonebgorges.
Fixes #15015.

git-svn-id: https://develop.svn.wordpress.org/trunk@31699 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-10 19:07:31 +00:00
Sergey Biryukov 5fe8182c7f EXIF/IPTC captions should populate Caption (`post_excerpt`) on upload, not Description (`post_content`).
Make sure the caption is always set if found. Previously, if the caption was less than 80 characters, only the Title field would be set.

props beaulebens, ericlewis, bendoh, SergeyBiryukov.
fixes #22768.

git-svn-id: https://develop.svn.wordpress.org/trunk@31694 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-10 05:06:39 +00:00
Boone Gorges 969c850149 Share fixtures across `wp_list_authors()` tests.
See #30017.

git-svn-id: https://develop.svn.wordpress.org/trunk@31676 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-08 15:57:02 +00:00
Boone Gorges 5bb3e71cc0 Whitelist 'psd' for uploads when testing `wp_attachment_is() on multisite.
It's not allowed by default, which causes the fixture not to be built.

See #25275 [31647].

git-svn-id: https://develop.svn.wordpress.org/trunk@31670 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-07 18:47:04 +00:00
Boone Gorges a11372afe1 Improved 'orderby' meta syntax in `WP_User_Query`.
Recent commits have added the ability to order query results by specific
clauses of the 'meta_query' parameter (comments [31467], posts [31312] and
[31340]). The current changeset ports the same functionality to `WP_User_Query`.

Also introduced is the ability to pass the value of `$meta_key` to 'orderby'.

The internals of `WP_User_Query::prepare_users()` had to be reordered
somewhat to support these changes, primarily to ensure that the `meta_query`
object generates its SQL clauses before the 'orderby' parameter is parsed.

See #31265.

git-svn-id: https://develop.svn.wordpress.org/trunk@31669 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-07 18:37:05 +00:00
Boone Gorges 6a4839bd83 User query `meta_vars` test must account for the 'blog_id' clause added in multisite.
See #31265.

git-svn-id: https://develop.svn.wordpress.org/trunk@31668 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-07 17:33:48 +00:00
Boone Gorges 0fb3e2566f Add tests for the conversion of 'meta_*' query vars to `$meta_query` objects in all query classes.
See #31265.

git-svn-id: https://develop.svn.wordpress.org/trunk@31666 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-07 16:34:50 +00:00
Boone Gorges 945fd67d7b Improve 'orderby' syntax for `WP_User_Query`.
This changeset ports a number of 'orderby' features from `WP_Query` and
`WP_Comment_Query`:

* Allow multiple 'orderby' values to be passed as a space-separated list.
* Allow multiple 'orderby' values to be passed as a flat array.
* Allow multi-dimensional 'orderby', with orderby fields as array keys and ASC/DESC as the corresponding values.

See #31265.

git-svn-id: https://develop.svn.wordpress.org/trunk@31663 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-07 16:05:11 +00:00
Boone Gorges 3262ff0cc8 Tests for some existing 'orderby' functionality in `WP_*_Query` classes.
* In `WP_Query` and `WP_Comment_Query`, ensure that 'orderby' can parse multiple values for 'orderby' when passed as a space-separated string.
* In `WP_User_Query`, ensure that "shorthand" orderbys (like 'login' and 'name') are converted to their full versions (like 'user_login' and 'display_name').

See #31265.

git-svn-id: https://develop.svn.wordpress.org/trunk@31662 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-07 15:44:28 +00:00
Boone Gorges b2332718a1 When passing `$full` to `get_posts_by_author_sql()`, make sure a 'post_type' clause is included in results.
This change makes the 'post_type' clause in `wp_list_authors()` redundant, so
we remove it. Third-party plugins using `get_posts_by_author_sql()` may have
similarly redundant clauses, but this won't change the results returned by the
SQL queries.

Also adds unit tests for `get_posts_by_author_sql()`.

Props pbearne.
Fixes #30354.

git-svn-id: https://develop.svn.wordpress.org/trunk@31653 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-07 01:14:31 +00:00
Scott Taylor 8a28e19808 Add unit tests for `wp_attachment_is()`, checks the whitelist and arbitrary extension.
See #25275.


git-svn-id: https://develop.svn.wordpress.org/trunk@31647 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-06 20:37:08 +00:00
Boone Gorges b9e222fd6a Allow `$autoload` setting to be changed for existing options using `update_option()`.
[31628] made it possible to pass an `$autoload` param to `update_option()` that
applies when the option does not yet exist in the database. The current
changeset introduces parity for existing options: the `$autoload` setting
for existing options can be changed via the `$autoload` parameter. For internal
simplicity, `$autoload` is ignored for existing options when `$value` is not
also changed.

This changeset also moves `update_option()` tests into their own class.

Props dd32.
Fixes #26394.

git-svn-id: https://develop.svn.wordpress.org/trunk@31640 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-06 13:56:44 +00:00
Boone Gorges 67324a9234 Introduce `$autoload` parameter to `update_option()`.
When creating an option via `add_option()`, the `$autoload` param allows you to
tell WP whether the option should be loaded as part of the 'alloptions' cache
during every pageload. `update_option()`, when used with a non-existent option
calls `add_option()` internally. The new `$autoload` param in `update_option()`
is passed along to `add_option()` in cases where the option does not yet exist.

The associated unit tests are skipped on multisite due to an issue that causes
`WP_INSTALLING` to force cache misses. See #31130.

Props codix, nofearinc, MikeHansenMe.
Fixes #26394.

git-svn-id: https://develop.svn.wordpress.org/trunk@31628 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-05 19:13:00 +00:00
Boone Gorges c4e9c64233 Pinking shears in unit test files.
git-svn-id: https://develop.svn.wordpress.org/trunk@31623 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-05 13:14:28 +00:00
Boone Gorges 067fa3702e In PHPUnit test classes, `parent::tearDown()` should be the last thing done in `tearDown()` methods.
`WP_UnitTestCase::tearDown()` restores the test environment to the default
conditions, including rolling back the MySQL transaction that the test takes
place in, resetting globals, and unhooking test-specific filters. As such, all
teardown routines for specific tests should happen before the parent class's
`tearDown()` method is called. Failure to do so can cause database locks on
certain configurations, among other problems.

See #31537.

git-svn-id: https://develop.svn.wordpress.org/trunk@31622 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-05 13:14:15 +00:00
Boone Gorges 07abae914e In `get_next_comments_link()`, ensure proper pagination when no 'cpage' query var is found.
The 'cpage' query var is only set when using `comments_template()` to display
comments. If displaying them in a context where 'cpage' is not yet set, the
default value should be 1, not 0.

Props MomDad, couturefreak.
Fixes #20319.

git-svn-id: https://develop.svn.wordpress.org/trunk@31617 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-05 03:56:21 +00:00
Boone Gorges c1b30747d5 Respect `comment_date` and `comment_date_gmt` params in `wp_new_comment()`.
Props solarissmoke, oso96_2000.
Fixes #14279.

git-svn-id: https://develop.svn.wordpress.org/trunk@31615 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-05 02:59:47 +00:00
Boone Gorges 1ee4d99972 In `wp_get_attachment_url()`, convert to HTTPS when possible.
`wp_get_attachment_url()`, via `wp_upload_dir()`, uses 'siteurl' to generate
attachment URLs. When a site is SSL-optional on the front end - ie, 'siteurl'
is non-HTTPS, but SSL is available - a number of situations can arise where
non-HTTPS attachment URLs cause browser mixed-content warnings:

a) SSL is forced in the admin and `wp_get_attachment_url()` is used to generate the `<img>` tag for an inserted image. In these cases, the post content will contain non-HTTPS. Viewing/editing this post in the Dashboard will result in non-HTTPS images being served in an SSL environment.
b) `wp_get_attachment_url()` is used in a theme to generate an `<img>` `src` attribute on a public page. When viewing that page over SSL, the images will have HTTP URLs.

This changeset switches attachment URLs to HTTPS when it's determined that the
host supports SSL. This happens when 'siteurl' is non-SSL, but the current page
request *is* over SSL, and the host of the current request matches the host of
the URL being generated.

Props joemcgill, boonebgorges.
Fixes #15928.

git-svn-id: https://develop.svn.wordpress.org/trunk@31614 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-05 02:38:59 +00:00
Gary Pendergast d258490653 When sanitizing a URL to redirect to, UTF-8 characters can be URL encoded, instead of being removed.
While RFC 3986 does not specify which character sets are allowed in URIs, Section 2.5 states that octects matching UTF-8 character encoding should be percent-encoded, then unreserved octets outside of the UTF-8 range should be percent-encoded. As browsers tend to only implement support for UTF-8 in URLs, this change only implements the UTF-8 encoding part. We may revisit the second part if it becomes an issue.

Fixes #31486



git-svn-id: https://develop.svn.wordpress.org/trunk@31587 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-28 02:20:52 +00:00
Scott Taylor 65c58832cb Improve `get_media_embedded_in_content()` so that it returns the media it finds in the same order that it appears in the content.
Adds unit test, updates another.

Props kopepasah.
See #26675.


git-svn-id: https://develop.svn.wordpress.org/trunk@31574 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-27 16:11:00 +00:00
Boone Gorges e365b3a364 Add 'orderby=description' support to `get_terms()`.
This fixes an interface inconsistency in edit-tags.php, where Description
appears as a sortable column header.

Props neil_pie.
Fixes #31364.

git-svn-id: https://develop.svn.wordpress.org/trunk@31532 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-24 16:36:26 +00:00
Sergey Biryukov 4d61c79ca1 Fix line endings after [31522].
fixes #31430.

git-svn-id: https://develop.svn.wordpress.org/trunk@31531 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-24 10:05:48 +00:00
Sergey Biryukov 0421ee26ec Add unit tests for `get_page_template_slug()`.
props tyxla.
fixes #31389.

git-svn-id: https://develop.svn.wordpress.org/trunk@31522 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-23 18:47:01 +00:00
Boone Gorges 129e5f5278 Ensure that a request URL is always set in `WP_UnitTestCase::go_to()`.
Failure to set this variable meant that passing the home URL to `go_to()`
(without a trailing slash) resulted in a PHP notice, and failed to reset the
globals properly.

Props joostdevalk.
Fixes #31417.

git-svn-id: https://develop.svn.wordpress.org/trunk@31515 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-23 01:07:18 +00:00
Boone Gorges 1beeccc96f Use PHP 5.2 compatible syntax in image tests.
T_PAAMAYIM_NEKUDOTAYIM, HAKUNA_MATATA, YOLO.

See [31510], #31124.

git-svn-id: https://develop.svn.wordpress.org/trunk@31512 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-22 21:41:22 +00:00
Boone Gorges d854564f73 Better image-type support checks in image unit tests.
PHP can be compiled without support for certain image types. Our unit tests
should be sensitive to these configurations.

Fixes #31124.

git-svn-id: https://develop.svn.wordpress.org/trunk@31510 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-22 21:06:36 +00:00
Dominik Schilling (ocean90) 40bd738983 Adjust our QUnit test suite to show the QUnit toolbar.
props iseulde.
fixes #31413.

git-svn-id: https://develop.svn.wordpress.org/trunk@31502 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-22 15:31:14 +00:00
Boone Gorges 94791cd8f2 Respect 'default_option_' filters during early sanity checks in `add_option()` and `update_option()`.
`add_option()` and `update_option()` both call `get_option()` to compare the
value passed to the function with any existing value for the given option name.
When a `'default_option_'` filter is in place to change the default value of
an option, `add_option()` and `update_option()` ought to check against the
filtered value, rather than a hardcoded `false`, in order to determine whether
a prior value exists.

Props GregLone, tyxla.
Fixes #31047.

git-svn-id: https://develop.svn.wordpress.org/trunk@31473 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-18 19:13:43 +00:00
Boone Gorges 086e03e8e2 Improved handling of expectedDeprecated and expectedIncorrectUsage annotations in unit tests.
* Do the `expectedDeprecated()` check in `assertPostConditions()` instead of `tearDown()`. Previously, `fail`ing inside of `tearDown()` was causing the rest of the teardown process to be aborted, resulting in inter-test leakage.
* Collect all `expectedDeprecated` and `expectedIncorrectUsage` annotations in an entire method and display them all when `fail`ing, instead of showing only the first one.

Props jdgrimes.
Fixes #31362.

git-svn-id: https://develop.svn.wordpress.org/trunk@31469 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-17 16:11:09 +00:00
Boone Gorges 8bf5fce78f Improve 'orderby' syntax for `WP_Comment_Query`.
Since [29027], `WP_Query` has supported an array of values for the `$orderby`
parameter, with field names as array keys and ASC/DESC as the array values.
This changeset introduces the same syntax to `WP_Comment_Query`.

We leverage the new support for multiple ORDER BY clauses to fix a bug that
causes comments to be queried in an indeterminate order when sorting by the
default `comment_date_gmt` and comments share the same value for
`comment_date_gmt`. By always including a `comment_ID` subclause at the end of
the ORDER BY statement, we ensure that comments always have a unique fallback
for sorting.

This changeset also includes improvements paralleling those introduced to
`WP_Query` in [31312] and [31340], which allow `$orderby` to accept array keys
from specific `$meta_query` clauses. This change lets devs sort by multiple
clauses of an associated meta query. See #31045.

Fixes #30478. See #31265.

git-svn-id: https://develop.svn.wordpress.org/trunk@31467 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-16 14:09:40 +00:00
Boone Gorges 4138275df9 More careful type conversion in `WP_Query` `is_*()` methods.
`is_array( 1, '1-foo' )` returns true, which means that `is_page( 1 )`
was returning true when on a page with the slug '1-foo'. We avoid this odd
behavior by casting the queried object ID to a string before testing against
the value passed to the conditional function.

This also helps to avoid a problem where an arbitrary value for `$page` would
cause `is_page( $page )` to return true if the query had been manipulated by
a plugin to show that the current page's ID is 0.

Props boonebgorges, r-a-y, nunomorgadinho, wonderboymusic, clifgriffin.
Fixes #24674.

git-svn-id: https://develop.svn.wordpress.org/trunk@31458 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-14 02:08:46 +00:00
Sergey Biryukov 78b02ec722 Use more descriptive names for `register_post_type()` and `register_taxonomy()` tests with too long and too short names.
see #31134, #31135.

git-svn-id: https://develop.svn.wordpress.org/trunk@31457 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-13 23:33:56 +00:00
John Blackbourn f4d6d4e66b Return a `WP_Error` if an empty name is provided when registering a post type.
Fixes #31134
Props tyxla, MikeHansenMe


git-svn-id: https://develop.svn.wordpress.org/trunk@31450 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-13 16:42:36 +00:00
John Blackbourn 22fc19e06d Return a `WP_Error` if an empty name is provided when registering a taxonomy.
Fixes #31135
Props tyxla, MikeHansenMe


git-svn-id: https://develop.svn.wordpress.org/trunk@31449 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-13 16:26:37 +00:00
Boone Gorges ab10e5fe71 Add tests for some of `WP_Query`'s sticky post logic.
See #27282.

git-svn-id: https://develop.svn.wordpress.org/trunk@31439 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-13 02:24:57 +00:00
Dion Hulse afef491a75 Avoid a PHP Warning when `add_args` is passed as `false` to `paginate_links()`.
Props boonebgorges for the unit test.
See #30831 [31203].


git-svn-id: https://develop.svn.wordpress.org/trunk@31432 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-12 01:38:26 +00:00
Dominik Schilling (ocean90) d4c47d6364 Fix failing `Tests_Dependencies_jQuery::test_wp_script_is_dep_enqueued` test.
[31370] has broken the test because the Customizer test enqueues some scripts. Unset `$GLOBALS['wp_scripts']` on tearDown() so other tests will start with zero enqueued scripts.

see #30936.
fixes #31302.

git-svn-id: https://develop.svn.wordpress.org/trunk@31426 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-11 22:44:20 +00:00
Boone Gorges ed639b408a Split shared taxonomy terms on term update.
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.

In cases where a plugin or theme stores term IDs in the database, term splitting
can cause backward compatibility issues. The current changeset introduces
two utilities to aid developers with the transition. The `'split_shared_term'`
action fires when the split takes place, and should be used to catch changes in
term_id. In cases where `'split_shared_term'` cannot be used, the
`wp_get_split_term()` function gives developers access to data about terms
that have previously been split. Documentation for these functions, with
examples, can be found in the Plugin Developer Handbook. WordPress itself
stores term IDs in this way in two places; `_wp_check_split_default_terms()`
and `_wp_check_split_terms_in_menus()` are hooked to `'split_shared_term'` to
perform the necessary cleanup.

See [30241] for a previous attempt at the split. It was reverted in [30585]
for 4.1.0.

Props boonebgorges, mboynes.
See #5809.

git-svn-id: https://develop.svn.wordpress.org/trunk@31418 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-11 19:41:54 +00:00
Sergey Biryukov 757fd2c1e4 Always pass back the custom classes `get_post_class()` was called with, even if the post was not found.
props F J Kaiser, Bueltge.
fixes #22271.

git-svn-id: https://develop.svn.wordpress.org/trunk@31408 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-11 03:59:06 +00:00
Boone Gorges d4fbf04671 Don't parse empty 'tax_input' keys in `edit_post()`.
This fixes a bug introduced in [31359] where saving a tax_input that contained
only whitespace would result in a random tag being erroneously added to the
post.

See #30615.

git-svn-id: https://develop.svn.wordpress.org/trunk@31392 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-09 22:53:40 +00:00
Gary Pendergast be3c59e64c WPDB: Some character set tests were failing if `DB_CHARSET` was empty, or a non-utf8 character set.
git-svn-id: https://develop.svn.wordpress.org/trunk@31372 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-09 00:38:11 +00:00
Dominik Schilling (ocean90) 2518bbbb1f Customizer: Introduce an API to create WP_Customize_Settings for dynamically-created settings.
* Introduce WP_Customize_Manager::add_dynamic_settings() to register dynamically-created settings.
* Introduce `customize_dynamic_setting_args` filter to pass an array of args to a dynamic setting's constructor.
* Add unit tests for WP_Customize_Manager and WP_Customize_Widgets.
* See WP_Customize_Widgets as an example.

props westonruter.
fixes #30936.

git-svn-id: https://develop.svn.wordpress.org/trunk@31370 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-08 23:10:05 +00:00
Boone Gorges 76b84b9231 Add `orderby=meta_value_num` support to `WP_User_Query`.
Props tyxla, genkisan.
Fixes #27887.

git-svn-id: https://develop.svn.wordpress.org/trunk@31369 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-08 16:58:14 +00:00
Boone Gorges bdda122e7f In `WP_Query::get_queried_object()`, avoid PHP notices when `is_tax` is paired with an empty `tax_query`.
It's possible to have an empty `tax_query` and `is_tax=true` when the initial
query contains a taxonomy var (and is processed as such during
`WP_Query::parse_query()`) but the taxonomy var is unset during a 'parse_query'
callback. While this kind of behavior is not necessarily something we need to
support, we should continue to avoid PHP notices in such cases, as we did prior
to WP 4.1.

Fixes #31246.

git-svn-id: https://develop.svn.wordpress.org/trunk@31366 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-07 19:49:17 +00:00
Boone Gorges fb4048fcdd Parse non-hierarchical tag input into term IDs before sending to `wp_insert_post()`.
When editing a post, non-hierarchical taxonomy terms are sent as the
comma-separated list entered into the tax_input metabox. Passing these
values directly to `wp_update_post()` meant that they were interpreted as
term slugs rather than term names, causing mismatches when a typed string
matched the slug of one term and the name of a different term. We fix the
problem by preprocessing tax_input data sent from post.php, converting it to
unambiguous term_ids before saving.

Props boonebgorges, ArminBraun.
Fixes #30615.

git-svn-id: https://develop.svn.wordpress.org/trunk@31359 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-06 20:31:37 +00:00
Gary Pendergast 9f6ddf8944 WPDB: If a site is using the `utf8` charset, and their version of MySQL supports `utf8mb4`, auto-upgrade them to `utf8mb4`.
This patch also resizes some indexes, to allow for the 767 byte index size limit in standard MySQL installs.

See #21212



git-svn-id: https://develop.svn.wordpress.org/trunk@31349 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-06 04:50:19 +00:00
Boone Gorges 41db99c31a Use field-specific sanitization in `WP_Tax_Query::transform_query()`.
When terms are entered into the database, term fields are sanitized with
`sanitize_term_field()`. To ensure that the `SELECT ... WHERE` queries in
`WP_Tax_Query::transform_query()` are not broken by overzealous sanitization,
`sanitize_term_field()` should be used in that case as well. This fixes a bug
where a tax_query using 'field=name' would fail if the 'terms' parameter
contained characters (like spaces) that were improperly removed by
`sanitize_title_for_query()`.

Fixes #27810.

git-svn-id: https://develop.svn.wordpress.org/trunk@31346 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-06 02:01:24 +00:00
Boone Gorges 90947c2c45 Another array syntax fix for Customizer tests.
See [31339], #30988.

git-svn-id: https://develop.svn.wordpress.org/trunk@31342 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-05 19:54:06 +00:00
Boone Gorges 0f28011bcf Modify `meta_query orderby syntax to use array keys as clause "handles".
The implementation of `meta_query` orderby introduced in [31312] put clause
identifiers into a 'name' parameter of the clause. For greater clarity, this
changeset updates the syntax to use the associative array key used when
defining `meta_query` parameters, instead of the 'name' parameter.

Props Funkatronic, DrewAPicture.
Fixes #31045.

git-svn-id: https://develop.svn.wordpress.org/trunk@31340 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-05 19:37:47 +00:00
Boone Gorges 9d72e1c6a2 Use temporary variable for array in `Tests_Customize_Setting::test_preview_standard_types_multidimensional()`.
The syntax previously used - `call_user_func( 'foo' )['bar']`, where `foo()`
returns an array - is not valid on all supported versions of PHP, and was
breaking the CI builds.

See #30988.

git-svn-id: https://develop.svn.wordpress.org/trunk@31339 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-05 19:18:16 +00:00
Boone Gorges c9c9af5df8 Introduce `'value_field'` parameter to `wp_dropdown_pages()`.
This parameter allows developers to choose the post field that will be used to
fill in the 'option' attribute of the generated dropdown markup.

See [31006] #30306 for a parallel enhancement in `wp_dropdown_categories()`.

Props jfarthing84.
Fixes #12494.

git-svn-id: https://develop.svn.wordpress.org/trunk@31338 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-05 19:03:52 +00:00
Dominik Schilling (ocean90) 8bc9ad756d Ensure that `WP_Customize_Setting::value()` returns default value for setting if not dirty.
There was regression introduced by #28580 where only changed (dirty) settings now are POST'ed to the Customizer preview.

* Allow WP_Customize_Manager::post_value() to accept a second $default argument.
* Introduce WP_Customize_Manager::unsanitized_post_values() for accessing previously-private member variable _post_values.
* Do require_once instead of require for Customizer classes.
* Add unit tests for WP_Customize_Manager and WP_Customize_Setting.

props westonruter.
fixes #30988.

git-svn-id: https://develop.svn.wordpress.org/trunk@31329 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-03 10:14:28 +00:00
Sergey Biryukov 5e9b89bf59 When using WP_Query's `'fields' => 'ids'` (or `'fields' => 'id=>parent'`), make sure the returned result is always an array of integers.
fixes #31194. see #27252.

git-svn-id: https://develop.svn.wordpress.org/trunk@31324 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-03 02:28:52 +00:00
Boone Gorges f05f380638 In `get_sample_permalink()`, override 'future' status before generating permalink.
In [31114], `get_permalink()` was modified to prevent pretty permalinks from
being generated for posts with the 'future' post status. This inadvertently
broke the pretty permalink preview for scheduled posts. The fix is to include
the 'future' status in the list of statuses that `get_sample_permalink()` fakes
as 'publish' before it fetches a permalink.

Props DrewAPicture.
Fixes #30910.

git-svn-id: https://develop.svn.wordpress.org/trunk@31323 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-02 16:49:23 +00:00
Boone Gorges 5f6ea53e86 When querying for a specific post, allow posts with a non-public status to be returned as long as that status is specified.
This makes it possible to, for example, retrieve a specific post using the
`p` parameter of `WP_Query`, even if the post is in the Trash, by including
the `post_status=trash` parameter.

Props ebinnion.
Fixes #29167.

git-svn-id: https://develop.svn.wordpress.org/trunk@31321 602fd350-edb4-49c9-b593-d223f7449a82
2015-02-01 20:25:42 +00:00
Andrew Ozz 9391d4f572 Separate the tests for IE conditional comments support in WP_Scripts. Props valendesigns, see 16024.
git-svn-id: https://develop.svn.wordpress.org/trunk@31317 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-31 20:40:49 +00:00
Boone Gorges 32f2903248 Prevent terms in a show_in_quick_edit=false taxonomy from being updated by a faked AJAX request.
The UI for these taxonomies was hidden in [31308], but it remained possible to
send a direct POST request to the `inline-edit` endpoint to bypass the
restriction. The current changeset fixes this.

Props meloniq.
Fixes #26948.

git-svn-id: https://develop.svn.wordpress.org/trunk@31313 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-31 19:37:12 +00:00
Boone Gorges 2d737796d2 Improve support for ordering `WP_Query` results by postmeta.
`WP_Meta_Query` clauses now support a 'name' parameter. When building a
`WP_Query` object, the value of 'orderby' can reference this 'name', so that
it's possible to order by any clause in a meta_query, not just the first one
(as when using 'orderby=meta_value'). This improvement also makes it possible
to order by multiple meta query clauses (or by any other eligible field plus
a meta query clause), using the array syntax for 'orderby' introduced in [29027].

Props Funkatronic, boonebgorges.
Fixes #31045.

git-svn-id: https://develop.svn.wordpress.org/trunk@31312 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-31 15:47:51 +00:00
Sergey Biryukov f36af772ea Remove redundant parameter.
see #30753.

git-svn-id: https://develop.svn.wordpress.org/trunk@31311 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-31 02:11:46 +00:00
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