`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
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
`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
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
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
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
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
`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
* 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
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
`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
[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
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
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
* 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
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
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
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
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
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
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
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
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
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
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
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
`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
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
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
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
`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
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
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
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
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
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
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
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
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
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
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
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
* 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
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
[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
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
Unlike `get_avatar()`, `get_avatar_url()` is not pluggable. It can be extended/or modified through the new filters included.
Fixes#21195.
Props mdawaffe, pento, pathawks, DrewAPicture
git-svn-id: https://develop.svn.wordpress.org/trunk@31107 602fd350-edb4-49c9-b593-d223f7449a82