Commit Graph

695 Commits

Author SHA1 Message Date
John Blackbourn
f545bb3f63 Docs: Improve documentation of known return types, plus other docs fixes.
See #48303

Built from https://develop.svn.wordpress.org/trunk@46660


git-svn-id: http://core.svn.wordpress.org/trunk@46460 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-05 21:23:02 +00:00
Sergey Biryukov
e199663322 I18N: Capitalize translator comments consistently, add trailing punctuation.
Includes minor code layout fixes.

See #44360.
Built from https://develop.svn.wordpress.org/trunk@45932


git-svn-id: http://core.svn.wordpress.org/trunk@45743 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-03 00:41:05 +00:00
Sergey Biryukov
16b8d91baa I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.

Includes minor code layout fixes.

Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!

Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926


git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 17:13:59 +00:00
Sergey Biryukov
7f7480cb2a Docs: Add missing description for $wp_query and $wp_the_query globals.
Props mukesh27.
See #45604, #47110.
Built from https://develop.svn.wordpress.org/trunk@45739


git-svn-id: http://core.svn.wordpress.org/trunk@45550 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-08-04 01:59:56 +00:00
Sergey Biryukov
8e85299a00 General: First pass at replacing Codex URLs with a corresponding HelpHub or DevHub article.
Props ianbelanger, tobifjellner, SergeyBiryukov.
See #47771.
Built from https://develop.svn.wordpress.org/trunk@45674


git-svn-id: http://core.svn.wordpress.org/trunk@45485 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-25 22:45:57 +00:00
Sergey Biryukov
7d74080b80 Privacy: Introduce Privacy Policy page helpers:
* `is_privacy_policy()` template tag
* `privacy-policy.php` template
* `.privacy-policy` body class
* `.menu-item-privacy-policy` menu item class

Props garrett-eclipse, birgire, xkon, Clorith.
Fixes #44005.
Built from https://develop.svn.wordpress.org/trunk@44966


git-svn-id: http://core.svn.wordpress.org/trunk@44797 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-03-21 19:48:50 +00:00
Boone Gorges
05fa2363ab Posts: Avoid the use of globals in get_the_content() and related functions.
This changeset introduces `$post` parameters to `get_the_content()` and
`wp_trim_excerpt()`. When a `$post` object is passed to one of these functions,
the functions will operate on the data from that object, rather than from the
post globals (`$authordata`, `$page`, etc). This ensures that the functions work
in a predictable manner when used outside of the regular post loop.

The global-mismatch problem is surfaced in cases where `get_the_excerpt()` is
called outside of the post loop, on posts that don't have a defined excerpt. In
these cases, the post globals - used to generate a fallback excerpt - may refer
to the incorrect object, resulting in PHP notices or other unpredictable
behavior. See #36934 for a related issue.

Props spacedmonkey, kraftbj, Shital Patel.
Fixes #42814.
Built from https://develop.svn.wordpress.org/trunk@44941


git-svn-id: http://core.svn.wordpress.org/trunk@44772 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-03-20 15:49:49 +00:00
Gary Pendergast
56c162fbc9 Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.


Built from https://develop.svn.wordpress.org/trunk@43571


git-svn-id: http://core.svn.wordpress.org/trunk@43400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-08-17 01:51:36 +00:00
Dominik Schilling
5c291d49de Pinking shears.
See #41057.
Built from https://develop.svn.wordpress.org/trunk@42843


git-svn-id: http://core.svn.wordpress.org/trunk@42673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-18 14:23:33 +00:00
Sergey Biryukov
c7c98dd7ea Docs: Correct $id parameter type for old_slug_redirect_post_id filter.
Props dlh.
Fixes #43375.
Built from https://develop.svn.wordpress.org/trunk@42722


git-svn-id: http://core.svn.wordpress.org/trunk@42552 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-21 09:35:33 +00:00
Drew Jaynes
6e665d1f15 Docs: Link to the "Conditional Tags" article in the Theme Developer Handbook from the descriptions for a variety of core conditional tag functions.
These notations largely serve to direct consumers (of both the source and the parsed code reference) to extended information on individual and related conditional tags throughout WordPress. The changeset also standardizes corresponding DocBlock summaries to use third-person singular verbs.

