[wp-trac] Re: [WordPress Trac] #5384: wp_flag api

WordPress Trac wp-trac at lists.automattic.com
Sat Nov 24 06:50:48 GMT 2007


#5384: wp_flag api
-------------------------+--------------------------------------------------
 Reporter:  tellyworth   |        Owner:  anonymous
     Type:  enhancement  |       Status:  new      
 Priority:  normal       |    Milestone:  2.5      
Component:  General      |      Version:           
 Severity:  normal       |   Resolution:           
 Keywords:               |  
-------------------------+--------------------------------------------------
Comment (by darkdragon):

 Dude. I'm sorry. I'm not saying your idea is bad, I actually do like it a
 lot. I just don't agree with code that uses '@' to suppress errors and
 warnings. Which all in fact you are doing is covering up a possible bug.

 What does {{{@$_flags[$name]}}} return when it doesn't exist? I would
 really like to know. The most logical answer is 'NULL', but how can you be
 sure? It might return an empty string, or '0'. You also suppress the
 notice or warning that {{{$_flags[$name]}}} does not exist.

 Sure, I get that. However for most PHP versions, using '@' takes a
 performance hit. It isn't until PHP 5.1+ that the performance hit is
 fixed. Now, the question you must answer is how many people are using the
 latest version that fixes that performance hit and how much of an
 performance hit will be dealt to those that don't have that version?

 Don't take this personally, just explain these issues to me and clarify
 from what I think I know and educate me on what '@' is better than
 defensively programming.

 If something may not exist, then I was always taught to test to make sure
 that it does exist, explicitly. Using isset() does not introduce bugs, it
 removes them by explicitly testing what might have been failure in other
 instances. Less code does not mean always mean less bugs, sometimes you
 need more code to make sure that bugs won't show up.

 Thanks for the updated patch, but as you are creating an Registry Pattern,
 I think a class would provide a better solution instead.

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


More information about the wp-trac mailing list