Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SQL syntax error due to incorrect parameter #18550

Closed
tsteur opened this issue Dec 29, 2021 · 1 comment · Fixed by #19994
Closed

Fix SQL syntax error due to incorrect parameter #18550

tsteur opened this issue Dec 29, 2021 · 1 comment · Fixed by #19994
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Dec 29, 2021

Maybe an empty array was passed to deleteInvalidations method in which case it would need to return directly again?

Error: {"message":"SQLSTATE[42000]: Syntax error or access violation: 1064 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 1","file":"libs/Zend/Db/Statement/Pdo.php","line":236,"backtrace":" on libs/Zend/Db/Statement/Pdo.php(236)\n#0 libs/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)\n#1 libs/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)\n#2 libs/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('DELETE FROM ar...', Array)\n#3 core\/Db\/Adapter\/Pdo\/Mysql.php(310): Zend_Db_Adapter_Pdo_Abstract->query('DELETE FROM ar...', Array)\n#4 core/Db.php(280): Piwik\Db\Adapter\Pdo\Mysql->query('DELETE FROM ar...', Array)\n#5 core\/DataAccess\/Model.php(801): Piwik\\Db::query('DELETE FROM ar...')\n#6 core/CronArchive/QueueConsumer.php(260): Piwik\DataAccess\Model->deleteInvalidations(Array)\n#7 core/CronArchive.php(375): Piwik\CronArchive\QueueConsumer->getNextArchivesToProcess()\n#8 core/CronArchive.php(263): Piwik\CronArchive->run()\n#9 core/Access.php(661): Piwik\CronArchive->Piwik\{closure}()\n#10 core/CronArchive.php(269): Piwik\Access::doAsSuperUser(Object(Closure))\n#11 plugins/CoreConsole/Commands/CoreArchiver.php(32): Piwik\CronArchive->main()\n#12 vendor/symfony/console/Symfony/Component/Console/Command/Command.php(257): Piwik\Plugins\CoreConsole\Commands\CoreArchiver->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))\n#13 vendor/symfony/console/Symfony/Component/Console/Application.php(874): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))\n#14 vendor/symfony/console/Symfony/Component/Console/Application.php(195): Symfony\Component\Console\Application->doRunCommand(Object(Piwik\Plugins\CoreConsole\Commands\CoreArchiver), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))\n#15 [internal function]: Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))\n#16 core/Console.php(130): call_user_func(Array, Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))\n#17 core/Access.php(670): Piwik\Console->Piwik\{closure}()\n#18 core/Console.php(131): Piwik\Access::doAsSuperUser(Object(Closure))\n#19 core/Console.php(82): Piwik\Console->doRunImpl(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))\n#20 vendor/symfony/console/Symfony/Component/Console/Application.php(126): Piwik\Console->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))\n#21 console(32)

@tsteur tsteur added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label Dec 29, 2021
@sgiehl
Copy link
Member

sgiehl commented Nov 11, 2022

Just cam across this issue and had a quick look at the code. I guess the problem might be here:

$alreadyInProgressId = $this->model->isArchiveAlreadyInProgress($invalidatedArchive);
if ($alreadyInProgressId) {
$this->addInvalidationToExclude($invalidatedArchive);
if ($alreadyInProgressId < $invalidatedArchive['idinvalidation']) {
$this->logger->debug("Skipping invalidated archive {$invalidatedArchive['idinvalidation']}, invalidation already in progress. Since in progress is older, not removing invalidation.");
} else if ($alreadyInProgressId > $invalidatedArchive['idinvalidation']) {
$this->logger->debug("Skipping invalidated archive {$invalidatedArchive['idinvalidation']}, invalidation already in progress. Since in progress is newer, will remove invalidation.");
$this->model->deleteInvalidations([$invalidatedArchive['idinvalidation']]);
}
continue;
}

$this->model->deleteInvalidations() expects to receive the full array and not the ids only. Will set up a quick PR to fix that.

@sgiehl sgiehl added Bug For errors / faults / flaws / inconsistencies etc. and removed Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. labels Nov 11, 2022
@sgiehl sgiehl self-assigned this Nov 11, 2022
@sgiehl sgiehl added this to the 4.12.4 milestone Nov 11, 2022
@elabuwa elabuwa changed the title Fatal error because SQL syntax error in DataAccess Model Fix SQL syntax error due to incorrect parameter Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants