XF 1.5 IPB 3.4 gallery import: Mysqli statement execute error : Duplicate entry '20953' for key 'PRIMARY'


Active member

trying to get a testboard running and I got a problem with the import of the gallery images. Every time it stops at a certain image ID with following error message:

Mysqli statement execute error : Duplicate entry '20953' for key 'PRIMARY'

    Zend_Db_Statement_Mysqli->_execute() in Zend/Db/Statement.php at line 297
    Zend_Db_Statement->execute() in Zend/Db/Adapter/Abstract.php at line 479
    Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 574
    Zend_Db_Adapter_Abstract->insert() in XenForo/DataWriter.php at line 1638
    XenForo_DataWriter->_insert() in XenForo/DataWriter.php at line 1627
    XenForo_DataWriter->_save() in XenForo/DataWriter.php at line 1419
    XenForo_DataWriter->save() in XenGallery/Model/Importers.php at line 167
    XenGallery_Model_Importers->importMedia() in XenGallery/Importer/IPGallery34x.php at line 663
    XenGallery_Importer_IPGallery34x->_importMedia() in XenGallery/Importer/IPGallery34x.php at line 557
    XenGallery_Importer_IPGallery34x->stepMedia() in XenForo/Importer/Abstract.php at line 124
    XenForo_Importer_Abstract->runStep() in XenForo/ControllerAdmin/Import.php at line 189
    XenForo_ControllerAdmin_Import->_runStep() in XenForo/ControllerAdmin/Import.php at line 137
    XenForo_ControllerAdmin_Import->actionImport() in XenForo/FrontController.php at line 351
    XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
    XenForo_FrontController->run() in /is/htdocs/page/www/page/xen/admin.php at line 13

I already tried:
- deleting the entry 20953 in xenforo database (xengallery_media) -> same error
- deleting the entry 20953 in the ipb source database -> same error for 20954 -> also deleted 20954 -> same error for 20955 -> also deleted 20955 -> now it won't move on anymore (stuck at 20,54 %), as if it still expects 20953-20955 to come -> Started the whole gallery import again (deleted everything first) without 20953-20955 in ipb source database -> gets stuck at the same place (20,54 %) and just loads for an eternity, but actually seem to do nothing (no new tables in the database. Last entry 20952).
- uploading the images again on the server-> same error

When I type in the URL of the images they load fine in the browser. They are all around 200 KB in size, so no big images either.

Any ideas what might cause this error and how I could fix it/work around it?

Chris D

XenForo developer
Staff member
It's possible that something is happening which is causing PHP to crash and resume the request from its previous point, which would mean the process would never progress.

Can you please check your web server or PHP error logs and maybe MySQL error logs to see if there's any hint of this falling over at this particular point?


Active member
Hi, thanks for your response.

This is getting more difficult than I thought it would be :S. I asked my hoster for the MySQL- and PHP-Log. I won't get the MySQL log from him, but I have access to the PHP log, though it only logs critical errors and this one wasn't in there, so I had to change it to display all (E_All) and in less than 12 hours the currently running IPB 3.4 literally exploded the error log with notices, forcing my hoster to disable it, so I can`t use the PHP-Error log either :(.

A good thing, after 24 hours I was able to progress the conversion by deleting the image from the xenforo database and it started running again - even though I already tried this one before -, but the browser lost connection to the script in the night and I wasn't able to continue it because it wasn't progressing anymore. It was running through that image on my WAMP server, and because it later continues running through on the testboard on my normal server, I think the image is fine, probably just a problem with MySQL, which cleared itself after some time of doing nothing, I would assume.

Now I'm going to start at 0 again with the conversion of the gallery, hopefully it will work better this time.

Just one question: The gallery is a bit larger - 95k images -, so it takes several days to complete. My IP changes once a day. Does this log me out from ACP and stops the script from continuing or does it continue running even when my session/IP expired?

Jake Bunce

XenForo moderator
Staff member
There is some tolerance for IP changes in the session handler. I believe it only enforces the first 3 octets for IPv4, and the first 64 bits for IPv6. So basically if your IP changes but you are still on the same network then you should be fine.