Opened 6 years ago
Closed 6 years ago
#51376 closed defect (bug) (fixed)
wp_get_shortlink produces PHP Notice on unregistered post type
| Reported by: | apedog | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.6 |
| Component: | Posts, Post Types | Version: | |
| Severity: | normal | Keywords: | has-patch |
| Cc: | Focuses: |
Description
Calling wp_get_shortlink with an existing ID of an unregistered custom post type, the following PHP notice is shown:
Notice: Trying to get property 'public' of non-object in \wp-includes\link-template.php on line 3913
Step to reproduce:
- Create a custom post type.
- Add new post of custom post type to database.
- Unregister/disable custom post type.
- Call
wp_get_shortlinkwith ID from step 2
Problem is due to get_post( $id ) returning object regardless if registered or not. So $post_id is not empty.
However get_post_type_object returns null with no sanity checks before $post_type->public is tested.
Attachments (2)
Change History (6)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
51376 - alternative patch