Commit Graph

385 Commits

Author SHA1 Message Date
Rachel Baker
f407e3a473 Comments: Use TEXT column type in fallback for wp_get_comment_column_max_length().
Fixes #10377.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36292 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-15 20:10:27 +00:00
Pascal Birchler
19d4304565 Comments: Add a new pre_wp_update_comment_count_now filter.
This allows filtering a post's comment count before it is queried and updated in the database.

Props peterwilsoncc for initial patch.
Fixes #35060.
Built from https://develop.svn.wordpress.org/trunk@36318


git-svn-id: http://core.svn.wordpress.org/trunk@36285 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-15 13:42:26 +00:00
Rachel Baker
87e7b4455d Comments: Restrict the maximum characters for input fields within the comments template.
Added hardcoded maxlength attributes on the author, author_email, author_url, and comment_field input markup. These can be modified via the comment_form_defaults filter. Added logic in wp_handle_comment_submission() to return a WP_Error when the comment_author, comment_author_url, or comment_content values exceed the max length of their columns. Introduces wp_get_comment_column_max_length() which returns the max column length for a given column name, and is filterable. Unit tests included for the error conditions in wp_handle_comment_submission()

Fixes #10377.

Props westonruter rachelbaker.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-13 01:25:26 +00:00
Boone Gorges
74f83e1016 Allow comment agent and author IP to be set via wp_update_comment().
Props adamsilverstein, welcher.
Fixes #35276.
Built from https://develop.svn.wordpress.org/trunk@36215


git-svn-id: http://core.svn.wordpress.org/trunk@36182 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-07 03:55:28 +00:00
Rachel Baker
2bdc6a5fd0 Docs: Add null to post_id param type, fix syntax, and descriptions in the DocBlock for wp_update_comment_count().
See #32246.


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


git-svn-id: http://core.svn.wordpress.org/trunk@36105 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-31 19:21:28 +00:00
Aaron Jorbin
09688bd59c Ensure only approved comments trigger post author notifications
Posts that are trashed shouldn't trigger post author notifications.  Adds unit tests to enforce this.

Props scottbrownconsulting, peterwilsoncc, swissspidy
Fixes #35006


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


git-svn-id: http://core.svn.wordpress.org/trunk@36085 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-29 17:54:28 +00:00
Rachel Baker
a828b700fc Comments: Return early from wp_update_comment_count() if there is not a valid post.
Props ambrosey, juanfra. 
Fixes #34977


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


git-svn-id: http://core.svn.wordpress.org/trunk@36080 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-28 22:58:28 +00:00
John Blackbourn
afc7f43ca0 Comments: When a comment is submitted, ensure the user_ID element in the array that's passed to the preprocess_comment filter gets populated.
Fixes #34997

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


git-svn-id: http://core.svn.wordpress.org/trunk@36003 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-21 02:47:26 +00:00
Rachel Baker
719239ca1e Comments: Use an integer as the default value for comment_post_ID in wp_insert_comment to match database column.
Props MikeHansenMe, juanfra, rabmalin. 
Fixes #34956


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


git-svn-id: http://core.svn.wordpress.org/trunk@35912 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-15 15:13:27 +00:00
Sergey Biryukov
fe131bacd1 I18N: Use better context for comment statuses.
See #35054.
Built from https://develop.svn.wordpress.org/trunk@35902


git-svn-id: http://core.svn.wordpress.org/trunk@35866 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-13 19:11:26 +00:00
Rachel Baker
9dd574bd99 Comments: Comments don’t need no Post ID when created, so they don’t be needing one to be edited.
In `wp_update_comment()` only check if the given `comment_post_ID` is valid if it isn’t `0`.  This allows comments that were created programmatically via `wp_insert_comment()` without the (optional) `comment_post_ID` parameter to be edited.

Props subharanjan for the initial patch.
Fixes #34954


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


git-svn-id: http://core.svn.wordpress.org/trunk@35817 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-10 15:17:29 +00:00
John Blackbourn
28c78799c3 Ensure the correct error message is returned when a user attempts to comment on a post to which they do not have access.
Adds more tests.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35709 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-28 18:29:32 +00:00
Sergey Biryukov
bc1e479fd0 After [35718], update the location of some files in This filter is documented in docs.
Partially reverts [33954].

Fixes #33413.
Built from https://develop.svn.wordpress.org/trunk@35725


git-svn-id: http://core.svn.wordpress.org/trunk@35689 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-22 03:51:28 +00:00
Andrew Nacin
1579e45d41 Simplify the include graph after work to split out classes.
see #33413. More details there.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-20 07:24:30 +00:00
Drew Jaynes
5f6cdc2c3b Docs: The Comment API is singular.
See #33701.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 13:44:25 +00:00
Scott Taylor
67f90df6a4 Walker_Comment should be in its own file. Loaded now via wp-includes/comment.php, which makes it 100% BC.
See #33413.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33931 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-09 02:41:24 +00:00
Drew Jaynes
bfe8b01ef2 Docs: Clarify the file header summary for wp-includes/comment.php, the top-level file for the core Comments API.
Also adds inline DocBlock for the `require_once()` calls that now bring in the `WP_Comment` and `WP_Comment_Query` classes, as well as core comments functionality.

