diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index ca30890169..0bf6c52654 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -6327,12 +6327,12 @@ function is_local_attachment( $url ) { * * @param string|array $args Arguments for inserting an attachment. * @param string|false $file Optional. Filename. - * @param int $parent_post Optional. Parent post ID. + * @param int $parent_post_id Optional. Parent post ID. * @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false. * @param bool $fire_after_hooks Optional. Whether to fire the after insert hooks. Default true. * @return int|WP_Error The attachment ID on success. The value 0 or WP_Error on failure. */ -function wp_insert_attachment( $args, $file = false, $parent_post = 0, $wp_error = false, $fire_after_hooks = true ) { +function wp_insert_attachment( $args, $file = false, $parent_post_id = 0, $wp_error = false, $fire_after_hooks = true ) { $defaults = array( 'file' => $file, 'post_parent' => 0, @@ -6340,8 +6340,8 @@ function wp_insert_attachment( $args, $file = false, $parent_post = 0, $wp_error $data = wp_parse_args( $args, $defaults ); - if ( ! empty( $parent_post ) ) { - $data['post_parent'] = $parent_post; + if ( ! empty( $parent_post_id ) ) { + $data['post_parent'] = $parent_post_id; } $data['post_type'] = 'attachment'; diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php index 210505c862..61fd9233e3 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php @@ -134,21 +134,21 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { * * @since 4.7.2 * - * @param int $parent_post Supplied ID. + * @param int $parent_post_id Supplied ID. * @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise. */ - protected function get_parent( $parent_post ) { + protected function get_parent( $parent_post_id ) { $error = new WP_Error( 'rest_post_invalid_parent', __( 'Invalid post parent ID.' ), array( 'status' => 404 ) ); - if ( (int) $parent_post <= 0 ) { + if ( (int) $parent_post_id <= 0 ) { return $error; } - $parent_post = get_post( (int) $parent_post ); + $parent_post = get_post( (int) $parent_post_id ); if ( empty( $parent_post ) || empty( $parent_post->ID ) || $this->parent_post_type !== $parent_post->post_type diff --git a/tests/phpunit/includes/factory/class-wp-unittest-factory-for-attachment.php b/tests/phpunit/includes/factory/class-wp-unittest-factory-for-attachment.php index 85206d5159..262c6c4640 100644 --- a/tests/phpunit/includes/factory/class-wp-unittest-factory-for-attachment.php +++ b/tests/phpunit/includes/factory/class-wp-unittest-factory-for-attachment.php @@ -55,12 +55,12 @@ class WP_UnitTest_Factory_For_Attachment extends WP_UnitTest_Factory_For_Post { * @since 4.4.0 * @since 6.2.0 Returns a WP_Error object on failure. * - * @param string $file The file name to create attachment object for. - * @param int $parent ID of the post to attach the file to. + * @param string $file The file name to create attachment object for. + * @param int $parent_post_id ID of the post to attach the file to. * * @return int|WP_Error The attachment ID on success, WP_Error object on failure. */ - public function create_upload_object( $file, $parent = 0 ) { + public function create_upload_object( $file, $parent_post_id = 0 ) { $contents = file_get_contents( $file ); $upload = wp_upload_bits( wp_basename( $file ), null, $contents ); @@ -78,13 +78,13 @@ class WP_UnitTest_Factory_For_Attachment extends WP_UnitTest_Factory_For_Post { 'post_title' => wp_basename( $upload['file'] ), 'post_content' => '', 'post_type' => 'attachment', - 'post_parent' => $parent, + 'post_parent' => $parent_post_id, 'post_mime_type' => $type, 'guid' => $upload['url'], ); // Save the data. - $attachment_id = wp_insert_attachment( $attachment, $upload['file'], $parent, true ); + $attachment_id = wp_insert_attachment( $attachment, $upload['file'], $parent_post_id, true ); if ( is_wp_error( $attachment_id ) ) { return $attachment_id;