Notations been added for the following functions:

* comments_open()
* email exists()
* has_excerpt()
* has_post_thumbnail()
* has_tag()
* in_category()
* in_the_loop()
* is_404()
* is_active_sidebar()
* is_active_widget()
* is_admin()
* is_admin_bar_showing()
* is_archive()
* is_attachment()
* is_author()
* is_blog_installed()
* is_category()
* is_comments_popup()
* is_date()
* is_day()
* is_dynamic_sidebar()
* is_feed()
* is_front_page()
* is_home()
* is_local_attachment()
* is_main_query
* is_month()
* is_multi_author
* is_new_day()
* is_page()
* is_page_template()
* is_paged()
* is_plugin_active()
* is_plugin_active_for_network()
* is_plugin_inactive()
* is_plugin_page()
* is_post_type_archive()
* is_preview()
* is_rtl()
* is_search()
* is_single()
* is_singular()
* is_sticky()
* is_tag()
* is_tax()
* is_taxonomy_hierarchical()
* is_time()
* is_trackback()
* is_user_logged_in()
* is_year()
* pings_open()
* post_type_exists()
* taxonomy_exists()
* term_exists()
* username exists()
* wp_attachment_is_image()
* wp_script_is()

Props janalwin.
Fixes #43254.

Built from https://develop.svn.wordpress.org/trunk@42710


