Skip Navigation

[Résolu] Custom Field entries are lost when I update the listing

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: When I save a post in wp-admin, the custom field values are not saved. When the page reloads, the values are missing. Upon inspecting the server logs, I see lots of messages that say something like this:

WordPress database error Duplicate entry '532831' for key 'PRIMARY' for query INSERT INTO `wp_postmeta` (`post_id`, `meta_key`, `meta_value`) VALUES (212232, '_wp_page_template', 'default') ...

Solution:
Make a backup of your database, then repair the postmeta table using phpMyAdmin or your host Control Panel.

This support ticket is created Il y a 6 années et 9 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Ce sujet contient 9 réponses, a 2 voix.

Dernière mise à jour par indianplayschools Il y a 6 années et 9 mois.

Assisté par: Christian Cox.

Auteur
Publications
#611060

I am trying to update the listing or publish a listing entered by user. I can see the posted listing with custom fields. When I click on update during editing, the custom field entries dissappear. However the title, body and taxonomies remain safe. I have upadted all the plugins.
Please resolve .
Thank you

#611129

Hi, can you tell me some more information?
- I do not see a functions.php file in your child theme. Is any custom code added in another location?
- Please temporarily activate the default Twenty Seventeen theme and temporarily disable all non-Toolset plugins. Edit one of these listings in wp-admin, are the custom field values removed? If not, please reactivate other plugins one by one until the conflict is revealed.
- If the custom field values are removed, I can take a closer look. I may need to create a clone of your site and run some tests locally.

#611246
Untitled1.png
Untitled.png

Thank you for your response. I have uploaded twenty seventeen theme and deleted all the other plugins except Toolset.
But, the problem persists. When I tried editing an existing listing, after updating, I lose the custom fields. Even when I add a new listing, only the body part and taxonomies get published and custom fields remain empty. Please check the screenshot.
As the homepage looks odd, I am changing back the settings to original.
Please let me know what else can be done.

#611249

There is no funstions.php in the child theme as I did not customize it. Thank you

#611459

I looked at your site's error log file at indianplayschools.com/error_log and I see quite a few errors. Any time I try to make a change to one of the posts custom fields in wp-admin, an error like this is logged:

[31-Jan-2018 14:32:04 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')))  AND wp_posts.post_type = 'preschool' AND ((wp_posts.post_status = 'publish'' at line 1 for query SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  WHERE 1=1  AND ((()))  AND wp_posts.post_type = 'preschool' AND ((wp_posts.post_status = 'publish'))  ORDER BY wp_posts.post_date DESC LIMIT 925, 5 made by require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts

Another common error began occurring often as far back as Jan 29:

[29-Jan-2018 14:05:32 UTC] WordPress database error Duplicate entry '532831' for key 'PRIMARY' for query INSERT INTO `wp_postmeta` (`post_id`, `meta_key`, `meta_value`) VALUES (212232, '_wp_page_template', 'default') made by require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/Divi/page.php'), the_content, apply_filters('the_content'), WP_Hook->apply_filters, do_shortcode, preg_replace_callback, do_shortcode_tag, ET_Builder_Element->_shortcode_callback, ET_Builder_Section->shortcode_callback, do_shortcode, preg_replace_callback, do_shortcode_tag, ET_Builder_Element->_shortcode_callback, ET_Builder_Row->shortcode_callback, do_shortcode, preg_replace_callback, do_shortcode_tag, ET_Builder_Element->_shortcode_callback, ET_Builder_Column->shortcode_callback, do_shortcode, preg_replace_callback, do_shortcode_tag, ET_Builder_Element->_shortcode_callback, do_shortcode, preg_replace_callback, do_shortcode_tag, CRED_Helper::credFormShortcode, CRED_Helper::cred_form, CRED_Form_Builder_Base->get_form, CRED_Form_Base->print_form, CRED_Form_Post->create_new_post, cred__create_auto_draft, wp_insert_post, update_post_meta, update_metadata, add_metadata

This seems to indicate a problem in your database where mysql is trying to insert a duplicate primary key. I need to investigate this a bit further, so I have downloaded a All-in-One WP Migration clone from yesterday. Please stand by and I will take a closer look.

#611473

It's odd, the issue does not occur on my local copy of your site. I am able to edit custom field values without any problems. The duplicate key error message I see in your logs is pointing to a postmeta key which is related to post 212230, which is "Nest Pre School". This post is currently in the Trash on your site. Can I restore it temporarily to run some tests? After the tests, can I delete it permanently?

#611501

Yes please . You can delete that listing permanently. Thank You so much for your concern and support. i am totally unaware of what the issue is and why the error has occured. I will be grateful to you if you can help me out with this . Thank you.

#611511
Screen Shot 2018-01-31 at 12.02.47 PM.png

That didn't help, unfortunately. If the clone I downloaded is from 2 days ago, maybe the problem was introduced after the clone was made. Therefore I didn't get the corrupted database, and that's why it works for me. That would explain a lot. With that in mind, I can think of two options:

First, make a backup of your site's database. This is very important so you have a way to revert if necessary.

1. Repair your postmeta database table to fix the primary key issue. If you have access to the database with phpMyAdmin, you can repair a table there - see the screenshot for an example. If not, there may be an option to repair a specific table in your host Control Panel's Database settings or MySQL settings. If you are not able to figure out how to repair the postmeta database table, I recommend talking to your hosting company. They will be able to point you in the right direction.

2. Revert to the old site backup in All-in-One WP Migration. You will lose any data that was added since that backup, but I think the problem will be resolved since the problem did not occur for me with the old backup.

#611517

Thank You very much. I will look into the solution and repair postmeta

#611521

Thank you very much for the clear instructions. That screen shot was just what I needed as I am non-coder.Now, I have repaired the table. When I check now, my fields are intact. I am so grateful to you. Your support inspires me to give the same support to my clients.
Thanks a zillion