Coding Standards: Rename the `$postid` parameter to `$post_id` in `wp_delete_post()`.

This matches the parameter name in `wp_trash_post()` and all the other functions receiving post ID as a parameter.

See #60700.
Built from https://develop.svn.wordpress.org/trunk@57857


git-svn-id: http://core.svn.wordpress.org/trunk@57358 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2024-03-19 17:47:10 +00:00
parent 1a0add316f
commit f09287b6e1
2 changed files with 48 additions and 30 deletions

View File

@ -3460,15 +3460,15 @@ function wp_post_mime_type_where( $post_mime_types, $table_alias = '' ) {
* @see wp_delete_attachment()
* @see wp_trash_post()
*
* @param int $postid Optional. Post ID. Default 0.
* @param int $post_id Optional. Post ID. Default 0.
* @param bool $force_delete Optional. Whether to bypass Trash and force deletion.
* Default false.
* @return WP_Post|false|null Post data on success, false or null on failure.
*/
function wp_delete_post( $postid = 0, $force_delete = false ) {
function wp_delete_post( $post_id = 0, $force_delete = false ) {
global $wpdb;
$post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $postid ) );
$post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $post_id ) );
if ( ! $post ) {
return $post;
@ -3476,12 +3476,15 @@ function wp_delete_post( $postid = 0, $force_delete = false ) {
$post = get_post( $post );
if ( ! $force_delete && ( 'post' === $post->post_type || 'page' === $post->post_type ) && 'trash' !== get_post_status( $postid ) && EMPTY_TRASH_DAYS ) {
return wp_trash_post( $postid );
if ( ! $force_delete
&& ( 'post' === $post->post_type || 'page' === $post->post_type )
&& 'trash' !== get_post_status( $post_id ) && EMPTY_TRASH_DAYS
) {
return wp_trash_post( $post_id );
}
if ( 'attachment' === $post->post_type ) {
return wp_delete_attachment( $postid, $force_delete );
return wp_delete_attachment( $post_id, $force_delete );
}
/**
@ -3506,30 +3509,39 @@ function wp_delete_post( $postid = 0, $force_delete = false ) {
*
* @see wp_delete_post()
*
* @param int $postid Post ID.
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
*/
do_action( 'before_delete_post', $postid, $post );
do_action( 'before_delete_post', $post_id, $post );
delete_post_meta( $postid, '_wp_trash_meta_status' );
delete_post_meta( $postid, '_wp_trash_meta_time' );
delete_post_meta( $post_id, '_wp_trash_meta_status' );
delete_post_meta( $post_id, '_wp_trash_meta_time' );
wp_delete_object_term_relationships( $postid, get_object_taxonomies( $post->post_type ) );
wp_delete_object_term_relationships( $post_id, get_object_taxonomies( $post->post_type ) );
$parent_data = array( 'post_parent' => $post->post_parent );
$parent_where = array( 'post_parent' => $postid );
$parent_where = array( 'post_parent' => $post_id );
if ( is_post_type_hierarchical( $post->post_type ) ) {
// Point children of this page to its parent, also clean the cache of affected children.
$children_query = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s", $postid, $post->post_type );
$children_query = $wpdb->prepare(
"SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s",
$post_id,
$post->post_type
);
$children = $wpdb->get_results( $children_query );
if ( $children ) {
$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => $post->post_type ) );
}
}
// Do raw query. wp_get_post_revisions() is filtered.
$revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) );
$revision_ids = $wpdb->get_col(
$wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $post_id )
);
// Use wp_delete_post (via wp_delete_post_revision) again. Ensures any meta/misplaced data gets cleaned up.
foreach ( $revision_ids as $revision_id ) {
wp_delete_post_revision( $revision_id );
@ -3540,14 +3552,20 @@ function wp_delete_post( $postid = 0, $force_delete = false ) {
wp_defer_comment_counting( true );
$comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d ORDER BY comment_ID DESC", $postid ) );
$comment_ids = $wpdb->get_col(
$wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d ORDER BY comment_ID DESC", $post_id )
);
foreach ( $comment_ids as $comment_id ) {
wp_delete_comment( $comment_id, true );
}
wp_defer_comment_counting( false );
$post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ) );
$post_meta_ids = $wpdb->get_col(
$wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id )
);
foreach ( $post_meta_ids as $mid ) {
delete_metadata_by_mid( 'post', $mid );
}
@ -3571,12 +3589,12 @@ function wp_delete_post( $postid = 0, $force_delete = false ) {
* @since 1.2.0
* @since 5.5.0 Added the `$post` parameter.
*
* @param int $postid Post ID.
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
*/
do_action( 'delete_post', $postid, $post );
do_action( 'delete_post', $post_id, $post );
$result = $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) );
$result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) );
if ( ! $result ) {
return false;
}
@ -3600,10 +3618,10 @@ function wp_delete_post( $postid = 0, $force_delete = false ) {
* @since 2.2.0
* @since 5.5.0 Added the `$post` parameter.
*
* @param int $postid Post ID.
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
*/
do_action( 'deleted_post', $postid, $post );
do_action( 'deleted_post', $post_id, $post );
clean_post_cache( $post );
@ -3613,7 +3631,7 @@ function wp_delete_post( $postid = 0, $force_delete = false ) {
}
}
wp_clear_scheduled_hook( 'publish_future_post', array( $postid ) );
wp_clear_scheduled_hook( 'publish_future_post', array( $post_id ) );
/**
* Fires after a post is deleted, at the conclusion of wp_delete_post().
@ -3623,10 +3641,10 @@ function wp_delete_post( $postid = 0, $force_delete = false ) {
*
* @see wp_delete_post()
*
* @param int $postid Post ID.
* @param int $post_id Post ID.
* @param WP_Post $post Post object.
*/
do_action( 'after_delete_post', $postid, $post );
do_action( 'after_delete_post', $post_id, $post );
return $post;
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.6-alpha-57854';
$wp_version = '6.6-alpha-57857';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.