[wp-hackers] WP option set bug (or at least discrepancy)

Stephane Daury wordpress at tekartist.org
Fri Apr 4 14:30:43 GMT 2008


Maes sense.

Thanks Jacob.

---
Stephane Daury - http://tekartist.org/



On Apr 03, 2008, at 12:40, Jacob Santos wrote:

> Yes.
>
> You should use add_option, while you are installing, unless of  
> course the
> option is dynamic. When you are updating, you should use  
> update_option.
>
> In order to figure out whether or not you should update, you should  
> use
> get_option to retrieve the option and test whether it is false, then
> either install or upgrade, if needed.
>
> Proper plugin development techniques should be expressed on the  
> codex to
> prevent errors on the part of the developers (not all of whom are  
> complete
> idiots, I do really stupid crap too, don't get me started, I have a  
> long
> list I just shake my head at).
>
> Back on topic, there has been a patch made to "correct" this issue,
> however it seems partially human error and developers to blame. I  
> think
> developers were spoiled off of add_posts() and update_posts(), not all
> code works that way, nor should all code work that way.
>
> Also on topic, this is the exact reason why you don't put  
> documentation
> that belongs inline in a developer manual setting. When you make a  
> change
> inline, you see the documentation there and can update it. Knowing  
> where
> it is on the codex is or even if it is on the codex is tedious.
>
> I will suggest just creating a patch which adds phpdoc to that  
> function in
> the source and just give examples of usage on the codex page.
>
>
>> Hey all,
>>
>> There's a nasty discrepancy between the core codebase and the codex  
>> in
>> regards to the update_option() function.
>>
>> http://codex.wordpress.org/Function_Reference/update_option
>>
>> In the above docs, the advertised params are :
>> - $name
>> - $value
>> - $description
>> - $autoload
>>
>> But in the code (wp-includes/functions.php), the specs actually are
>> update_option($option_name, $newvalue)
>>
>> The main issue with this is that (as far as I know), everybody uses
>> update_option over add_option, since the docs (and code) states:
>> "This function can be called even if the option does not exist, the
>> function will create the option. ".
>>
>> It's an immediate issue for me that gonna be a big drag, because I  
>> now
>> need to check if the option exists, then use add or update, since I
>> need to set the autoload flag.
>> Not the end of the world, but I thought I'd mention it before editing
>> the codex page.
>>
>> Is there something I'm missing?!?
>>
>> Stephane
>>
>>
>>
>>
>> ---
>> Stephane Daury - http://tekartist.org/
>>
>>
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
> -- 
> Jacob Santos
>
> http://www.santosj.name - Personal Blog
> http://funcdoc.wordpress.com - WordPress Function Documentation Blog
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list