Commit Graph

79 Commits

Author SHA1 Message Date
whyisjake 9f86174e08 Comments: Ensure that unmoderated comments won't be search indexed.
After a comment is submitted, only allow a brief window where the comment is live on the site. 

Fixes #49956.
Props: jonkolbert, ayeshrajans, Asif2BD, peterwilsoncc, imath, audrasjb, jonoaldersonwp, whyisjake.

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


git-svn-id: http://core.svn.wordpress.org/trunk@47661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-02 20:12:07 +00:00
Sergey Biryukov 7932193708 Coding Standards: Use strict comparison where static strings are involved.
This reduces the number of `WordPress.PHP.StrictComparisons.LooseComparison` issues in half, from 1897 to 890.

Includes minor code layout fixes for better readability.

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47808


git-svn-id: http://core.svn.wordpress.org/trunk@47584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-05-16 18:42:12 +00:00
Sergey Biryukov 6b5087812c Comments: Restore inclusion of an empty comment type when building the `WHERE` clause in `WP_Comment_Query::get_comment_ids()`.
This ensures that `get_comments( array( 'type' => 'comment' ) )` still includes comments that have not yet migrated to the `comment` type.

Follow-up to [47597].

Props ocean90.
See #49236.
Built from https://develop.svn.wordpress.org/trunk@47625


git-svn-id: http://core.svn.wordpress.org/trunk@47400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-04-26 13:14:06 +00:00
Sergey Biryukov 61a2f62ffd Comments: Use `comment` instead of an empty string for the `comment_type` DB field value in comments table.
This is the first step to bring support for custom comment types into WordPress.

Add a scheduled upgrade routine to update the type value for existing comments, in batches of 100 at a time.

Props imath, aaroncampbell, jeremyfelt, dshanske.
Fixes #49236.
Built from https://develop.svn.wordpress.org/trunk@47597


git-svn-id: http://core.svn.wordpress.org/trunk@47372 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-04-17 19:35:06 +00:00
Sergey Biryukov 38676936ba Coding Standards: Use strict type check for `in_array()` and `array_search()` where strings are involved.
This reduces the number of `WordPress.PHP.StrictInArray.MissingTrueStrict` issues from 486 to 50.

Includes minor code layout fixes for better readability.

See #49542.
Built from https://develop.svn.wordpress.org/trunk@47550


git-svn-id: http://core.svn.wordpress.org/trunk@47325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-04-05 03:02:11 +00:00
Sergey Biryukov 641c632b0c Coding Standards: Use Yoda conditions where appropriate.
See #49222.
Built from https://develop.svn.wordpress.org/trunk@47219


git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-02-09 16:55:09 +00:00
Sergey Biryukov 001ffe81fb Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47122


git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-29 00:45:18 +00:00
Sergey Biryukov e6bbff13c5 Code Modernisation: Replace `call_user_func_array()` in various `__call()` methods with dynamic function calls.
The callback in these functions is always checked against a limited list of valid callbacks that can be safely changed to dynamic function calls.

Props jrf.
See #47678.
Built from https://develop.svn.wordpress.org/trunk@46144


git-svn-id: http://core.svn.wordpress.org/trunk@45956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-15 11:53:56 +00:00
Sergey Biryukov c9071ca2e6 Docs: Clarify the `int` return value in `comments_pre_query` filter DocBlock.
See #45800.
Built from https://develop.svn.wordpress.org/trunk@46087


git-svn-id: http://core.svn.wordpress.org/trunk@45899 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-10 19:04:56 +00:00
Adam Silverstein b3e64f0947 Comments: add a new `comments_pre_query` filter to short circuit WP_Comment_Query 'get_comments' queries.
Return a non-null value to bypass WordPress's default comment queries.

Props felipeelia, spacedmonkey.
Fixes #45800.


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


git-svn-id: http://core.svn.wordpress.org/trunk@45898 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-10 18:42:56 +00:00
Gary Pendergast 14c7533162 Coding Standards: Fix all `WordPress.DB.PreparedSQLPlaceholders` issues.
See #47632.


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


git-svn-id: http://core.svn.wordpress.org/trunk@45414 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-05 05:43:55 +00:00
Gary Pendergast 4803fc405e Coding Standards: Fix the `Squiz.PHP.DisallowMultipleAssignments` violations in `wp-includes`.
See #47632.


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


git-svn-id: http://core.svn.wordpress.org/trunk@45401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-07-02 23:42:58 +00:00
Gary Pendergast 8656a65e1e Coding Standards: Fix and whitelist variable names.
From the `WordPress.NamingConventions.ValidVariableName` sniff, this commit fixes/whitelists all `NotSnakeCaseMemberVar`, `MemberNotSnakeCase`, and `StringNotSnakeCase` violations. It also fixes a handful of the `NotSnakeCase` violations.

