WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 21 months ago

#45030 reopened enhancement

Remove new_postarr from doc in wp_insert_post function

Reported by: mukesh27 Owned by:
Milestone: Future Release 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 2 years ago.
45030.2.patch (608 bytes) - added by mukesh27 2 years ago.
updated patch with file path
45030.3.patch (693 bytes) - added by mukesh27 2 years ago.

Download all attachments as: .zip

Change History (9)

@mukesh27
2 years ago

@mukesh27
2 years ago

updated patch with file path

#1 @johnbillion
2 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
2 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 2 years ago by mukesh27 (previous) (diff)

#3 in reply to: ↑ 2 ; follow-up: @peterwilsoncc
2 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
2 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
2 years ago

#5 @SergeyBiryukov
2 years ago

  • Milestone set to 5.1

#6 @pento
21 months 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.

Note: See TracTickets for help on using tickets.