See #33413. See #33701.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-04 01:47:25 +00:00
Scott Taylor
e73ee5ac98 Introduce WP_Comment class to model/strongly-type rows from the comments database table. Inclusion of this class is a pre-req for some more general comment cleanup and sanity.
* Takes inspiration from `WP_Post` and adds sanity to comment caching. 
* Clarifies when the current global value for `$comment` is returned. The current implementation in `get_comment()` introduces side effects and an occasion stale global value for `$comment` when comment caches are cleaned.
* Strongly-types `@param` docs
* This class is marked `final` for now

Props wonderboymusic, nacin.

See #32619.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-03 18:17:24 +00:00
Scott Taylor
f07ab12359 Comments: move WP_Comment_Query into its own file. comment.php loads the new files, so this is 100% BC if someone is loading comment.php directly. New files created using svn cp.
Creates: 
`class-wp-comment-query.php` 
`comment-functions.php` 

`comment.php` contains only top-level code. Class file only contains the class. Functions file only contains functions.

See #33413.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33718 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-26 04:27:21 +00:00
Scott Taylor
ef87172270 foreach is a statement, not a function.
See #33491.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-25 20:28:22 +00:00
Drew Jaynes
7aff9092c7 Docs: Document the default comment data arguments for wp_new_comment().
Props rachelbaker, DrewAPicture
Fixes #32369.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33698 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-25 17:03:21 +00:00
Scott Taylor
572a0a587a Comments shouldn't have more than one _wp_trash_meta_status entry. When deleting _wp_trash_meta_status, also delete _wp_trash_meta_time.
See #11200.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33621 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-20 02:45:26 +00:00
Drew Jaynes
536cdddbcd Fix inline documentation syntax for get_default_comment_status(), introduced in 4.3.
See [33122]. See #32891.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33195 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-13 21:23:25 +00:00
Helen Hou-Sandí
30e478b1fb Move get_default_comment_status() to wp-includes/comment.php to sit alongside get_comment_statuses().
props nacin.
see #31168.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33093 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-08 15:44:28 +00:00
Boone Gorges
ca390b2fb5 Allow 'comment_agent' and 'comment_author_IP' to be set via wp_new_comment().
Props mrutz, wonderboymusic, rachelbaker.
Fixes #14601.
Built from https://develop.svn.wordpress.org/trunk@33021


git-svn-id: http://core.svn.wordpress.org/trunk@32992 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-01 12:08:25 +00:00
Scott Taylor
a0e373ef80 For doc block types, favor bool over the few remaining booleans
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32935 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-27 01:03:25 +00:00
Boone Gorges
fdd0917471 In WP_Comment_Query, parse meta_query vars after the pre_get_comments hook.
[31467] included a change that involved generating meta_query SQL before the
`pre_get_comments` hook, with the result that `pre_get_comments` callbacks were
no longer able to modify comment meta queries. We fix the problem by moving the
SQL generation to after the hook.

This changeset also includes a second call to `meta_query->parse_query_vars()`,
to ensure that modifications to metadata-related query vars (such as `meta_key`
and `meta_value`) performed in `pre_get_comments` callbacks have the expected
effect on the comment query.

Fixes #32762.
Built from https://develop.svn.wordpress.org/trunk@32911


git-svn-id: http://core.svn.wordpress.org/trunk@32882 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-23 14:36:27 +00:00
Scott Taylor
5e994cd6a1 Customizer et al, use elseif in PHP, not else if.
This was corrected via brute force in [31090].

See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32845 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-19 22:01:25 +00:00
Andrew Nacin
7080c8e24b Update comment caches in WP_Comment_Query, rather than comments template.
props dd32.
fixes #31081.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32740 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-14 19:21:25 +00:00
Scott Taylor
19a3aacc94 Add @static* annotations where they are missing.
Initialize all static vars that are not, most to `null`.

See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32620 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-29 15:43:29 +00:00
Drew Jaynes
4c37f68b79 Fix inline documentation syntax in wp_xmlrpc_server.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32561 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-25 06:25:25 +00:00
Scott Taylor
1b960d56b6 Add missing doc blocks to class-wp-theme.php.
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32517 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-22 17:31:27 +00:00
Drew Jaynes
2aa620b76a Update the DocBlock for wp_new_comment() to reference the wp_insert_comment() documentation for argument information.
Fixes #31747.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32470 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-13 02:54:26 +00:00
Drew Jaynes
4769bd2a4f Document the default arguments for wp_insert_comment() as a hash notation.
Props lamosty, rachelbaker.
See #31747.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32469 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-13 02:51:28 +00:00
Boone Gorges
3f642ba717 Use table prefix for comment__in and comment__not_in SQL clauses of WP_Comment_Query.
The prefix prevents ambiguity when joining against other tables.