See #45934.


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


git-svn-id: http://core.svn.wordpress.org/trunk@44404 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-12 06:06:48 +00:00
Felix Arntz a71d208785 General: Fix problematic string to array parsing.
WordPress has historically often used code like `preg_split( '/[\s,]+/', $var )` to parse a string of comma-separated values into an array. However, this approach was causing an empty string to not be parsed into an empty array as expected, but rather into an array with the empty string as its sole element.

This was among other areas causing problems in the REST API where passing an empty request parameter could cause that request to fail because, instead of it being ignored, that parameter would be compared against the valid values for it, which typically do not include an empty string.

Props david.binda, sstoqnov.
Fixes #43977.

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


git-svn-id: http://core.svn.wordpress.org/trunk@44377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-10 21:06:49 +00:00
Sergey Biryukov 9c08686353 Docs: Fix typo in the description of `status` parameter of `WP_Comment_Query`.
See #41338.
Built from https://develop.svn.wordpress.org/trunk@44412


git-svn-id: http://core.svn.wordpress.org/trunk@44242 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-01-07 11:38:50 +00:00
desrosj 268402cf53 PHP7.3 compatibility: Fix compact throwing notices.
In PHP 7.3, the `compact()` function has been changed to issue an `E_NOTICE` level error if a passed string refers to an unset variable. In previous versions of PHP, this notice was silently skipped. The full RFC can be viewed here: https://wiki.php.net/rfc/compact.

Props jorbin, desrosj.

Merges [43819] and [43832] to trunk.

Fixes #44416.
Built from https://develop.svn.wordpress.org/trunk@44166


git-svn-id: http://core.svn.wordpress.org/trunk@43996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-14 05:13:52 +00:00
John Blackbourn b13e73d05c Docs: Document more parameters and properties using typed array notation.
See #41756

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


git-svn-id: http://core.svn.wordpress.org/trunk@42705 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-03-25 18:10:32 +00:00
Sergey Biryukov 0354c3e2f1 Docs: Add missing `@return` entry for `WP_Comment_Query::get_comment_ids()`.
Props chetan200891, birgire.
Fixes #42795.
Built from https://develop.svn.wordpress.org/trunk@42376


git-svn-id: http://core.svn.wordpress.org/trunk@42205 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-12-07 13:47:52 +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
Boone Gorges 2f95f44008 Correct documentation for `status` param of `WP_Comment_Query`.
The `status` parameter accepts an array or string/comma-separated list.

Introduced in [30084].

Props pbiron.
Fixes #41338.
Built from https://develop.svn.wordpress.org/trunk@42165


git-svn-id: http://core.svn.wordpress.org/trunk@41996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-13 16:26:47 +00:00
John Blackbourn 67c973f95e Docs: Correct parameter type documentation for various `__call()` methods.
See #42505

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


git-svn-id: http://core.svn.wordpress.org/trunk@41982 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-11-10 22:56:47 +00:00
John Blackbourn 9fdbe6538e Docs: Remove `&` prefixes from parameter documentation to avoid doc parsing errors.
Props sudar for the original patch.

See #35974

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


git-svn-id: http://core.svn.wordpress.org/trunk@41520 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-02 22:03:33 +00:00
Boone Gorges c080c0a2ea Introduce `paged` argument to `WP_Comment_Query`.
Using `paged` with `number` allows developers to request
paginated comment results without having to do a manual offset
calculation.

Props AdamWills.
Fixes #38268.
Built from https://develop.svn.wordpress.org/trunk@41287


git-svn-id: http://core.svn.wordpress.org/trunk@41127 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-21 15:35:46 +00:00
John Blackbourn d510413811 Docs: Fix various filter documentation.
See #38462, #41017

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


git-svn-id: http://core.svn.wordpress.org/trunk@41055 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-08-03 14:34:44 +00:00
Boone Gorges c657a2c060 Comments: Ignore the 'fields' parameter in the comment query cache.
`WP_Comment_Query` always queries runs an ID query, and so is unaffected
by the 'fields' parameter. As such, 'fields' can be ignored when building
a cache key for the results of the ID query.

Props spacedmonkey.
Fixes #41348.
Built from https://develop.svn.wordpress.org/trunk@41190


