Fixed Xenforo 1.2 Beta to Xenforo Importer Error (Attached Files)

Got this error when importing attachments. Everything else had ran fine up to that point.

Admin Control Panel - XenForoServer Error
Mysqli prepare 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 ')' at line 3

Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115

Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381

Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478

Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 808

Zend_Db_Adapter_Abstract->fetchPairs() in XenForo/Importer/XenForo.php at line 2232

XenForo_Importer_XenForo->stepAttachments() in XenForo/Importer/Abstract.php at line 77

XenForo_Importer_Abstract->runStep() in XenForo/ControllerAdmin/Import.php at line 195

XenForo_ControllerAdmin_Import->_runStep() in XenForo/ControllerAdmin/Import.php at line 143

XenForo_ControllerAdmin_Import->actionImport() in XenForo/FrontController.php at line 337

XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134

XenForo_FrontController->run() in /home/me/public_html/admin.php at line 13

I guess the array `$contentIdMap` is empty (result of XenForo_Model_Import::getImportContentMap) and caused the SQL error. A simple empty check should help you go through with the import. Replace the above block of code with these and try again:

Is there a reason though that $contentIdMap would be empty normally? It seems possible that I'm doing something wrong with the way I create attachments in MetaMirror. (or BD AttachmentStore).

Click to expand...

I don't know really. I find it a bit strange because `$attachments` was not queried with any kind of keys so array_keys will simply array indeces. I could be wrong though...

Btw, @DRE, you installed [bd] Attachment Store on the source forum or on the target forum? If you have it installed in source forum, you need to rebuild attachment with default mode to move all files back into their original location. Or your import will fail

I don't know really. I find it a bit strange because `$attachments` was not queried with any kind of keys so array_keys will simply array indeces. I could be wrong though...

Btw, @DRE, you installed [bd] Attachment Store on the source forum or on the target forum? If you have it installed in source forum, you need to rebuild attachment with default mode to move all files back into their original location. Or your import will fail

Click to expand...

Source forum and no I didn't do that when I ran the import. I'll try again. Do I still use your code edit?

Source forum and no I didn't do that when I ran the import. I'll try again. Do I still use your code edit?

Click to expand...

If you didn't rebuild it, the importer will fail without any error. It will just ignore the attachments in external data/Amazon S3/FTP (it will import attachments in default just fine). You still need to figure out what caused the current error.

Alright so I did all the steps listed in this thread EXCEPT the code edit @xfrocks posted and this is the error.

Admin Control Panel - XenForoServer Error
Mysqli prepare 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 ')' at line 3

Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115

Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381

Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478

Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 808

Zend_Db_Adapter_Abstract->fetchPairs() in XenForo/Importer/XenForo.php at line 2232

XenForo_Importer_XenForo->stepAttachments() in XenForo/Importer/Abstract.php at line 77

XenForo_Importer_Abstract->runStep() in XenForo/ControllerAdmin/Import.php at line 195

XenForo_ControllerAdmin_Import->_runStep() in XenForo/ControllerAdmin/Import.php at line 143

XenForo_ControllerAdmin_Import->actionImport() in XenForo/FrontController.php at line 337

XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134

XenForo_FrontController->run() in /home/me/public_html/test/admin.php at line 13

I did your code edit and it did not work. I did everything posted in this thread including close my main board and disabled every addon, no dice.

Server Error
Mysqli prepare 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 ')' at line 3

Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115

Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381

Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478

Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 808

Zend_Db_Adapter_Abstract->fetchPairs() in XenForo/Importer/XenForo.php at line 2232

XenForo_Importer_XenForo->stepAttachments() in XenForo/Importer/Abstract.php at line 77

XenForo_Importer_Abstract->runStep() in XenForo/ControllerAdmin/Import.php at line 195

XenForo_ControllerAdmin_Import->_runStep() in XenForo/ControllerAdmin/Import.php at line 143

XenForo_ControllerAdmin_Import->actionImport() in XenForo/FrontController.php at line 337

XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134

XenForo_FrontController->run() in /home/me/public_html/test/admin.php at line 13

Click to expand...

The error is still at 2232, if you did the edit, it should be line 2234. Are you sure you made the edit correctly? You probably want to upload the contents to some gist.github.com or similar and send the link to me. Should open a conversation for that to avoid copyright issue.

If I'm reading this code right, this error should only happen if the found attachments are all orphaned from their content. I'm not sure why that would happen, as attachments should generally be cleaned up if data is hard deleted, though I suppose it could be a throwback to 1.1 if a forum were deleted.