[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 03:52:06 GMT 2007


#5265: current_user_can() can run before wp_get_current_user() is defined
----------------------------+-----------------------------------------------
 Reporter:  Viper007Bond    |        Owner:  anonymous
     Type:  defect          |       Status:  reopened 
 Priority:  normal          |    Milestone:  2.4      
Component:  Administration  |      Version:  2.3.1    
 Severity:  normal          |   Resolution:           
 Keywords:                  |  
----------------------------+-----------------------------------------------
Comment (by 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.

 Just because a function makes reference to a function that may not exist
 at that time, doesn't mean it will break anything until the function is
 called that contains the function in question.

 As for fixing the pluggables, there is a pattern that would be useful. I
 forget what the name is. Hmm, related to Dependency Interjection, but I
 don't think that is the correct name for the pattern. No matter.

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

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


More information about the wp-trac mailing list