git-svn-id: http://core.svn.wordpress.org/trunk@41030 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-30 14:56:41 +00:00
Drew Jaynes 0860bb2771 Docs: Remove `@access` notations from method DocBlocks in wp-includes/* classes.
Prior to about 2013, many class methods lacked even access modifiers which made the `@access` notations that much more useful. Now that we've gotten to a point where the codebase is more mature from a maintenance perspective and we can finally remove these notations. Notable exceptions to this change include standalone functions notated as private as well as some classes still considered to represent "private" APIs.

See #41452.

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


git-svn-id: http://core.svn.wordpress.org/trunk@41002 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-27 00:41:44 +00:00
Sergey Biryukov 0a24e8d1cd Docs: Add `@access` entry for `WP_Comment_Query::fill_descendants()`.
Props umangvaghela123.
Fixes #41435.
Built from https://develop.svn.wordpress.org/trunk@41145


git-svn-id: http://core.svn.wordpress.org/trunk@40985 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-25 12:54:45 +00:00
Sergey Biryukov 00b91b3003 Docs: Add a `@global` entry for `$wpdb` in `WP_Comment_Query::fill_descendants()`.
Props jontyravi.
Fixes #41412.
Built from https://develop.svn.wordpress.org/trunk@41123


git-svn-id: http://core.svn.wordpress.org/trunk@40963 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-07-23 10:40:45 +00:00
Boone Gorges f882fc1295 Comments: Clean up unused code after [38446].
When the direct SQL query was removed in [38446], part of the SQL
concatenation was not removed. This changeset fixes that.

Props david.binda.
Fixes #39142.
Built from https://develop.svn.wordpress.org/trunk@39532


git-svn-id: http://core.svn.wordpress.org/trunk@39472 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-12-07 15:52:44 +00:00
Boone Gorges bd11f7b84a Comments: Query used to fill comment descendants should reset 'offset' and 'number' params.
Descendant queries should not inherit the 'offset' and 'number'
parameters of the parent query, or descendants will be missed.

Previously: [38497].

See #37696.
Built from https://develop.svn.wordpress.org/trunk@39274


git-svn-id: http://core.svn.wordpress.org/trunk@39214 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-17 03:03:30 +00:00
Aaron Jorbin 82911b1756 Cache API: introduce wp_cache_get_last_changed to improve DRY
One thing fairly common to the cache groups is a block of code to look to see when the cache was last changed, and if there isn't one, to set it for the current microtime(). It appears in 8 different places in core. This adds a new helper `wp_cache_get_last_changed` to DRY things up a bit.

Since `wp-includes/cache.php` isn't guaranteed to be loaded, this new function is in `wp-includes/functions.php`

Props spacedmonkey, desrosj.
Fixes #37464.


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


git-svn-id: http://core.svn.wordpress.org/trunk@38792 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-21 02:54:34 +00:00
Gary Pendergast af69f4ab1a General: Restore usage of `$wpdb`, instead of `$this->db`.
Hiding the `$wpdb` global behind a property decreases the readability of the code, as well as causing irrelevant output when dumping an object.

Reverts [38275], [38278], [38279], [38280], [38387].
See #37699.


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


git-svn-id: http://core.svn.wordpress.org/trunk@38711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-10 06:38:31 +00:00
Dominik Schilling 1babe4b968 Comments: Revert [38298].
Instead use the correct comparison operator which was changed in [38297].

Fixes #37416.
Built from https://develop.svn.wordpress.org/trunk@38639


git-svn-id: http://core.svn.wordpress.org/trunk@38582 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-09-21 17:38:28 +00:00
Boone Gorges 3a4169d7ab Comments: Don't do direct SQL query when fetching decendants.
The SQL query was built using the clauses compiled when querying for
top-level comments. But in cases where the top-level comment query
results are already in the cache, the SQL clauses are not built, and
so are unavailable for `fill_descendants()`. Instead, we call
`get_comments()`, using modified versions of the parameters passed
to the main `WP_Comment_Query` class.

Props Akeif, Rarst for testing.
Fixes #37696.
Built from https://develop.svn.wordpress.org/trunk@38446


git-svn-id: http://core.svn.wordpress.org/trunk@38387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 14:48:29 +00:00
Scott Taylor af1fb6b8d2 Query: use correct description in the docblock for `$number` in `WP_Comment_Query`, `WP_Network_Query`, and `WP_Site_Query`.
Props flixos90.
Fixes #37621.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-23 14:41:29 +00:00
Scott Taylor 4bdd4edb77 Comments: in `WP_Comment_Query::fill_descendants()`, `continue` if there is an empty array in the loop.
See #37416, [38297].

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


git-svn-id: http://core.svn.wordpress.org/trunk@38239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-21 06:43:29 +00:00
Scott Taylor f02f4ac762 Comments: in `WP_Comment_Query::fill_descendants()`, compute `count()` in the first `for` expression so that it does not run on each iteration.
Props vishalkakadiya, deremohan.
Fixes #37416.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38238 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-21 06:25:29 +00:00
Scott Taylor e7ffad7fac Query: add a `protected` field, `$db`, (composition, as it were) to `WP_*_Query` classes to hold the value for the database abstraction, instead of importing the `global $wpdb` into every method that uses it. Reduces the number of global imports by 32.
See #37699.

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


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

See #37318.

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


git-svn-id: http://core.svn.wordpress.org/trunk@38062 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-20 16:57:32 +00:00
Sergey Biryukov c50056a1f2 Comments: Introduce the `cache_domain` argument for `WP_Comment_Query` to allow caching to a unique set of cache buckets.
See [18128] for `get_terms()` and [37572] for `WP_Term_Query`.

Props Chouby, rachelbaker.
Fixes #37419.
Built from https://develop.svn.wordpress.org/trunk@38117


git-svn-id: http://core.svn.wordpress.org/trunk@38058 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-20 15:07:30 +00:00
Boone Gorges c6d5f78241 Comments: Cache results of `SELECT FOUND_ROWS()` query.
When comment IDs are fetched from the cache rather than the database,
the subsequent `SELECT FOUND_ROWS()` query will not return the correct value.
To avoid unnecessary queries, we cache the results of the `found_comments`
query alongside the comment IDs.

Props spacedmonkey.
Fixes #37184.
Built from https://develop.svn.wordpress.org/trunk@38001


git-svn-id: http://core.svn.wordpress.org/trunk@37942 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-07 14:27:38 +00:00
Sergey Biryukov bf2bea4987 Comments: Remove the assignment of an undocumented `$comment_count` property in `WP_Comment_Query::get_comments()`, which appears to be accidentally introduced in [34544].
Props flixos90.
Fixes #37187.
Built from https://develop.svn.wordpress.org/trunk@37873


git-svn-id: http://core.svn.wordpress.org/trunk@37814 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-26 14:28:28 +00:00
Boone Gorges e202610ac8 Comments: Improve caching for hierarchical queries.
Hierarchical comment queries work by first fetching the IDs of top-level
comments, and then filling the descendant tree one level at a time based on the
top-level results. When top-level comment IDs are found in the cache,
`WP_Comment_Query` does not generate the SQL used to fetch these comments. In
this case, the `fill_descendants()` query does not have enough information
to fill children. As a result, descendant comments were failing to be filled
in cases where the top-level comments were found in the cache.

This was a minor bug previously, because comment caches were not maintained
between pageloads. Since comment caches are now persistent [37613], the problem
becomes evident anywhere that a persistent object cache is in use.

The solution is to cache parent-child relationships, so that when top-level
comments are found in the cache, descendant comments should be found there as
well.

Fixes #36487.
Built from https://develop.svn.wordpress.org/trunk@37625


git-svn-id: http://core.svn.wordpress.org/trunk@37593 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-02 18:28:27 +00:00
Drew Jaynes fb6d8bae49 Docs: Apply inline `@see` tags to hooks referenced in DocBlocks for core classes.
Applying these specially-crafted `@see` tags allows the Code Reference parser to recognize and link these elements as actions and filters.

See #36921.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37507 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-23 18:54:27 +00:00
Drew Jaynes 602b51a209 Docs: Standardize filter docs in core classes in wp-includes/* to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37460 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:15:28 +00:00
Boone Gorges e79d2a1bad Improve `@return` documentation for `WP_Comment_Query::get_comments()`.
Props barryceelen.
Fixes #36896.
Built from https://develop.svn.wordpress.org/trunk@37482


git-svn-id: http://core.svn.wordpress.org/trunk@37450 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 16:21:27 +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 c7a2b7683b Docs: Add a missing hook doc for the `parse_comment_query` hook, added in [31793].
Props flixos90.
See #24826. Fixes #36740.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37321 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-03 16:22:27 +00:00
Boone Gorges 2f66998e3f `date_query` should be a property on `WP_Comment_Query` objects.
Instead of a local variable.

Props flixos90.
Fixes #36741.
Built from https://develop.svn.wordpress.org/trunk@37354


git-svn-id: http://core.svn.wordpress.org/trunk@37320 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-03 16:15:29 +00:00
Drew Jaynes 4a171993ed Docs: Standardize the changelog entry for the new `$author_url` argument, introduced in [36224].
See #35377. See #35986.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36801 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-03 16:02:27 +00:00