[wp-trac] [WordPress Trac] #44497: get_page_link() doesn't check if a valid post object is returned before trying to access its properties

WordPress Trac noreply at wordpress.org
Thu Mar 12 21:08:41 UTC 2026


#44497: get_page_link() doesn't check if a valid post object is returned before
trying to access its properties
-------------------------------+-----------------------------
 Reporter:  rodrigosprimo      |       Owner:  (none)
     Type:  defect (bug)       |      Status:  new
 Priority:  normal             |   Milestone:  Future Release
Component:  Posts, Post Types  |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  needs-refresh      |     Focuses:
-------------------------------+-----------------------------
Changes (by westonruter):

 * keywords:  has-patch => needs-refresh
 * milestone:  Awaiting Review => Future Release


Comment:

 I think we can simply update `get_page_link()` to return an empty string
 if `get_post()` fails to return a `WP_Post`. We can skip the
 `_doing_it_wrong()`, I think.

 Also, the same should be done for `_get_page_link()`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44497#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list