Changeset 48154 for trunk/src/wp-includes/comment.php
- Timestamp:
- 06/24/2020 12:03:33 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment.php
r48140 r48154 2406 2406 * @since 2.0.0 2407 2407 * @since 4.9.0 Add updating comment meta during comment update. 2408 * @since 5.5.0 Allow returning a WP_Error object on failure. 2408 2409 * 2409 2410 * @global wpdb $wpdb WordPress database abstraction object. 2410 2411 * 2411 2412 * @param array $commentarr Contains information on the comment. 2412 * @return int The value 1 if the comment was updated, 0 if not updated. 2413 */ 2414 function wp_update_comment( $commentarr ) { 2413 * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. 2414 * @return int|bool|WP_Error Comment was updated if value is 1, or was not updated if value is 0, 2415 * false, or a WP_Error object. 2416 */ 2417 function wp_update_comment( $commentarr, $wp_error = false ) { 2415 2418 global $wpdb; 2416 2419 … … 2418 2421 $comment = get_comment( $commentarr['comment_ID'], ARRAY_A ); 2419 2422 if ( empty( $comment ) ) { 2420 return 0; 2423 if ( ! $wp_error ) { 2424 return 0; 2425 } 2426 2427 return new WP_Error( 'invalid_comment_id', __( 'Invalid comment ID.' ) ); 2421 2428 } 2422 2429 2423 2430 // Make sure that the comment post ID is valid (if specified). 2424 2431 if ( ! empty( $commentarr['comment_post_ID'] ) && ! get_post( $commentarr['comment_post_ID'] ) ) { 2425 return 0; 2432 if ( ! $wp_error ) { 2433 return 0; 2434 } 2435 2436 return new WP_Error( 'invalid_post_id', __( 'Invalid post ID.' ) ); 2426 2437 } 2427 2438 … … 2464 2475 * Filters the comment data immediately before it is updated in the database. 2465 2476 * 2466 * Note: data being passed to the filter is already unslashed. 2477 * Note: data being passed to the filter is already unslashed. Returning 0 or a 2478 * WP_Error object is preventing the comment to be updated. 2467 2479 * 2468 2480 * @since 4.7.0 2481 * @since 5.5.0 Allow returning a WP_Error object on failure. 2469 2482 * 2470 2483 * @param array $data The new, processed comment data. 2471 2484 * @param array $comment The old, unslashed comment data. 2472 2485 * @param array $commentarr The new, raw comment data. 2473 */ 2474 $data = apply_filters( 'wp_update_comment_data', $data, $comment, $commentarr ); 2486 * @param bool $wp_error Optional. Whether to return a WP_Error on failure. 2487 * Default false. 2488 */ 2489 $data = apply_filters( 'wp_update_comment_data', $data, $comment, $commentarr, $wp_error ); 2490 2491 // Do not carry on on failure. 2492 if ( is_wp_error( $data ) || 0 === $data ) { 2493 return $data; 2494 } 2475 2495 2476 2496 $keys = array( 'comment_post_ID', 'comment_content', 'comment_author', 'comment_author_email', 'comment_approved', 'comment_karma', 'comment_author_url', 'comment_date', 'comment_date_gmt', 'comment_type', 'comment_parent', 'user_id', 'comment_agent', 'comment_author_IP' );
Note: See TracChangeset
for help on using the changeset viewer.