Fixed InvalidQueryException when trying to run an importer with numeric import log table

Jeremy P

XenForo developer
Staff member
Affected version
2.0.0
Per the title, if you try to run an importer and you enter a numeric import log table name (ex: 20171211) during configuration, an exception is thrown.
 
Could you clarify what the actual exception was, including error and stack trace?

This isn't expected as we quote the table name with back ticks and there shouldn't be anything particular that should prevent this AFAIK.
 
@Chris D I've reproduced this:

XF\Db\InvalidQueryException: MySQL statement prepare error [1064]: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '20171215 (`content_type`, `old_id`, `new_id`) VALUES (?, ?, ?) ON DUPLICATE KEY ' at line 1 in src/XF/Db/AbstractStatement.php at line 212

  1. XF\Db\AbstractStatement->getException() insrc/XF/Db/Mysqli/Statement.php at line 174
  2. XF\Db\Mysqli\Statement->getException() insrc/XF/Db/Mysqli/Statement.php at line 35
  3. XF\Db\Mysqli\Statement->prepare() in src/XF/Db/Mysqli/Statement.phpat line 46
  4. XF\Db\Mysqli\Statement->execute() in src/XF/Db/AbstractAdapter.phpat line 69
  5. XF\Db\AbstractAdapter->query() in src/XF/Db/AbstractAdapter.php at line 145
  6. XF\Db\AbstractAdapter->insert() in src/XF/Import/Log.php at line 117
  7. XF\Import\Log->log() in src/XF/Import/DataManager.php at line 116
  8. XF\Import\DataManager->log() insrc/XF/Import/Data/AbstractData.php at line 105
  9. XF\Import\Data\AbstractData->save() insrc/addons/SV/ContentRatings/Import/Importer/PostRatings.php at line215
  10. SV\ContentRatings\Import\Importer\PostRatings->stepRatingTypeCategories() in src/XF/Import/Runner.php at line 161
  11. XF\Import\Runner->runStep() in src/XF/Import/Runner.php at line 75
  12. XF\Import\Runner->run() in src/XF/Admin/Controller/Import.php at line231
  13. XF\Admin\Controller\Import->actionRun() insrc/XF/Mvc/Dispatcher.php at line 249
  14. XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line88
  15. XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line41
  16. XF\Mvc\Dispatcher->run() in src/XF/App.php at line 1879
  17. XF\App->run() in src/XF.php at line 328
  18. XF::runApp() in admin.php at line 13

XF\Db\AbstractAdapter::insert doesn't quote with backticks the table name.

PHP:
$res = $this->query(
   "$keyword $modifier INTO $table (" . implode(', ', $cols) . ') VALUES '
   . '(' . implode(', ', $sqlValues) . ')'
   . ($onDupe ? " ON DUPLICATE KEY UPDATE $onDupe" : ''),
   $bind
);

This applies to insertBulk/delete/update methods as well
 
Right. It’s on the insert. I assumed it was on creation of the table which is what I was looking at.
 
Top Bottom