Removes the restoration logic, which leveraged a static property initialized with `get_option()`.
See #33968.
git-svn-id: https://develop.svn.wordpress.org/trunk@34807 602fd350-edb4-49c9-b593-d223f7449a82
The function now uses the following order of precedence when calculating
comment pagination: 1. the 'per_page' value passed in the `$args` array,
2. the 'comments_per_page' query var in `$wp_query`, and 3. the
'comments_per_page' setting from options-discussion.php. This change allows
`get_page_of_comment()` to return an accurate value before the main query
has been run.
Props laceous.
See #13939.
git-svn-id: https://develop.svn.wordpress.org/trunk@34806 602fd350-edb4-49c9-b593-d223f7449a82
This prevents notices from being thrown when a 'pre_get_users' callback
removes required values from the list of `query_vars`.
For backward compatibility with previous uses of 'pre_get_users', default
values are parsed both before and after the action is fired.
Fixes#33449.
git-svn-id: https://develop.svn.wordpress.org/trunk@34804 602fd350-edb4-49c9-b593-d223f7449a82
Introduces `add_network_option()`, `update_network_option()`, `get_network_option()`, and `delete_network_option()`, which use the internals previously found in the `*_site_option()` functions and allow for a network ID to enable cross network storage and retrieval of network options.
* `*_site_option()` functions are now wrappers for `*_network_option()` and will interact with options for the current network in a multisite environment.
* All will continue to fallback to `*_option()` for non-multisite uses.
* Adds basic tests for cross network storage and retrieval.
* Existing tests for `*_site_option()` functions provide coverage for storage and retrieval of current network options.
Props spacedmonkey, DrewAPicture, jeremyfelt.
See #28290.
git-svn-id: https://develop.svn.wordpress.org/trunk@34777 602fd350-edb4-49c9-b593-d223f7449a82
After [33807], `Tests_Image_Intermediate_Size::test_get_intermediate_sizes_by_array_zero_width()`
was failing intermittently. This failure was due to the use of a random number
for the image height. When the height was sufficiently large - $height >= 202 -
to change the aspect ratio of the cropped image (based on WP's threshold of a
1px difference), the test passed. And when the height was exactly 200, the
medium image size was hit exactly. The failure occurred only with a height of
201, which is close enough to 200 so that WP determined that the aspect ratio
of the potential crop was close enough to match.
The current changeset splits the test into two, in order to demonstrate the
failure.
See #17626. Fixes#34087.
git-svn-id: https://develop.svn.wordpress.org/trunk@34775 602fd350-edb4-49c9-b593-d223f7449a82
* Add test file accidentally omitted from [34761].
* Bail properly from benchmarker when a `preg_last_error()` is found.
Props miqrogroove.
See #34121.
git-svn-id: https://develop.svn.wordpress.org/trunk@34773 602fd350-edb4-49c9-b593-d223f7449a82
In versions of PHP earlier than 5.4, the `$matches` parameter was required.
Excluding it here meant that PCRE benchmarking tests were erroring on older
versions of PHP without cleaning up the PCRE ini settings, causing various
problems on later tests.
Props miqrogroove, dd32, boonebgorges.
And to the cosmic forces that cause bugs like this. The best part of waking up
is diagnosing leakage between automated tests.
See #34121.
git-svn-id: https://develop.svn.wordpress.org/trunk@34772 602fd350-edb4-49c9-b593-d223f7449a82
* Move pattern from `wptexturize()` into a separate function.
* Move pattern from `wp_html_split()` into a separate function.
* Beautify code for `wp_html_split()`.
* Remove unnecessary instances of `/s` modifier in patterns that don't use dots.
* Add `tests/phpunit/data/formatting/whole-posts.php` for testing larger strings.
* Add function `benchmark_pcre_backtracking()`.
* Add tests for `wp_html_split()`.
* Add tests for `wptexturize()`.
* Add tests for `get_shortcode_regex()`.
Props miqrogroove.
Fixes#34121.
git-svn-id: https://develop.svn.wordpress.org/trunk@34761 602fd350-edb4-49c9-b593-d223f7449a82
Specifically, `::insert()`, `::replace()`, `::update()`, and `::delete()` can now set a column to `NULL`, or add the `IS NULL` condition to the `WHERE` clause.
This is based on [backpress 279].
Props pento, nbachiyski, sorich87.
Fixes#15158.
git-svn-id: https://develop.svn.wordpress.org/trunk@34737 602fd350-edb4-49c9-b593-d223f7449a82
After [34561], `wp_list_comments()` no longer passed all of a post's comments
to `Walker_Comments`. As a result, calls to `get_comment_link()` occurring
inside the comment loop had insufficient context to determine the proper
'cpage' value to use when generating comment permalinks. This, in turn, caused
comment permalinks to behave erratically.
The current changeset addresses the problem as follows:
* `get_comment_link()` now accepts a 'cpage' parameter. When present, 'cpage' will be used to build the comment permalink - no automatic calculation will take place.
* When called within the main loop, `wp_list_comments()` calculates the proper 'cpage' value for comments in the loop, and passes it down to `get_comment_link()`.
* `cpage` and `comment-page-x` query vars are generally required in comment permalinks (see #34068), but an exception is made when 'default_comment_page=oldest': the bare post permalink will always be the same as `cpage=1`, so `cpage` is excluded in this case.
Props peterwilsoncc for assiduous spreadsheeting.
Fixes#34073.
git-svn-id: https://develop.svn.wordpress.org/trunk@34735 602fd350-edb4-49c9-b593-d223f7449a82
[34561] "fixed" the problem of newest-first comments showing fewer than
'per_page' comments on the post permalink when the total number of comments
was not divisible by 'per_page'. See #29462. But this fix caused numerous
other problems. First, comment pages reported by `get_page_of_comment()`
(which expects comment pages to be filled oldest-first) were no longer correct.
Second, and more seriously, the new logic caused comments to be shifted
between pages, making their permalinks non-permanent.
The current changeset reverts the changed behavior. In order to preserve the
performance improvements introduced in [34561], an additional query must be
performed when 'default_comments_page=newest' and 'cpage=0' (ie, you're viewing
the post permalink). A nice side effect of this revert is that we no longer
need the hacks required to determine proper comment pagination, introduced in
[34561].
See #8071. See #34073.
git-svn-id: https://develop.svn.wordpress.org/trunk@34729 602fd350-edb4-49c9-b593-d223f7449a82
Continuing with the "code is poetry" theme after [34719], we need to continue
to update the option in the database on non-multisite in this
`wp_insert_term()` test.
See #31130.
git-svn-id: https://develop.svn.wordpress.org/trunk@34720 602fd350-edb4-49c9-b593-d223f7449a82
[34718] introduced a 'db_version' check to term meta functions, to ensure that
they don't run when the term meta schema is not yet in place. This call to
`get_option()` causes a database hit during Multisite tests, due to the
presence of the `WP_INSTALLING` constant. See #31130. The extra database
queries are causing cache tests to fail.
In similar cases, we have `markTestSkipped()` when `is_multisite()`. Because
the term meta API is so extensive - term meta caches can be primed anywhere a
`WP_Query` loop is fired up - we implement a more generous workaround in this
case. To prevent `get_option( 'db_version' )` from hitting the database during
multisite unit tests, we use a 'pre_option_' filter.
Heaven help us.
See #34091.
git-svn-id: https://develop.svn.wordpress.org/trunk@34719 602fd350-edb4-49c9-b593-d223f7449a82
The tests included in [34669] contained a couple of problems:
* Comments were not always created in the expected order, due to the incorrect use of 'comment_date_gmt'.
* 'asc'/'desc' and 'older'/'newer' were confused.
* 'default_comments_page=newest' ('last') didn't properly account for the cpage=1 offset.
The code itself powering this pagination was correct; it's only the tests that
were wrong.
See #8071.
git-svn-id: https://develop.svn.wordpress.org/trunk@34713 602fd350-edb4-49c9-b593-d223f7449a82
Lazy-loading logic is moved to a method on `WP_Query`. This makes it possible
for comment feeds to take advantage of metadata lazyloading, in addition to
comments loaded via `comments_template()`.
This new technique parallels the termmeta lazyloading technique introduced in
[34704].
Fixes#34047.
git-svn-id: https://develop.svn.wordpress.org/trunk@34711 602fd350-edb4-49c9-b593-d223f7449a82
[34529] introduced lazyloading for the metadata belonging to terms matching
posts in the main `WP_Query`. The current changeset improves this technique
in the following ways:
* Term meta lazyloading is now performed on the results of all `WP_Query` queries, not just the main query.
* Fewer global variable touches and greater encapsulation.
* The logic for looping through posts to identify terms is now only performed once per `WP_Query`.
Props dlh, boonebgorges.
See #34047.
git-svn-id: https://develop.svn.wordpress.org/trunk@34704 602fd350-edb4-49c9-b593-d223f7449a82
The 'exclude_tree' parameter must be compatible with 'hierarchical';
previously, 'hierarchical' canceled it out. This changeset also makes it so
that 'exclude_tree' is compatible with 'exclude'. When both are passed, and
'hierarchical' is true, the descendant trees of terms in both parameters will
be excluded from matched terms.
Props tott, webord, MikeHansenMe.
Fixes#12981.
git-svn-id: https://develop.svn.wordpress.org/trunk@34696 602fd350-edb4-49c9-b593-d223f7449a82
Previously, unattached attachments would have unsightly `/?attachment_id=1` URLs. As we've moved away from attachments being specifically attached to posts, instead being Media items, this has made the unattached URLs a more common occurrence.
We can breath easy once more, knowing that the world is a little bit safer from the horror of unnecessarily ugly URLs.
Props SergeyBiryukov, wonderboymusic, pento.
Fixes#1914.
git-svn-id: https://develop.svn.wordpress.org/trunk@34690 602fd350-edb4-49c9-b593-d223f7449a82
Using the same logic that we use to redirect posts when their slug changes, we can provide the same functionality for attachments. Attachment pages are posts, too.
Props swissspdy.
Fixes#34043.
git-svn-id: https://develop.svn.wordpress.org/trunk@34685 602fd350-edb4-49c9-b593-d223f7449a82
`the_author_posts_link()` has in-turn been converted into a wrapper, with most of its logic moved to the new function.
Adds tests for the new function.
Props chipbennett, zrothauser, wonderboymusic, DrewAPicture.
Fixes#30355.
git-svn-id: https://develop.svn.wordpress.org/trunk@34677 602fd350-edb4-49c9-b593-d223f7449a82
Square brackets must be encoded in the path, path parameters, query parameters, and fragment, but must not be encoded in anything up to the domain and port.
Adds a bunch of tests, including square brackets in query parameters, IPv6 URLs, and several other permutations.
See #16859
git-svn-id: https://develop.svn.wordpress.org/trunk@34674 602fd350-edb4-49c9-b593-d223f7449a82
Also fixes unit tests post-[34670]. The test methods have been slightly renamed because it is no longer a button. Hopefully this name will be more future-proof.
see #18306.
git-svn-id: https://develop.svn.wordpress.org/trunk@34671 602fd350-edb4-49c9-b593-d223f7449a82
The old comment pagination logic had a separate block for comment threads that
appeared on a single page. After the refactoring in [34561], all comment
pagination logic is unified.
This change ensures that 'comment_order' is respected in all scenarios.
Fixes#8071.
git-svn-id: https://develop.svn.wordpress.org/trunk@34669 602fd350-edb4-49c9-b593-d223f7449a82
Historically, `wp_old_slug_redirect()` has only ever redirected the old slug of posts, it hasn't included URL endpoints, or worked with comment feed URLs. By adding support for these, we ensure a greater range of URLs aren't killed when the slug changes.
Props swissspdy.
Fixes#33920.
git-svn-id: https://develop.svn.wordpress.org/trunk@34659 602fd350-edb4-49c9-b593-d223f7449a82
In [30298] the unit tests default confirguration was modified to exclude external-http tests. This change was never migrated to the multisite XML configuration. The external HTTP code doesn't follow different logic in multisite, so the logic to exclude the tests then ( The external-http tests are very slow, and Wp_Http functionality is fairly isolated ) holds true here as well.
See #33968
git-svn-id: https://develop.svn.wordpress.org/trunk@34656 602fd350-edb4-49c9-b593-d223f7449a82
Previously, we'd run the sanity checks if `is_mysql` was not set to `false`. This caused problems for DB drop-ins that didn't define `is_mysql` at all. Instead, we can just check if `is_mysql` is `empty()`.
Also fix some unit tests that accidently ran correctly because of the strict `false ===` comparison.
Fixes#33501.
git-svn-id: https://develop.svn.wordpress.org/trunk@34655 602fd350-edb4-49c9-b593-d223f7449a82
When `wp_page_menu()` is used as a fallback for `wp_nav_menu()`, the `before` and `after` arguments should be set and output as `<ul>` and `</ul>`, respectively.
See #11095. See [34653].
git-svn-id: https://develop.svn.wordpress.org/trunk@34654 602fd350-edb4-49c9-b593-d223f7449a82
This fixes issues with local HTTPS requests (eg. WP Cron) on OS X where cURL is using SecureTransport instead of OpenSSL.
Fixes#33978
git-svn-id: https://develop.svn.wordpress.org/trunk@34639 602fd350-edb4-49c9-b593-d223f7449a82
When passing a value of 'slug' to `wp_insert_term()` that contains non-ASCII
characters, WordPress converts accented characters to non-accented versions.
(See `sanitize_title()` and `remove_accents()`.) The same conversion happens
when fetching when fetching a term using a slug. In this way, it's possible to
create a term and fetch it using the same accented string, even though the slug
is actually stored with non-accented characters.
See #16282.
git-svn-id: https://develop.svn.wordpress.org/trunk@34628 602fd350-edb4-49c9-b593-d223f7449a82
This change was introduced in [34601]. 0 is a special snowflake. The code treats it as if it should fall back to the default, rather than respecting 0 as 0. Essentially, 0 means 100. WAT? This has been discussed previusly in https://core.trac.wordpress.org/ticket/19538#comment:10. This test should return True right now, but the behavior should be discussed and in the future 0 may mean 0.
See #34037
Props jorbin, boonebgorges
git-svn-id: https://develop.svn.wordpress.org/trunk@34606 602fd350-edb4-49c9-b593-d223f7449a82
This test was added [34577], but shouldn't have been, because the bug it
describes has not been fixed.
See #21292.
git-svn-id: https://develop.svn.wordpress.org/trunk@34604 602fd350-edb4-49c9-b593-d223f7449a82
Travis doesn't properly support SSL on older versions of PHP. Since we don't test for SSL support in all of the tests, this can cause these tests to fail. This changes a URL introduced in [34568]
See #33968
git-svn-id: https://develop.svn.wordpress.org/trunk@34600 602fd350-edb4-49c9-b593-d223f7449a82
[34583] modified comment queries so that all post fields are no longer loaded
by default. Instead, they are loaded only when requested on individual comment
objects. This changeset improves that flow:
* `WP_Comment` magic methods `__isset()` and `__get()` should only load the post when a post field is being requested.
* The new `update_comment_post_cache` argument for `WP_Comment_Query` allows developers to specify that, when comments are queried, all of the posts matching those comments should be loaded into cache with a single DB hit. This parameter defaults to false, since typical comment queries are linked to a single post.
Fixes#27571.
git-svn-id: https://develop.svn.wordpress.org/trunk@34599 602fd350-edb4-49c9-b593-d223f7449a82
Adds (rewrites) unit tests from 4 years ago that we never committed because....
Props wonderboymusic, koke, ericmann, nprasath002.
Fixes#17981.
git-svn-id: https://develop.svn.wordpress.org/trunk@34570 602fd350-edb4-49c9-b593-d223f7449a82
For threaded comments, we need comments to be retrieved within bounds, so logged-out users don't see unmoderated comments on the front end, etc.
Updates unit tests.
See #8071.
git-svn-id: https://develop.svn.wordpress.org/trunk@34569 602fd350-edb4-49c9-b593-d223f7449a82
The Menu Customizer feature includes a performance technique whereby the controls for nav menu items are only embedded into the DOM once the containing menu section is expanded. This commit implements the same DOM deferral for widgets but goes a step further than just embedding the controls once the widget area's Customizer section is expanded: it also defers the embedding of the widget control's form until the widget is expanded, at which point the `widget-added` event also fires to allow any additional widget initialization to be done. The deferred DOM embedding can speed up initial load time by 10x or more. This DOM deferral also yields a reduction in overall memory usage in the browser process.
Includes changes to `wp_widget_control()` to facilitate separating out the widget form from the surrounding accordion container; also includes unit tests for this previously-untested function. Also included are initial QUnit tests (finally) for widgets in the Customizer.
Fixes#33901.
git-svn-id: https://develop.svn.wordpress.org/trunk@34563 602fd350-edb4-49c9-b593-d223f7449a82
Previously, the 'page_comments' toggle allowed users to disable comment
pagination. This toggle was only superficial, however. Even with
'page_comments' turned on, `comments_template()` loaded all of a post's
comments into memory, and passed them to `wp_list_comments()` and
`Walker_Comment`, the latter of which produced markup for only the
current page of comments. In other words, it was possible to enable
'page_comments', thereby showing only a subset of a post's comments on a given
page, but all comments continued to be loaded in the background. This technique
scaled poorly. Posts with hundreds or thousands of comments would load slowly,
or not at all, even when the 'comments_per_page' setting was set to a
reasonable number.
Recent changesets have addressed this problem through more efficient tree-
walking, better descendant caching, and more selective queries for top-level
post comments. The current changeset completes the project by addressing the
root issue: that loading a post causes all of its comments to be loaded too.
Here's the breakdown:
* Comment pagination is now forced. Setting 'page_comments' to false leads to evil things when you have many comments. If you want to avoid pagination, set 'comments_per_page' to something high.
* The 'page_comments' setting has been expunged from options-discussion.php, and from places in the codebase where it was referenced. For plugins relying on 'page_comments', we now force the value to `true` with a `pre_option` filter.
* `comments_template()` now queries for an appropriately small number of comments. Usually, this means the `comments_per_page` value.
* To preserve the current (odd) behavior for comment pagination links, some unholy hacks have been inserted into `comments_template()`. The ugliness is insulated in this function for backward compatibility and to minimize collateral damage. A side-effect is that, for certain settings of 'default_comments_page', up to 2x the value of `comments_per_page` might be fetched at a time.
* In support of these changes, a `$format` parameter has been added to `WP_Comment::get_children()`. This param allows you to request a flattened array of comment children, suitable for feeding into `Walker_Comment`.
* `WP_Query` loops are now informed about total available comment counts and comment pages by the `WP_Comment_Query` (`found_comments`, `max_num_pages`), instead of by `Walker_Comment`.
Aside from radical performance improvements in the case of a post with many
comments, this changeset fixes a bug that caused the first page of comments to
be partial (`found_comments` % `comments_per_page`), rather than the last, as
you'd expect.
Props boonebgorges, wonderboymusic.
Fixes#8071.
git-svn-id: https://develop.svn.wordpress.org/trunk@34561 602fd350-edb4-49c9-b593-d223f7449a82
* Don't allow comments to be created for posts that have `comment_status` set to `'closed'`
* Set some magic props on `WP_User` to vars before passing them to `wp_xmlrpc_server::escape()`
Props wonderboymusic, jesin.
Fixes#27471.
git-svn-id: https://develop.svn.wordpress.org/trunk@34559 602fd350-edb4-49c9-b593-d223f7449a82
Comments can be threaded. Now your query can be threaded too! Bonus: it's
not totally insane.
* The new `$hierarchical` parameter for `WP_Comment_Query` accepts three values:
* `false` - Default value, and equivalent to current behavior. No descendants are fetched for matched comments.
* `'flat'` - `WP_Comment_Query` will fetch the descendant tree for each comment matched by the query paramaters, and append them to the flat array of comments returned. Use this when you have a separate routine for constructing the tree - for example, when passing a list of comments to a `Walker` object.
* `'threaded'` - `WP_Comment_Query` will fetch the descendant tree for each comment, and return it in a tree structure located in the `children` property of the `WP_Comment` objects.
* `WP_Comment` now has a few utility methods for fetching the descendant tree (`get_children()`), fetching a single direct descendant comment (`get_child()`), and adding anothing `WP_Comment` object as a direct descendant (`add_child()`). Note that `add_child()` only modifies the comment object - it does not touch the database.
Props boonebgorges, wonderboymusic.
See #8071.
git-svn-id: https://develop.svn.wordpress.org/trunk@34546 602fd350-edb4-49c9-b593-d223f7449a82
`WP_Comment_Query` will now report the total number of comments matching the
query params (`comments_found`), as well as the total number of pages required
to display these comments (`max_num_pages`). Because `SQL_CALC_FOUND_ROWS`
queries can introduce a lot of overhead in some cases, we disable the feature
by default. Pass `no_found_rows=false` to `WP_Comment_Query` to enable the
count. (We use the negative parameter name 'no_found_rows' for parity with
`WP_Query`.)
Props wonderboymusic, boonebgorges.
See #8071.
git-svn-id: https://develop.svn.wordpress.org/trunk@34544 602fd350-edb4-49c9-b593-d223f7449a82
`get_page_of_comment()` uses `get_option()`, and WP_INSTALLING earlier in the
test suite causes `get_option()` to miss the cache. See #31130.
See #11334.
git-svn-id: https://develop.svn.wordpress.org/trunk@34540 602fd350-edb4-49c9-b593-d223f7449a82
The 'last_changed' incrementor is used to invalidate the `get_terms()` query
cache. Since `get_terms()` queries may reference 'meta_query', changing term
metadata could change the results of the queries. So we invalidate the cache
on add, delete, and update.
See #10142.
git-svn-id: https://develop.svn.wordpress.org/trunk@34538 602fd350-edb4-49c9-b593-d223f7449a82
The new `$comment_meta` parameter of `wp_insert_comment()` allows an array of
key/value pairs to be passed when creating a comment. These pairs are then
stored as commentmeta when the comment has been created.
Props tellyworth, wonderboymusic.
Fixes#12431.
git-svn-id: https://develop.svn.wordpress.org/trunk@34533 602fd350-edb4-49c9-b593-d223f7449a82
The test `Tests_Multisite_Site::test_created_site_details()` checks for tables
that should be empty on a newly created MS site. `termmeta` is now one of those
tables.
See #10142.
git-svn-id: https://develop.svn.wordpress.org/trunk@34532 602fd350-edb4-49c9-b593-d223f7449a82
This is an alternative to using 'offset', and manually calculating pagination.
Note that 'paged' works only in conjunction with 'number', the latter of which
provides the per-page value.
Props sebastian.pisula.
Fixes#25145.
git-svn-id: https://develop.svn.wordpress.org/trunk@34531 602fd350-edb4-49c9-b593-d223f7449a82
Adds a new table to the database schema (`wp_termmeta`), and a set of
`*_term_meta()` API functions. `get_terms()` and `wp_get_object_terms()`
now also support 'meta_query' parameters, with syntax identical to other
uses of `WP_Meta_Query`.
When fetching terms via `get_terms()` or `wp_get_object_terms()`, metadata for
matched terms is preloaded into the cache by default. Disable this behavior
by setting the new `$update_term_meta_cache` paramater to `false`.
To maximize performance, within `WP_Query` loops, the termmeta cache is *not*
primed by default. Instead, we use a lazy-loading technique: metadata for all
terms belonging to posts in the loop is loaded into the cache the first time
that `get_term_meta()` is called within the loop.
Props boonebgorges, sirzooro.
See #10142.
git-svn-id: https://develop.svn.wordpress.org/trunk@34529 602fd350-edb4-49c9-b593-d223f7449a82
XML-RPC: In `wp_xmlrpc_server::wp_editComment()`, allow comments to be trashed.
Introduce unit tests for `wp_editComment` in `xmlrpc/*` #NeverForget
Props tyxla, wonderboymusic.
Fixes#30965.
git-svn-id: https://develop.svn.wordpress.org/trunk@34524 602fd350-edb4-49c9-b593-d223f7449a82
Create the first ever unit tests for `get_comment_excerpt()`.
Props dannydehaan, wonderboymusic.
Fixes#27526.
git-svn-id: https://develop.svn.wordpress.org/trunk@34520 602fd350-edb4-49c9-b593-d223f7449a82
Also corrects a test value in the data provider for `Tests_Sanitize_Option::test_sanitize_option()` which was only consequentially passing.
Fixes#34000
git-svn-id: https://develop.svn.wordpress.org/trunk@34519 602fd350-edb4-49c9-b593-d223f7449a82
Awesome rewrite bug: the `page` query var was being set to `'/4'` in `$wp`. When cast to `int`, it returns `0` (Bless you, PHP). `WP_Query` calls `trim( $page, '/' )` when setting its own query var. The few places that were checking `page` before posts were queried now have sanity checks, so that these changes work without flushing rewrites.
Adds/updates unit tests.
Props wonderboymusic, dd32.
See #11694.
git-svn-id: https://develop.svn.wordpress.org/trunk@34492 602fd350-edb4-49c9-b593-d223f7449a82
The `comment_date_gmt` field of the `wp_comments` table is indexed, which makes
`WHERE` matches against the field much faster than against the unindexed
`comment_date`. For bulk operations like data import, the speed difference can
be meaningful.
We continue to default to 'blog' for `$timezone`, to preserve compatibility
with existing uses.
Props apokalyptik.
Fixes#33871.
git-svn-id: https://develop.svn.wordpress.org/trunk@34460 602fd350-edb4-49c9-b593-d223f7449a82
This helps to avoid PHP notices later in the function.
Props walterebert, dipesh.kakadiya, DrewAPicture.
Fixes#33947.
git-svn-id: https://develop.svn.wordpress.org/trunk@34454 602fd350-edb4-49c9-b593-d223f7449a82
[34374] added a test that relies on a new test image. This test image wasn't included in the commit. This fixes the broken Tests_Image_Meta::test_exif_keywords test.
Props swissspidy, SteveHoneyNZ.
Fixes#33772.
git-svn-id: https://develop.svn.wordpress.org/trunk@34448 602fd350-edb4-49c9-b593-d223f7449a82
`WP_Comment_Query` now fetches comments in two stages: (1) a query to get the
IDs of comments matching the query vars, and (2) a query to populate the
objects corresponding to the matched IDs. The two queries are cached
separately, so that sites with persistent object caches will continue to have
complete cache coverage for normal comment queries.
Splitting the query allows our cache strategy to be more modest and precise, as
full comment data is only stored once per comment. It also makes it possible
to introduce logic for paginated threading, which is necessary to address
certain performance problems.
See #8071.
data is only stored once per comment, instead of along with
git-svn-id: https://develop.svn.wordpress.org/trunk@34310 602fd350-edb4-49c9-b593-d223f7449a82
[34268] introduced cache priming for commentmeta, enabled by default. To
ensure performance on single post pages - where commentmeta is most likely
to cause performance issues - we disable up-front cache-priming. Instead, we
prime commentmeta caches for all comments in the loop the first time
`get_comment_meta()` is called on the page.
Props bradt, dd32, wonderboymusic, boonebgorges.
Fixes#16894.
git-svn-id: https://develop.svn.wordpress.org/trunk@34270 602fd350-edb4-49c9-b593-d223f7449a82
When there are hundreds of settings and controls (e.g. nav menu items and widget instances) the resulting object that is JSON-encoded can become very large, and `wp_json_encode()` can consume a lot of memory to serialize it. By breaking down the serialization into multiple calls the peak memory usage can be kept in line.
Moves logic out of `wp-admin/customize.php` into the `WP_Customize_Manager` class with new methods:
* `is_ios()`
* `get_document_title_template()`
* `get_preview_url()`/`set_preview_url()`
* `get_return_url()`/`set_return_url()`
* `get_autofocus()`/`set_autofocus()`
* `customize_pane_settings()`
Includes unit tests for these methods, for which the logic was formerly untestable in `customize.php`.
Fixes#33898.
git-svn-id: https://develop.svn.wordpress.org/trunk@34269 602fd350-edb4-49c9-b593-d223f7449a82
The new 'update_comment_meta_cache' parameter, which defaults to `true`, can
be used to disable this behavior.
`update_comment_cache()` has been updated to support an `$update_meta_cache`
parameter, which also updates to true; this matches the pattern we use for
priming post caches.
See #16894.
git-svn-id: https://develop.svn.wordpress.org/trunk@34268 602fd350-edb4-49c9-b593-d223f7449a82
[34106] moved post author notification to a hook, and in the process, missed
the 'spam' check. This changeset restores that check.
To make unit testing easier, the notification callbacks have been refactored
to return values: false when various conditions aren't met (eg, approved
comments should not trigger moderation emails), and the return value of the
`wp_notify_*()` function otherwise.
Props cfinke, kraftbj.
See #33587.
git-svn-id: https://develop.svn.wordpress.org/trunk@34250 602fd350-edb4-49c9-b593-d223f7449a82
[13216] introduced the 'public' argument for `register_taxonomy()`. This param
was used to set defaults for 'show_ui' and a number of other params, but it
never did anything itself.
With this changeset, taxonomies registered with `public=false` will no longer
be queryable on the front end, ie via taxonomy archive queries.
Props wpsmith, ocean90, nacin, ericlewis, boonebgorges.
Fixes#21949.
git-svn-id: https://develop.svn.wordpress.org/trunk@34247 602fd350-edb4-49c9-b593-d223f7449a82
The `user_login` field only allows 60 characters, and `user_nicename` allows
50. However, there are no protections in the interface, and few in the code,
that prevent the creation of users with values in excess of these limits. Prior
to recent changes in `$wpdb`, users were generally created anyway, MySQL
having performed the necessary truncation. More recently, the `INSERT`s and
`UPDATE`s simply fail, with no real feedback on the nature of the failure.
This changeset addresses the issue in a number of ways:
* On the user-new.php and network/user-new.php panels, don't allow input in excess of the maximum field length.
* In `wp_insert_user()`, throw an error if the value provided for `'user_login'` or `'user_nicename'` exceeds the maximum field length.
* In `wp_insert_user()`, when using `'user_login'` to generate a default value for `'user_nicename'`, ensure that the nicename is properly truncated, even when suffixed for uniqueness (username-2, etc).
Props dipesh.kakadiya, utkarshpatel, tommarshall, boonebgorges.
Fixes#33793.
git-svn-id: https://develop.svn.wordpress.org/trunk@34218 602fd350-edb4-49c9-b593-d223f7449a82
In `_unregister_post_type()` (unit tests), don't add query vars of non-viewable post types to `WP::public_query_vars`.
Adds unit test.
Fixes#30018.
git-svn-id: https://develop.svn.wordpress.org/trunk@34215 602fd350-edb4-49c9-b593-d223f7449a82
We already accept 'id'. `ID` more closely matches the database and
`WP_User` schemas.
Props Shelob9.
Fixes#33869.
git-svn-id: https://develop.svn.wordpress.org/trunk@34125 602fd350-edb4-49c9-b593-d223f7449a82
The second parameter `$plaintext_pass` was removed in [33023] and restored as `$notify` in [33620] with a different behavior. If you have a plugin overriding `wp_new_user_notification()` which hasn't been updated you would get a notification with your username and the password "both".
To prevent this the second parameter is now deprecated and reintroduced as the third parameter.
Adds unit tests.
Props kraftbj, adamsilverstein, welcher, ocean90.
Fixes#33654.
(Don't ask for new pluggables kthxbye)
git-svn-id: https://develop.svn.wordpress.org/trunk@34116 602fd350-edb4-49c9-b593-d223f7449a82
Post type objects are reponsible for mapping their capabilities to core caps.
As a result, when the post type is no longer registered, the caps are no
longer mapped. This causes problems when a post is left in the database after
the post type is no longer present, and WP does an 'edit_post' or other cap
check against it: a PHP notice is thrown, and the cap check always fails.
As a more graceful fallback, we map all post-type-dependent caps onto
'edit_others_posts', which allows highly privileged users to be able to
access orphaned content (such as comments belonging to disabled post types),
while minimizing the possibility of unintended privilege escalation.
We also add a `_doing_it_wrong()` notice, so that developers and site
administrators are aware that the cap mapping is failing in the absence of
the registered post type.
Props mitchoyoshitaka, DrewAPicture, imath, codeelite, boonebgorges, nofearinc, SergeyBiryukov, jorbin, dlh.
Fixes#16956.
git-svn-id: https://develop.svn.wordpress.org/trunk@34091 602fd350-edb4-49c9-b593-d223f7449a82
Since [29248], a table join has not been necessary to process the
`$excluded_terms` parameter of `get_adjacent_post()`. Aside from adding extra
overhead, this join meant that post records that don't have any corresponding
rows in `wp_term_relationships` were erroneously excluded from results.
Fixes#32833.
git-svn-id: https://develop.svn.wordpress.org/trunk@34088 602fd350-edb4-49c9-b593-d223f7449a82
Setting the default value of the `queried_object_id` property to `0` meant
that, when called early enough in the WP bootstrap, `get_queried_object()`
could short-circuit the normal query by fooling it into thinking that the
request was for a page with id 0. Setting the default value to `null` instead
avoids this problem.
Props gradyetc, jazbek.
Fixes#31355.
git-svn-id: https://develop.svn.wordpress.org/trunk@34073 602fd350-edb4-49c9-b593-d223f7449a82
`wp_delete_user()` and `wpmu_delete_user()` both require an `$id` parameter.
Previously, the functions did not verify that the value passed was, in fact,
a number. As such, passing an object or any other entity that would be cast
to int `1` would result in user 1 being deleted. We fix this by enforcing
the requirement that `$id` be numeric.
Props dipesh.kakadiya, utkarshpatel, juliobox.
Fixes#33800.
git-svn-id: https://develop.svn.wordpress.org/trunk@34034 602fd350-edb4-49c9-b593-d223f7449a82
Other users in a network can now be given capabilities to manage users without also having global super admin privileges.
* Users with `manage_network_users` can not edit super admins.
* Users with `manage_network_users` can not promote users to super admin.
* Uses of `is_super_admin()` in `user-new.php` are now updated to `manage_network_users`.
Props daniellandau, chriscct7.
Fixes#16860.
git-svn-id: https://develop.svn.wordpress.org/trunk@33988 602fd350-edb4-49c9-b593-d223f7449a82
An administrator in multisite can not edit users other than itself.
Props daniellandau for the initial patch.
See #16860.
git-svn-id: https://develop.svn.wordpress.org/trunk@33987 602fd350-edb4-49c9-b593-d223f7449a82
This also includes a unit test to ensure we're only recommending actively supported versions of PHP in the future.
Fixes#33758.
git-svn-id: https://develop.svn.wordpress.org/trunk@33937 602fd350-edb4-49c9-b593-d223f7449a82
There are no uses of `wp_list_comments()` in Core where `$comments` are passed as the 2nd argument.
Adds unit tests.
Props wonderboymusic, bradt.
Fixes#16894.
git-svn-id: https://develop.svn.wordpress.org/trunk@33925 602fd350-edb4-49c9-b593-d223f7449a82
[29128] introduced updated documentation for the `'orderby'` parameter of
`get_terms()`. The new documentation mistakenly said that 'term_id' was a valid
orderby value. The current changeset makes that fantasy...A REALITY.
Props ixkaito.
Fixes#33726.
git-svn-id: https://develop.svn.wordpress.org/trunk@33903 602fd350-edb4-49c9-b593-d223f7449a82
Add unit tests - there were none. Mock `set_user_setting()` since it won't run due to `headers_sent()` being `true`.
Fixes#22781.
git-svn-id: https://develop.svn.wordpress.org/trunk@33840 602fd350-edb4-49c9-b593-d223f7449a82
Fixes a bug where `$new_theme` got set before the second argument was
appropriately handled, causing the `current_theme` option to later always be
updated to the parent theme's name.
Introduced in [21131].
Props obenland, wonderboymusic.
Fixes#32635.
git-svn-id: https://develop.svn.wordpress.org/trunk@33815 602fd350-edb4-49c9-b593-d223f7449a82
Add a bunch of unit tests to `tests/image/intermediate_size.php`.
Props joemcgill, ericlewis, kitchin, SergeyBiryukov, chipbennett.
Fixes#17626.
git-svn-id: https://develop.svn.wordpress.org/trunk@33807 602fd350-edb4-49c9-b593-d223f7449a82
* Cases for `0` and `1` should be `'1'` and `'0'`
* Add unit tests for `get_comment_count()`. Currently, there are none.
See #33414.
git-svn-id: https://develop.svn.wordpress.org/trunk@33806 602fd350-edb4-49c9-b593-d223f7449a82
This allows the 'current-cat' or 'current-cat-parent' classes to be applied
to more than one item in the list.
Props vilkatis.
Fixes#33565.
git-svn-id: https://develop.svn.wordpress.org/trunk@33804 602fd350-edb4-49c9-b593-d223f7449a82