[wp-trac] Re: [WordPress Trac] #5265: current_user_can() can run before wp_get_current_user() is defined

WordPress Trac wp-trac at lists.automattic.com
Mon Dec 10 04:19:11 GMT 2007


#5265: current_user_can() can run before wp_get_current_user() is defined
----------------------------+-----------------------------------------------
 Reporter:  Viper007Bond    |        Owner:  anonymous
     Type:  defect          |       Status:  closed   
 Priority:  normal          |    Milestone:           
Component:  Administration  |      Version:  2.3.1    
 Severity:  normal          |   Resolution:  invalid  
 Keywords:                  |  
----------------------------+-----------------------------------------------
Changes (by Viper007Bond):

  * status:  reopened => closed
  * resolution:  => invalid
  * milestone:  2.4 =>

Comment:

 Replying to [comment:10 darkdragon]:
 > For what it is worth, I agree with DD32. It is unacceptable to assume
 that functions will exist without hooking into init hook first. So
 naturally, anything plugin that doesn't follow this principle has a bug in
 the plugin and not in WordPress. It is a limitation of the language and
 therefore seems illogical to assume that functions will be available
 before PHP knows about it.

 I don't think there's any disagreement there.

 My point though is that I'm not calling a function that doesn't exist, I'm
 calling one that does and that's causing all of WordPress to break and
 that there should be some error handling there. One would think that any
 function defined at the time custom code is run would be expected to work
 or that otherwise it'd be undefined, but maybe that's just me...

 But anyway, I'll re-mark as invalid since the proper practice is to not
 run anything at plugin load.

 > '''WTF?''' Returning null in a constructor, that is plain bad practice
 right there. You should know better than that!

 Heh, I wasn't actually putting that forward that exact solution, just that
 perhaps it'd be best for the function to fail gracefully. ;)

-- 
Ticket URL: <http://trac.wordpress.org/ticket/5265#comment:11>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list