1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Resolved Bug Reports' started by DRE, Nov 6, 2013.

  1. DRE

    DRE Well-Known Member

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

    Admin Control Panel - XenForo
    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

    1. Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115
    2. Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381
    3. Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478
    4. Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 808
    5. Zend_Db_Adapter_Abstract->fetchPairs() in XenForo/Importer/XenForo.php at line 2232
    6. XenForo_Importer_XenForo->stepAttachments() in XenForo/Importer/Abstract.php at line 77
    7. XenForo_Importer_Abstract->runStep() in XenForo/ControllerAdmin/Import.php at line 195
    8. XenForo_ControllerAdmin_Import->_runStep() in XenForo/ControllerAdmin/Import.php at line 143
    9. XenForo_ControllerAdmin_Import->actionImport() in XenForo/FrontController.php at line 337
    10. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
    11. XenForo_FrontController->run() in /home/me/public_html/admin.php at line 13
     
  2. DRE

    DRE Well-Known Member

  3. Amaury

    Amaury Well-Known Member

    Then it would be an issue with that resource, not XenForo?
     
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    With both add-ons disabled, does the error still occur?
     
  5. xfrocks

    xfrocks Well-Known Member

    Line 2232 of xenforo/library/XenForo/Importer/XenForo.php

    PHP:
    $contentItems $db->fetchPairs("
    SELECT 
    $sqlIdName, message
    FROM 
    $sqlTableName
    WHERE 
    $sqlIdName IN ("$db->quote($contentIdMap) .")
    "
    );
    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:

    PHP:
    if (!empty($contentIdMap))
    {
    $contentItems $db->fetchPairs("
    SELECT 
    $sqlIdName, message
    FROM 
    $sqlTableName
    WHERE 
    $sqlIdName IN ("$db->quote($contentIdMap) .")
    "
    );
    }
    else
    {
    $contentItems = array();
    }
    TL;DR: It's a bug in the importer (not an add-on problem).
     
    Adam Howard and DRE like this.
  6. Mick West

    Mick West Well-Known Member

    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).
     
  7. xfrocks

    xfrocks Well-Known Member

    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 ;)
     
  8. DRE

    DRE Well-Known Member

    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?
     
  9. xfrocks

    xfrocks Well-Known Member

    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.
     
  10. DRE

    DRE Well-Known Member

    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 - XenForo
    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

    1. Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115
    2. Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381
    3. Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478
    4. Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 808
    5. Zend_Db_Adapter_Abstract->fetchPairs() in XenForo/Importer/XenForo.php at line 2232
    6. XenForo_Importer_XenForo->stepAttachments() in XenForo/Importer/Abstract.php at line 77
    7. XenForo_Importer_Abstract->runStep() in XenForo/ControllerAdmin/Import.php at line 195
    8. XenForo_ControllerAdmin_Import->_runStep() in XenForo/ControllerAdmin/Import.php at line 143
    9. XenForo_ControllerAdmin_Import->actionImport() in XenForo/FrontController.php at line 337
    10. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
    11. XenForo_FrontController->run() in /home/me/public_html/test/admin.php at line 13

    Gonna do that code edit now.
     
    Last edited: Nov 7, 2013
  11. DRE

    DRE Well-Known Member

    Only posting that to let you know that I got further with the import after following the other directions.
     
  12. DRE

    DRE Well-Known Member

    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

    1. Zend_Db_Statement_Mysqli->_prepare() in Zend/Db/Statement.php at line 115
    2. Zend_Db_Statement->__construct() in Zend/Db/Adapter/Mysqli.php at line 381
    3. Zend_Db_Adapter_Mysqli->prepare() in Zend/Db/Adapter/Abstract.php at line 478
    4. Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 808
    5. Zend_Db_Adapter_Abstract->fetchPairs() in XenForo/Importer/XenForo.php at line 2232
    6. XenForo_Importer_XenForo->stepAttachments() in XenForo/Importer/Abstract.php at line 77
    7. XenForo_Importer_Abstract->runStep() in XenForo/ControllerAdmin/Import.php at line 195
    8. XenForo_ControllerAdmin_Import->_runStep() in XenForo/ControllerAdmin/Import.php at line 143
    9. XenForo_ControllerAdmin_Import->actionImport() in XenForo/FrontController.php at line 337
    10. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
    11. XenForo_FrontController->run() in /home/me/public_html/test/admin.php at line 13
     
  13. xfrocks

    xfrocks Well-Known Member

    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.
     
    principia and DRE like this.
  14. DRE

    DRE Well-Known Member

    Thanks but I'm just going to drop it for now.
     
  15. Mike

    Mike XenForo Developer Staff Member

    I've added a similar check to prevent this error.

    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.
     
    xfrocks and DRE like this.

Share This Page