[wp-hackers] 0 as meta-data value is not being added to thedatabase.

Kevinjohn Gallagher kevinjohngallagher at hotmail.com
Mon Dec 12 22:21:34 UTC 2011


Thanks Otto,

That's a good catch bro, I had to check:
-  get_metadata (and using a print_r to test) isn't returning anything
-  upon testing adding metadata with a meta_value of 0 doesn't get added to 
the database
-  upon testing updating an existing metadata with a meta_value of 0 removes 
that metadata from the database

I've been through the code and added all the various debug and die() scripts 
and the appropriate: add_post_meta and update_post_meta.

wait... Wouldn't you know, because I'm not embarrassed enough already, the 
code has a typo in it that I couldn't spot until now.

Sorry all, and thanks for the help.
Kev


-----Original Message----- 
From: Otto
Sent: Monday, December 12, 2011 9:40 PM
To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] 0 as meta-data value is not being added to 
thedatabase.

I can't see any reason it wouldn't add it.

Are you checking the database directly for the result? Or are you
checking with get_metadata and then comparing to false?

Reason I ask is because 0 == false, but 0 does not === false.

-Otto



On Mon, Dec 12, 2011 at 2:14 PM, Kevinjohn Gallagher
<kevinjohngallagher at hotmail.com> wrote:
> One of many tonight (sorry folks),
>
> For the life of me I can’t figure this one out, when I try to add or 
> update meta-data where the value is “0” (zero), it’s neither adds or 
> updates it.
> If I change the value to anything other than “0” or “ “ it works fine.
> We surely don’t think that “0” is the same as no data, do we?
>
> Any idea’s?
>
> Thanks very much,
> Kev
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
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