[wp-trac] [WordPress Trac] #62366: get_post_states() throws PHP warning

WordPress Trac noreply at wordpress.org
Sat Nov 9 17:24:11 UTC 2024


#62366: get_post_states() throws PHP warning
-------------------------+-------------------------------------------------
 Reporter:  akramipro    |       Owner:  (none)
     Type:  defect       |      Status:  new
  (bug)                  |
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Posts, Post  |     Version:  trunk
  Types                  |
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  coding-standards, php-
  close                  |  compatibility
-------------------------+-------------------------------------------------

Comment (by akramipro):

 > User? I would think the developer. When a user enters somthing it sholud
 be validated, bit fail to see the relvance here.
 by user i mean developers 😅
 > Suggestion: Trace the error and see where it comes from. If core,
 investigate the cases it may happen, report here, then we can perhaps make
 that code better. If theme/plugin inform the authors.
 as i mentioned before it happens in `wp_setup_nav_menu_item()`
 there is already a ticket for that: #58932

 they suggest checking `$post` before pass to `get_post_states()` like you
 say.
 but i was thinking it is better to check that inside function.

 i understand what you mean and i agree with you that we can add a "doing
 it wrong" to let developers know they are passing bad `$post`.

 [[Image(https://img001.prntscr.com/file/img001/nvUGSwfAS-
 WaZNgNMxb1vg.png)]]

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


More information about the wp-trac mailing list