Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 6 years ago

#42797 closed defect (bug) (fixed)

Add missing parameter description in wp_get_post_parent_id function DocBlock

Reported by: keesiemeijer's profile keesiemeijer Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.1 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch has-unit-tests
Focuses: docs Cc:

Description

The wp_get_post_parent_id function accepts a post ID or a post object to get the parent post id and it defaults to the global post object.

Because the parameter is called $post_ID It needs to be updated to $post

Attachments (2)

42797.patch (2.5 KB) - added by keesiemeijer 7 years ago.
Add missing param description and rename $post_ID to $post
42797-tests.patch (2.7 KB) - added by Frank Klein 7 years ago.

Download all attachments as: .zip

Change History (9)

@keesiemeijer
7 years ago

Add missing param description and rename $post_ID to $post

#1 @keesiemeijer
7 years ago

  • Keywords has-patch has-unit-tests added

In patch 42797.patch the $post_ID parameter is renamed to $post and the description is added. I've added unit tests to see if the original code and new code return the same parent post ids.

#2 @SergeyBiryukov
7 years ago

  • Milestone changed from Awaiting Review to 5.0

#3 @SergeyBiryukov
7 years ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 42397:

Docs: Add missing parameter description in wp_get_post_parent_id() function DocBlock.

Rename $post_ID to $post for consistency with other functions.

Add unit tests for wp_get_post_parent_id().

Props keesiemeijer.
Fixes #42797.

#4 @SergeyBiryukov
7 years ago

In 42398:

Posts: Rename $ID to $post in get_post_mime_type() and get_post_status() for consistency with other functions.

See #42797.

#5 @Frank Klein
7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening this because the unit tests are not of an acceptable quality:

  1. Shared fixtures should be used whenever possible. The test suite is already slow, and we should keep it from getting slower unnecessarily.
  2. The global $post is an instance of WP_Post, and not an integer (post id).

Two smaller improvements:

  1. assertSame() should be preferred, because the checks are stricter.
  2. assertInstanceOf() is a shorter way to determine the type of an object.

Also the global $post gets reset after every test, so no need to do it manually.

#6 @SergeyBiryukov
7 years ago

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

In 42635:

Tests: Improve tests for wp_get_post_parent_id() added in [42397].

Props frank-klein.
Fixes #42797.

#7 @johnbillion
6 years ago

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