Props willgladstone.
Fixes #32081.
Built from https://develop.svn.wordpress.org/trunk@32461


git-svn-id: http://core.svn.wordpress.org/trunk@32431 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-08 19:45:26 +00:00
Gary Pendergast
364886a5be WPDB: When checking that a string can be sent to MySQL, we shouldn't use mb_convert_encoding(), as it behaves differently to MySQL's character encoding conversion.
Props mdawaffe, pento, nbachiyski, jorbin, johnjamesjacoby, jeremyfelt.

See #32165.


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


git-svn-id: http://core.svn.wordpress.org/trunk@32335 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-06 03:00:25 +00:00
Dominik Schilling
64fc7294b6 Use HTTPS URLs for codex.wordpress.org.
see #27115.
Built from https://develop.svn.wordpress.org/trunk@32116


git-svn-id: http://core.svn.wordpress.org/trunk@32095 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-12 21:29:32 +00:00
Drew Jaynes
7bcbe0cce1 Remove an unnecessary inline @see tag and document the $wpdb global in two WP_Comment_Query methods.
See [31793]. See #31888.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32017 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-05 15:47:27 +00:00
Sergey Biryukov
46b5808530 Remove obsolete $wpdb reference from get_comments() docs.
props lamosty.
fixes #31748.
Built from https://develop.svn.wordpress.org/trunk@31870


git-svn-id: http://core.svn.wordpress.org/trunk@31849 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-24 15:43:30 +00:00
Drew Jaynes
04bfec64e4 Move the default arguments hash notation for WP_Comment_Query to the new constructor, where the argument definitions were moved in [31793].
Core style dictates that the default arguments should be documented in the same function or method where they are defined.

See [31793].
Fixes #24826.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-16 20:18:28 +00:00
Boone Gorges
0876c26025 Improve method consistency in WP_Comment_Query.
* Introduce a `__construct()` method, which can accept an array of query vars.
* Move query logic out of `query()` method and into a new `get_comments()` method.
* Ensure that `$this->comments` is set whenever `get_comments()` returns a value.
* Introduce a `parse_query()` method, where query vars are parsed with default values and the 'parse_comment_query' action is fired.

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

Props westonruter, morganestes, boonebgorges.
Fixes #24826.
Built from https://develop.svn.wordpress.org/trunk@31793


git-svn-id: http://core.svn.wordpress.org/trunk@31775 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-16 14:24:32 +00:00
Boone Gorges
b3e11db20b Respect comment_date and comment_date_gmt params in wp_new_comment().
Props solarissmoke, oso96_2000.
Fixes #14279.
Built from https://develop.svn.wordpress.org/trunk@31615


git-svn-id: http://core.svn.wordpress.org/trunk@31596 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-05 03:00:26 +00:00
Scott Taylor
94bd0f93b8 wp_insert_comment() should be checking and setting $compacted, not the non-existent $post_data.
See [31263], #21212.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31534 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-26 05:38:24 +00:00
Boone Gorges
a224ff7d9b Improve 'orderby' syntax for WP_Comment_Query.
Since [29027], `WP_Query` has supported an array of values for the `$orderby`
parameter, with field names as array keys and ASC/DESC as the array values.
This changeset introduces the same syntax to `WP_Comment_Query`.

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

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

Fixes #30478. See #31265.
Built from https://develop.svn.wordpress.org/trunk@31467


git-svn-id: http://core.svn.wordpress.org/trunk@31448 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-16 14:10:27 +00:00
Gary Pendergast
dc0f9e0079 Comments: When a comment fails to insert, remove invalid characters from the email and URL fields, too.
See [31263], #21212


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


git-svn-id: http://core.svn.wordpress.org/trunk@31245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-21 23:18:22 +00:00
Gary Pendergast
8196266d26 Comments: When a comment fails to insert, remove any invalid characters and try again.
See #21212


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


git-svn-id: http://core.svn.wordpress.org/trunk@31244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-21 23:04:23 +00:00
Gary Pendergast
b74f13511a Allow comment_post_ID to be passed to wp_update_comment(), so that a comment can be moved to a different post.
Props tyxla, rachelbaker

Fixes #30946


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


git-svn-id: http://core.svn.wordpress.org/trunk@31176 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 02:39:23 +00:00
Sergey Biryukov
dcaa26c1de Add 'user_id' to the list of fields wp_update_comment() can update.
props jphase.
fixes #30307.
Built from https://develop.svn.wordpress.org/trunk@31172


git-svn-id: http://core.svn.wordpress.org/trunk@31153 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-13 06:48:22 +00:00
Sergey Biryukov
47b47c4980 Add 'comment_type' to the list of fields wp_update_comment() can update.
props desaiuditd.
fixes #30627.
Built from https://develop.svn.wordpress.org/trunk@31171


git-svn-id: http://core.svn.wordpress.org/trunk@31152 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-13 06:42:21 +00:00
Scott Taylor
61e12e00c1 In WP_Comment_Query, only allow __call() to run against ->get_search_sql().
See #30891.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31131 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-11 22:33:24 +00:00