Make WordPress Core

Opened 6 years ago

Closed 10 months ago

Last modified 9 months ago

#45030 closed enhancement (fixed)

Remove new_postarr from doc in wp_insert_post function

Reported by: mukesh27's profile mukesh27 Owned by:
Milestone: 5.0 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch
Focuses: docs Cc:

Description

$new_postarr is not used but it is mentioned in the documentation of the wp_insert_post() function.

Attachments (3)

45030.patch (536 bytes) - added by mukesh27 6 years ago.
45030.2.patch (608 bytes) - added by mukesh27 6 years ago.
updated patch with file path
45030.3.patch (693 bytes) - added by mukesh27 6 years ago.

Download all attachments as: .zip

Change History (11)

@mukesh27
6 years ago

@mukesh27
6 years ago

updated patch with file path

#1 @johnbillion
6 years ago

  • Keywords reporter-feedback added

Thanks for the patch @mukesh27. $new_postarr is the name given to the third of four parameters passed to this filter. Am I missing something?

#2 follow-up: @mukesh27
6 years ago

  • Keywords reporter-feedback removed

Thank you for your reply @johnbillion. You can check online link https://core.trac.wordpress.org/browser/trunk/src/wp-includes/post.php#L3575 filter wp_insert_post_parent contain one array variable $postarr.

Last edited 6 years ago by mukesh27 (previous) (diff)

#3 in reply to: ↑ 2 ; follow-up: @peterwilsoncc
6 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Replying to mukesh27:

You can check online link https://core.trac.wordpress.org/browser/trunk/src/wp-includes/post.php#L3575 filter wp_insert_post_parent contain one array variable $postarr.

The documentation for filters can be a little confusing.

The parameter names are for the function that the filter calls, rather than as passed. In this case compact( array_keys( $postarr ) ) is expected to be named $new_postarr in the called function.

The code you link to is a shorter way of writing:

<?php
$new_postarr = compact( array_keys( $postarr ) );
$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, $new_postarr, $postarr );

I'm going to close this ticket as invalid, which is trac's unfriendly way of documenting no change is needed.

#4 in reply to: ↑ 3 @mukesh27
6 years ago

  • Resolution invalid deleted
  • Status changed from closed to reopened
  • Type changed from defect (bug) to enhancement

@peterwilsoncc my question is that we have to add code relate $new_postarr = compact( array_keys( $postarr ) ); and pass it to filter then doc elements are right as per written.

Need to add update code file like you suggested.

<?php
$new_postarr = compact( array_keys( $postarr ) );
$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, $new_postarr, $postarr );

Replying to peterwilsoncc:

Replying to mukesh27:

You can check online link https://core.trac.wordpress.org/browser/trunk/src/wp-includes/post.php#L3575 filter wp_insert_post_parent contain one array variable $postarr.

The documentation for filters can be a little confusing.

The parameter names are for the function that the filter calls, rather than as passed. In this case compact( array_keys( $postarr ) ) is expected to be named $new_postarr in the called function.

The code you link to is a shorter way of writing:

<?php
$new_postarr = compact( array_keys( $postarr ) );
$post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, $new_postarr, $postarr );

I'm going to close this ticket as invalid, which is trac's unfriendly way of documenting no change is needed.

@mukesh27
6 years ago

#5 @SergeyBiryukov
6 years ago

  • Milestone set to 5.1

#6 @pento
6 years ago

  • Milestone changed from 5.1 to Future Release

The coding standards project is looking at the best way to manage situations like this, so I'm moving this out of 5.1, until there's a decision on that.

#7 @johnbillion
10 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

This was fixed in [44166].

#8 @swissspidy
9 months ago

  • Milestone changed from Future Release to 5.0
Note: See TracTickets for help on using tickets.