git-svn-id: http://core.svn.wordpress.org/trunk@42538 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-02-13 16:54:31 +00:00
Gary Pendergast
488df7c563 Docs: Correct some version numbers.
`wp_check_for_changed_dates()`, `_find_post_by_old_slug(), `_find_post_by_old_date()`, and the `old_slug_redirect_post_id` filter were intended to land in 4.9.2, but didn't quite make it. Instead, they'll be landing in 4.9.3.

See #15397.


Built from https://develop.svn.wordpress.org/trunk@42588


git-svn-id: http://core.svn.wordpress.org/trunk@42417 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-01-24 06:48:31 +00:00
Gary Pendergast
6da54f0d9b Canonical URLs: Redirect to the correct URL when the post date changes.
When a post slug is changed, we store a copy of the old slug, so that we can redirect visitors visiting the old URL to the new URL.

In the same way, this stores a copy of the old date, when the post date changes, so we can redirect visitors to the new URL.

Props nickmomrik.
Fixes #15397 for trunk.


Built from https://develop.svn.wordpress.org/trunk@42401


git-svn-id: http://core.svn.wordpress.org/trunk@42230 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-12-15 08:31:47 +00:00
Aaron Jorbin
e4e0aa27a5 Docs: Add description for is_day().
Props webdevmattcrom.
Fixes #42784.

Built from https://develop.svn.wordpress.org/trunk@42355


git-svn-id: http://core.svn.wordpress.org/trunk@42184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-12-03 20:42:47 +00:00
Gary Pendergast
aaf99e6913 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.


Built from https://develop.svn.wordpress.org/trunk@42343


git-svn-id: http://core.svn.wordpress.org/trunk@42172 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-30 23:11:00 +00:00
Drew Jaynes
8c7f5367c0 Docs: Remove some more top-level @aacess tags from function DocBlocks.
See #414532.

Built from https://develop.svn.wordpress.org/trunk@41168


git-svn-id: http://core.svn.wordpress.org/trunk@41008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-27 08:19:43 +00:00
Sergey Biryukov
564d6a0c90 Docs: Update the description of is_singular() and WP_Query::is_singular() to be parsed correctly by developer.wordpress.org.
Props grapplerulrich.
Fixes #39948.
Built from https://develop.svn.wordpress.org/trunk@40103


git-svn-id: http://core.svn.wordpress.org/trunk@40040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-02-23 10:30:43 +00:00
Scott Taylor
153ba4a832 Query: in wp_old_slug_redirect(), use get_query_var() instead of importing and touching the global $wp_query directly.
See #37699.

Built from https://develop.svn.wordpress.org/trunk@38463


git-svn-id: http://core.svn.wordpress.org/trunk@38404 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-31 06:21:41 +00:00
Scott Taylor
d5f28fdad8 Query: move WP_Query into its own file via svn cp.
See #37827.

Built from https://develop.svn.wordpress.org/trunk@38351


git-svn-id: http://core.svn.wordpress.org/trunk@38292 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-25 17:20:38 +00:00
Boone Gorges
d30a6a988a Query: Non-scalar and negative values for 'p' should always result in a 404.
Previously, the 'p' query var was being run through `absint()`, which
caused unexpected results.

Props Akeif, kouratoras.
Fixes #33372.
Built from https://develop.svn.wordpress.org/trunk@38288


git-svn-id: http://core.svn.wordpress.org/trunk@38229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-20 02:32:30 +00:00
Scott Taylor
9b393cea42 Query: use composition for $db in WP_Query, removes need to import global $wpdb in multiple methods.
See #37699.

Built from https://develop.svn.wordpress.org/trunk@38279


git-svn-id: http://core.svn.wordpress.org/trunk@38220 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-18 19:39:29 +00:00
Drew Jaynes
e6267dcf19 Docs: Fix formatting, tense, verb conjugation, and other syntax for wp-includes/* elements introduced or changed in 4.6.
Part 2/2.

Fixes #37318.

Built from https://develop.svn.wordpress.org/trunk@38125


git-svn-id: http://core.svn.wordpress.org/trunk@38066 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-20 19:33:30 +00:00
Sergey Biryukov
139387b7e5 Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core.
Props metodiew.
Fixes #36495.
Built from https://develop.svn.wordpress.org/trunk@37985


git-svn-id: http://core.svn.wordpress.org/trunk@37926 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-06 12:40:29 +00:00
Drew Jaynes
21ef286eef Docs: Further improve the note of caution within the DocBlock description for query_posts().
See #32246.

Built from https://develop.svn.wordpress.org/trunk@37878


git-svn-id: http://core.svn.wordpress.org/trunk@37819 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-26 18:06:27 +00:00
Drew Jaynes
872f1c5d38 Docs: Add a note to the DocBlock for query_posts() to caution against general usage, including a pointer to the pre_get_posts action.
Also adds missing parameter and return descriptions.

See #32246.

Built from https://develop.svn.wordpress.org/trunk@37877


git-svn-id: http://core.svn.wordpress.org/trunk@37818 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-26 17:47:28 +00:00
Jeremy Felt
6f3f00ea97 Multisite: Change WP_Network id property to an integer.
For consistency and developer sanity.

Props flixos90.
Fixes #37050.

Built from https://develop.svn.wordpress.org/trunk@37870


git-svn-id: http://core.svn.wordpress.org/trunk@37811 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-26 14:26:29 +00:00
Boone Gorges
8603aa402a Query: set_found_posts() must run immediately after main query.
If not run immediately after, the `SELECT FOUND_ROWS()` query might refer to
a different query, such as the one used to populate the post cache for a split
query.

Introduced in [37692].

Fixes #36687.
Built from https://develop.svn.wordpress.org/trunk@37721


git-svn-id: http://core.svn.wordpress.org/trunk@37687 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-16 02:01:29 +00:00
Boone Gorges
bd2fafae0a Query: After [37692], don't skip set_found_posts() when no posts are found.
The 'found_posts' filter must continue to run for plugins manipulating post
results via filter.

Props dd32.
Fixes #36687.
Built from https://develop.svn.wordpress.org/trunk@37712


git-svn-id: http://core.svn.wordpress.org/trunk@37678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-15 12:33:29 +00:00
Boone Gorges
486961626c Query: Allow plugins to supply post results instead of having WP_Query fetch them from the database.
Returning a non-null value from the new `posts_pre_query` filter will cause
`WP_Query` to skip its database query, so that posts data can be provided from
elsewhere. This is useful in cases where post data may be mirrored in a
separate location, such as an external search application.

Developers should note that the `WP_Query` properties generally used to
calculate pagination - specifically, `found_posts` and `max_num_pages`, which
are determined by default in `set_found_posts()` - must be provided explicitly
when using the `posts_pre_query` filter; since `WP_Query` will not be
contacting the database, it will have no access to `SELECT FOUND_ROWS()`.
The `WP_Query` instance is passed to `posts_pre_query` by reference, so that
these properties can be set manually if needed.

Props jpdavoutian, tlovett1.
Fixes #36687.
Built from https://develop.svn.wordpress.org/trunk@37692


git-svn-id: http://core.svn.wordpress.org/trunk@37658 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-14 02:00:29 +00:00
Boone Gorges
7a9ed544e8 Allow term meta lazy-loading to be selectively disabled in WP_Query.
The process of lazy-loading can be resource intensive for object that have
terms in large numbers of taxonomies and are running a persistent object cache.
This new parameter allows the feature to be disabled in these cases.

Props DBrumbaugh10Up.
See #36953.
Built from https://develop.svn.wordpress.org/trunk@37589


git-svn-id: http://core.svn.wordpress.org/trunk@37557 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-28 03:10:29 +00:00
Drew Jaynes
9193013158 Docs: Apply inline @see tags to hooks referenced in DocBlocks in a variety of wp-includes/* files.
Applying these specially-crafted `@see` tags allows the Code Reference parser to recognize and link these elements as actions and filters.

Fixes #36921.

Built from https://develop.svn.wordpress.org/trunk@37544


git-svn-id: http://core.svn.wordpress.org/trunk@37512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-23 19:02:28 +00:00
Drew Jaynes
5ac8c4158c Docs: Standardize filter docs in wp-includes/query.php to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

Built from https://develop.svn.wordpress.org/trunk@37509


git-svn-id: http://core.svn.wordpress.org/trunk@37477 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:35:54 +00:00
Drew Jaynes
f52a8cb1fa Docs: Remove/replace invalid inline @link tags in DocBlocks in wp-includes/*.
Fixes #36910.

Built from https://develop.svn.wordpress.org/trunk@37487


git-svn-id: http://core.svn.wordpress.org/trunk@37455 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 17:39:28 +00:00
Drew Jaynes
b1804afeaf Docs: Standardize on 'backward compatibility/compatible' nomenclature in core inline docs.
Also use 'back-compat' in some inline comments where backward compatibility is the subject and shorthand feels more natural.

Note: 'backwards compatibility/compatibile' can also be considered correct, though it's primary seen in regular use in British English.

Props ocean90.
Fixes #36835.

Built from https://develop.svn.wordpress.org/trunk@37431


git-svn-id: http://core.svn.wordpress.org/trunk@37397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-13 18:41:31 +00:00
Drew Jaynes
fe3b007fdd Docs: Remove inline @see tags from function, class, and method references in inline docs.
Known functions, classes, and methods are now auto-linked in Code Reference pages following #meta1483.

Note: Hook references are still linked via inline `@see` tags due to the unlikelihood of reliably matching for known hooks based on a RegEx pattern.

See #32246.

Built from https://develop.svn.wordpress.org/trunk@37342


git-svn-id: http://core.svn.wordpress.org/trunk@37308 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-02 04:00:28 +00:00
Boone Gorges
9bf510260f Query: Discard non-scalar 'm' instead of attempting to sanitize.
`WP_Query` discards most non-array date values ('year', 'monthnum', etc) by
casting to integer. Since [25138], the 'm' parameter has been handled
as a string; see #24884. However, the string-handling introduced in [25138]
blindly attempted to handle arrays and other non-scalar types as strings,
resulting in PHP notices and invalid MySQL syntax.

Props vortfu.
Fixes #36718.
Built from https://develop.svn.wordpress.org/trunk@37324


git-svn-id: http://core.svn.wordpress.org/trunk@37290 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-04-29 13:15:30 +00:00
Sergey Biryukov
cf12011934 Docs: Move the clarification of is_tax() and WP_Query::is_tax() return value added in [37235] to @return description.
Props DrewAPicture.
Fixes #36331.
Built from https://develop.svn.wordpress.org/trunk@37281


git-svn-id: http://core.svn.wordpress.org/trunk@37247 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-04-21 17:47:28 +00:00
Sergey Biryukov
2032e527b3 Docs: Clarify that is_tax() and WP_Query::is_tax() return false for built-in taxonomies (category and tag archives).
Props theMikeD.
Fixes #36331.
Built from https://develop.svn.wordpress.org/trunk@37235


git-svn-id: http://core.svn.wordpress.org/trunk@37201 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-04-18 01:44:26 +00:00
Boone Gorges
54cf1d2c3d Query: Allow results to be ordered by post_parent__in.
Props postpostmodern.
Fixes #36515.
Built from https://develop.svn.wordpress.org/trunk@37225


git-svn-id: http://core.svn.wordpress.org/trunk@37191 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-04-17 03:17:27 +00:00
Sergey Biryukov
4a5dea0d62 Canonical / Query: Restore the is_404() check in wp_old_slug_redirect() which was removed in [34659].
This reverts part of [34659] due to excessive canonical problems it's caused in 4.4.x.

Remove the unit tests which are no longer supported.
This also removes the `is_feed()` code to avoid confusion - only pages & embeds will be redirected.

Merges [36280] and [36281] to trunk.

Props dd32.
See #21602, #35344.
Built from https://develop.svn.wordpress.org/trunk@37075


git-svn-id: http://core.svn.wordpress.org/trunk@37042 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-23 21:54:26 +00:00
Boone Gorges
036e63c31a Query: Ignore search terms consisting of a single dash.
Due to the "exclude" support added in WP 4.4, single dashes were being
converted to "NOT LIKE '%%'" clauses, causing all searches to fail.

Props RomSocial, swissspidy.
Fixes #36195.
Built from https://develop.svn.wordpress.org/trunk@36989


git-svn-id: http://core.svn.wordpress.org/trunk@36956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-14 14:12:25 +00:00
Aaron Jorbin
5ec9a2aeb4 Revert r36696
This broke embeds. Needs a better solution to also make sure all queries from the REST API aren't broken.

see #35907.



Built from https://develop.svn.wordpress.org/trunk@36699


git-svn-id: http://core.svn.wordpress.org/trunk@36666 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-24 22:12:25 +00:00
Aaron Jorbin
ae9e63805d Permit sticky posts to affect the query in REST_REQUEST
Needed for https://github.com/WP-API/WP-API/issues/2210

Props danielbachhuber.
Fixes #35907.


Built from https://develop.svn.wordpress.org/trunk@36696


git-svn-id: http://core.svn.wordpress.org/trunk@36663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-24 21:44:26 +00:00
Boone Gorges
6d8a3f3612 Query: Search should match post_excerpt in addition to title and content.
When ordering search results, exact matches in the post excerpt are weighted
above those in post content, but below those in the post title.

Props swissspidy, sebastian.pisula.
FIxes #35762.
Built from https://develop.svn.wordpress.org/trunk@36647


git-svn-id: http://core.svn.wordpress.org/trunk@36614 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-23 20:14:26 +00:00
Boone Gorges
ba5cc4e776 Query: Allow a seed value to be passed when using 'rand' $orderby.
`WP_Query` allows random ordering; `'orderby' => 'rand'` translates to
`ORDER BY RAND()`. This syntax results in random ordering that is not
consistent from request to request. MySQL supports the passing of a seed value
to random sorts, such as `ORDER BY RAND(3)`, which will return the same
random value each time it's called. `WP_Query` now supports this syntax, by
passing `RAND(3)` (or whatever integer seed value you'd like) as the value
of `'orderby'`.

Props hlashbrooke.
Fixes #35692.
Built from https://develop.svn.wordpress.org/trunk@36632


git-svn-id: http://core.svn.wordpress.org/trunk@36599 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-23 16:40:26 +00:00
Boone Gorges
072c791df0 Query: is_*( $int ) should not falsely match strings starting with "$int".
Another chapter in the Storied Annals of Weird `in_array()` Behavior:
`in_array( 4, array( "4-cool-dudes" ) );` resolves to `true`, such that
`is_page( 4 )` was returning true for posts with the name `'4-cool-dudes'`.

We work around this behavior by ensuring that values passed to the `is_`
methods are cast to strings before the `in_array()` checks. ID checks still
work as expected; see #24674.

Props mikejolley, swissspidy, boonebgorges.
Fixes #35902.
Built from https://develop.svn.wordpress.org/trunk@36625


git-svn-id: http://core.svn.wordpress.org/trunk@36592 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-23 02:21:25 +00:00
Boone Gorges
571e14f897 More performance improvements to metadata lazyloading.
Comment and term meta lazyloading for `WP_Query` loops, introduced in 4.4,
depended on filter callback methods belonging to `WP_Query` objects. This meant
storing `WP_Query` objects in the `$wp_filter` global (via `add_filter()`),
requiring that PHP retain the objects in memory, even when the local variables
would typically be expunged during normal garbage collection. In cases where a
large number of `WP_Query` objects were instantiated on a single pageload,
and/or where the contents of the `WP_Query` objects were quite large, serious
performance issues could result.

We skirt this problem by moving metadata lazyloading out of `WP_Query`. The
new `WP_Metadata_Lazyloader` class acts as a lazyload queue. Query instances
register items whose metadata should be lazyloaded - such as post terms, or
comments - and a `WP_Metadata_Lazyloader` method will intercept comment and
term meta requests to perform the cache priming. Since `WP_Metadata_Lazyloader`
instances are far smaller than `WP_Query` (containing only object IDs), and
clean up after themselves far better than the previous `WP_Query` methods (bp
only running their callbacks a single time for a given set of queued objects),
the resource use is decreased dramatically.

See [36525] for an earlier step in this direction.

Props lpawlik, stevegrunwell, boonebgorges.
Fixes #35816.
Built from https://develop.svn.wordpress.org/trunk@36566


git-svn-id: http://core.svn.wordpress.org/trunk@36533 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-17 22:58:26 +00:00
Boone Gorges
60cf073672 Improve WP_Query lazyloading logic, for better performance.
Lazyloading for comment meta and term meta, introduced into `WP_Query` in
4.4, used flags - `updated_term_meta_cache` and `updated_comment_meta_cache` -
in an attempt to prevent cache priming from happening more than once per query
object. This technique was mostly effective, but not entirely efficient, since
the flag didn't prevent the `lazyload_*_meta` callbacks from running. The
obvious solution - removing the filter callback after it'd be run once - was
dismissed for 4.4 because of concerns that `remove_filter()` could disable
lazyloading too generally in the context of nested queries, due to the way
`_wp_filter_build_unique_id()` doesn't always build sufficiently unique IDs for
similar objects. However, further testing shows that this concern is only valid
in a very small subset of cases, while the cost of keeping the query objects in
memory, via the `$wp_filter` global, is quite significant. As such, this
changeset removes the flags in favor of the `remove_filter()` technique.

See #35454, #35816.
Built from https://develop.svn.wordpress.org/trunk@36524


git-svn-id: http://core.svn.wordpress.org/trunk@36491 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-13 03:05:27 +00:00
Boone Gorges
f1c0ed714a WP_Query taxonomy query vars should be set to first of multiple taxonomies.
This provides better parity with `get_queried_object()`, which will return the
first taxonomy/term matched by the current query.

[29891] introduced the abnormal behavior for the 'taxonomy' and 'term'
query vars.

Props Chouby.
Fixes #35619.
Built from https://develop.svn.wordpress.org/trunk@36484


git-svn-id: http://core.svn.wordpress.org/trunk@36451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-06 03:58:27 +00:00
Boone Gorges
e6d2b6cab0 Query: Respect 'suppress_filters' when filtering search-related SQL.
Props 5um17.
Fixes #35594.
Built from https://develop.svn.wordpress.org/trunk@36404


git-svn-id: http://core.svn.wordpress.org/trunk@36371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-26 03:12:25 +00:00