Title: Bug [with Fix] Multiple Duplicate Table Entries
Last modified: August 21, 2016

---

# Bug [with Fix] Multiple Duplicate Table Entries

 *  [hqarrse3](https://wordpress.org/support/users/hqarrse3/)
 * (@hqarrse3)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/)
 * I believe this is a bug, although doesn’t affect functionality. Every time you
   edit and save an article a new set of meta data is added, so filling the meta
   database unnecessarily.
 * If you therefore click on “Screen Options” and tick “Custom Fields” when editing
   a post, you get a long list of duplicates, 4 for every time the article is saved.
 * The reason for this is that WP function _update\_post\_meta _return false if 
   the data already exists (see below), but in the plugin in the case that data 
   already exists the false from update_post_meta is assumed to mean that the data
   doesn’t exist, and _add\_post\_meta_ is then called and a duplicate created. 
   This is around line 208 in author-product-reviews.php.
 * The fix is just to remove the 4 conditional calls to _add\_post\_meta_.
 * _____
 * From WP codex, for update_post_meta:
 * Returns meta_id if the meta doesn’t exist, otherwise returns true on success 
   and false on failure. It also returns false if the value submitted is the same
   as the value that is already in the database.
 * [http://wordpress.org/plugins/author-product-review/](http://wordpress.org/plugins/author-product-review/)

Viewing 15 replies - 1 through 15 (of 15 total)

 *  [nicmare](https://wordpress.org/support/users/nicmare/)
 * (@nicmare)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388954)
 * yea. i also mentioned this bug. see my screenshot: [https://www.dropbox.com/s/h7fis5ihpzgkk23/Screenshot%202014-01-04%2014.01.10.png](https://www.dropbox.com/s/h7fis5ihpzgkk23/Screenshot%202014-01-04%2014.01.10.png)
 * thank you for the fix! seems to work although i dont feel good to comment out
   so much code 😉
 *  [nicmare](https://wordpress.org/support/users/nicmare/)
 * (@nicmare)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388964)
 * update: i knew it would not be a good idea to remove so much code. now it does
   not save the custom fields on news posts. it only solves the duplicate fields
   on existing posts but now it does not work on new posts…
 *  Thread Starter [hqarrse3](https://wordpress.org/support/users/hqarrse3/)
 * (@hqarrse3)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388965)
 * then you’ve commented the wrong thing as it works fine. You should be commenting
   out the **add**_post_meta lines – I thought you were being a little melodramatic
   with “so much code”. You should be left with:
 *     ```
       update_post_meta($post_id, 'schema_product_name', $productName);
   
       update_post_meta($post_id, 'schema_product_price', $productPrice);
   
       update_post_meta($post_id, 'schema_price_currency', $priceCurrency);
   
       update_post_meta($post_id, 'schema_rating', $rating);
       ```
   
 *  Thread Starter [hqarrse3](https://wordpress.org/support/users/hqarrse3/)
 * (@hqarrse3)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388966)
 * the reason this works without add_post_meta is (from the codex):
 * **This may be used in place of add_post_meta**() function. The first thing this
   function will do is make sure that $meta_key already exists on $post_id. If it
   does not, add_post_meta($post_id, $meta_key, $meta_value) is called instead and
   its result is returned.
 *  Thread Starter [hqarrse3](https://wordpress.org/support/users/hqarrse3/)
 * (@hqarrse3)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388967)
 * Just made a mistake above – note my post [http://wordpress.org/support/topic/multiple-duplicate-table-entries?replies=5#post-5079057](http://wordpress.org/support/topic/multiple-duplicate-table-entries?replies=5#post-5079057)
   has been edited
 *  [nicmare](https://wordpress.org/support/users/nicmare/)
 * (@nicmare)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388968)
 * ah got it now! i commented out all the lines before instead of updating them ;-).
   seems to work right now. thank you hqarrse3!
 *  [jh20001](https://wordpress.org/support/users/jh20001/)
 * (@jh20001)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388991)
 * Thanks for the update. I’ve been wondering how to get rid of that >_<
 *  [Mike H](https://wordpress.org/support/users/mtnweekly/)
 * (@mtnweekly)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388992)
 * Is this really the solution. Asking people to go in and change code in WordPress
   so the Plugin will play nicely? This needs to be fixed ASAP
 *  Thread Starter [hqarrse3](https://wordpress.org/support/users/hqarrse3/)
 * (@hqarrse3)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388993)
 * I think the words you were looking for were:
 * “thanks Rajesh Namase for taking the time and trouble to post your code and documentation
   for others to use for free, and thanks hqarrse3 and nicmare for sorting out a
   bug and posting the discussion to help others”
 * followed perhaps by
 * “It looks as thought the author has moved on, and I think the community can do
   better, so I’m going to take this project on and (with the permission of Rajesh)”
   release a new version”
 *  [nicmare](https://wordpress.org/support/users/nicmare/)
 * (@nicmare)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388994)
 * haha
 *  [Mike H](https://wordpress.org/support/users/mtnweekly/)
 * (@mtnweekly)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388995)
 * Yeah this great info for people that know how to code. Want me how to tell you
   how to do a tuneup on your car? Think a newbie would be best going under the 
   hood?
 * “The fix is just to remove the 4 conditional calls to add_post_meta.” and where
   o where might this live. Again just pull the spark plugs out and put the wires
   back on….
 *  Thread Starter [hqarrse3](https://wordpress.org/support/users/hqarrse3/)
 * (@hqarrse3)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388996)
 * I would have to pay you to tune up my car as I don’t have the time or know-how.
   Likewise if you don’t have the time or know-how to adjust this modification to
   suit your needs, then you need to pay someone who does.
 * Looking at free / pro bono – just the same as I wouldn’t complain if you did 
   a less-than-perfect free tune-up for me, you should stop griping about less-than-
   perfect free coding work.
 * All that aside I can send you the file with the fixes in place if that helps.
 *  Thread Starter [hqarrse3](https://wordpress.org/support/users/hqarrse3/)
 * (@hqarrse3)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388997)
 * There you go:
 * [http://www.arrse.co.uk/olive_scripts/author-product-review.php.txt](http://www.arrse.co.uk/olive_scripts/author-product-review.php.txt)
 * Just replace the file with the same name in wp-content/plugins/author-product-
   review/ after removing the .txt from the end. That’s there just to stop my server
   trying to execute the file.
 *  [Mike H](https://wordpress.org/support/users/mtnweekly/)
 * (@mtnweekly)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388998)
 * Many thanks! hq
 *  [Mike H](https://wordpress.org/support/users/mtnweekly/)
 * (@mtnweekly)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388999)
 * mushrooms funny 🙂

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘Bug [with Fix] Multiple Duplicate Table Entries’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/author-product-review_eedef5.svg)
 * [Author Product Review](https://wordpress.org/plugins/author-product-review/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/author-product-review/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/author-product-review/)
 * [Active Topics](https://wordpress.org/support/plugin/author-product-review/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/author-product-review/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/author-product-review/reviews/)

## Tags

 * [duplicate](https://wordpress.org/support/topic-tag/duplicate/)

 * 15 replies
 * 4 participants
 * Last reply from: [Mike H](https://wordpress.org/support/users/mtnweekly/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/multiple-duplicate-table-entries/#post-4388999)
 * Status: not resolved