[wp-hackers] Nasty get_option()/get_settings() bug
Mark Jaquith
mark.wordpress at txfx.net
Wed Jan 11 23:18:45 GMT 2006
On Jan 11, 2006, at 8:56 AM, David House wrote:
> On 11/01/06, Mark Jaquith <mark.wordpress at txfx.net> wrote:
>> So what we need to do is come up with a way to discriminate between
>> "option isn't in cache" (and therefore, make the query) and "option's
>> non-existence has been cached" (and therefore don't make the query,
>> because we know it doesn't exist).
>
> The way it used to be done is have a seperate cache,
> $cache_nonexistantoptions or something, that stored the names of
> options that don't exist. This was checked before querying the DB. Is
> this not done now?
No, this is not currently done.
On Jan 11, 2006, at 2:53 PM, Matt Mullenweg wrote:
> There are so many funky bugs related to NULL/FALSE in PHP I would
> almost have a "magic" reserved value that means the option doesn't
> exist
Yeah, that could work. Return "%WP_OPTION_DOES_NOT_EXIST%" or some
such if the option does not exist in the option cache. Then, instead
of checking for $value === false, check for $value === "%
WP_OPTION_DOES_NOT_EXIST%" and only do the query in that circumstance.
It's hacky, but it's relatively uncomplicated. As long as our
"magic" string is obscure enough that it will never be legitimately
used, it should work fine.
--
Mark Jaquith
http://txfx.net/
More information about the wp-hackers
mailing list