[wp-hackers] preventing the duplicate wp_insert_post effect

Andrew Nacin wp at andrewnacin.com
Sat Jun 23 21:35:23 UTC 2012


On Thu, Jun 21, 2012 at 8:12 PM, Haluk Karamete <halukkaramete at gmail.com>wrote:

> One discovery...
>
> If I change the  "wp_insert_post"  to wpdb->insert and use a straight
> wpdb insert, there are no problems. So this is all comes down to the
> wp_insert_post.
>

I've never seen your issue before, and I've worked on similar migration
scripts many times, with tens, hundreds of thousands, and millions
of records. I've also never seen a bug report on Trac highlighting an
issue with duplicated inserts for wp_insert_post(). You say you're
not alone, and that may be true, but I've never heard of "the duplicate
"wp_insert_post effect".

So, something tells me this is a bug in your code. Perhaps your code
to differentiate between an insert and an update does not work and
instead you get repeated inserts. Perhaps you have code (or a plugin)
that does something very weird (and wrong) on an action fired by
wp_insert_post(). Given that you modified it to use $wpdb->insert()
directly (which is a very bad idea, as it isn't very forwards compatible
if wp_insert_post() changes in the future), a code conflict seems likely.

Nacin


More information about the wp-hackers mailing list