[wp-testers] Can't Add Custom Field

Chris Jean gaarai at gaarai.com
Thu Oct 29 15:41:46 UTC 2009


For those interested, I worked with Nathan on this issue and got it
remedied.

The problem was that the postmeta table had a modified schema in
addition to a broken index. The MySQL version running was 3.1.22, which
did have a bug that could cause failed inserts/updates due to a flaw in
the indexes. This was patched in version 3.1.23. So, I'm unsure if the
problem derived from the purely the version bug or if the schema
modification affected it as well.

The portion of the postmeta schema that was modified was the meta_id
column. It should be "bigint(20) unsigned not null primary key auto
increment"; however, it was "bigint(20) unsigned not null primary key
default='0'".

To fix the problem I dropped all three of the postmeta indexes,
confirmed that the issue was fixed, modified the column to fix the
schema, and recreated all three indexes. After this, the problem was
resolved.

So, the problem was MySQL-specific and not necessary related to
WordPress other than the fact that WordPress used the table.

One thing that could be helpful is to modify the handling of the
add_meta responses in wp-admin/admin-ajax.php. Currently no errors are
reported and any failure responds with "Please provide a custom field
value" each time add_meta fails.

Chris Jean
http://gaarai.com/
@chrisjean



Chris Jean wrote:
> I don't know why you are experiencing the problem since I can't
> duplicate it, but this might help you along.
>
> There are two conditions when this occurs (you can find both in
> wp-admin/admin-ajax.php). Both of these conditions result from a failure
> of the function add_meta.
>
> If I were you, I'd dig around in the add_meta function (found in
> wp-admin/includes/post.php). I'd add a bunch of error_log statements to
> dump out exactly what all the variables contain to see where the failure
> point is. Specifically, I'd start by dumping the contents of the
> $metavalue variable and the prepared insert statement.
>
> However, just to ensure it's not just a file problem, have you
> downloaded fresh code from wp.org and replaced all the wp-admin and
> wp-include files?
>
> Chris Jean
> http://gaarai.com/
> @chrisjean
>
>
>
> Nathan Rice wrote:
>   
>> Hey guys, quick question that you might be able to answer. I haven't been
>> able to find an answer to this anywhere else, so...
>>
>> I'm trying to add custom fields to new posts. When I choose the key and
>> enter the value and click "Add Custom Field", I get this error:
>>
>> "Please provide a custom field value."
>>
>> I did. But to double check, I do it again, providing a cf value. Same error.
>>
>> Running WP 2.8.5.
>>
>> This started happening right after a server migration, so just to be extra
>> careful, I've repaired and optimized all my tables from PHPMyAdmin, still no
>> luck.
>>
>> FWIW, I tried using a plugin that saves custom field values during the post
>> save process and they fail too (All in one SEO pack, for example) so it
>> seems that the add_post_meta() function is what is failing.
>>
>> Also of interest, updating custom fields seems to work fine. I can change
>> existing custom field values all day long. Which seems to indicate that
>> update_post_meta() is working just fine.
>>
>> Any help would be appreciated.
>>
>> Thanks!
>>
>> ------------------
>> Nathan Rice
>> WordPress and Web Development
>> www.nathanrice.net | twitter.com/nathanrice | www.modthemes.com
>> _______________________________________________
>> wp-testers mailing list
>> wp-testers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-testers
>>   
>>     


More information about the wp-testers mailing list