putyourlightson/craft-sherlock

Error on upgraded Craft install: `column "siteId" does not exist`

Closed this issue · 1 comments

Describe the bug

We just updated a Craft install from 3.4.30 to 3.6.15—I'm hoping it's simply an issue with jumping so many version bumps, but (that I can see) it doesn't seem to be the case.

Versions

  • Plugin version: pre-upgrade: 2.2.2, now on 3.1.2
  • Craft version: pre-upgrade: 3.4.30, now on 3.6.15

Checking out the blame in ScansService.php:62 just shows the initial multisite support changes. Sherlock was running alright in 3.4.30 with Multisite, so I'm assuming it should be alright in the latest, but let me know if that's not the case!

Here's the trace:

PDOException: SQLSTATE[42703]: Undefined column: 7 ERROR:  column "siteId" does not exist
LINE 3: WHERE ("siteId"=$1) AND (id > $2)
               ^ in /app/vendor/yiisoft/yii2/db/Command.php:1302
Stack trace:
#0 /app/vendor/yiisoft/yii2/db/Command.php(1302): PDOStatement->execute()
#1 /app/vendor/yiisoft/yii2/db/Command.php(1168): yii\db\Command->internalExecute('SELECT *\nFROM "...')
#2 /app/vendor/yiisoft/yii2/db/Command.php(410): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /app/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Command->queryAll()
#4 /app/vendor/yiisoft/yii2/db/ActiveQuery.php(133): yii\db\Query->all(NULL)
#5 /app/vendor/putyourlightson/craft-sherlock/src/services/ScansService.php(62): yii\db\ActiveQuery->all()
#6 /app/vendor/putyourlightson/craft-sherlock/src/variables/SherlockVariable.php(43): putyourlightson\sherlock\services\ScansService->getAllScans()
#7 /app/vendor/twig/twig/src/Extension/CoreExtension.php(1511): putyourlightson\sherlock\variables\SherlockVariable->getAllScans()
#8 /app/vendor/craftcms/cms/src/helpers/Template.php(106): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(putyourlightson\sherlock\variables\SherlockVariable), 'getAllScans', Array, 'method', false, false)
#9 /app/storage/runtime/compiled_templates/3a/3a7367217573522e2ffd76492aa48b69367cae4ce46b7ec497630199f5834dbd.php(102): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(putyourlightson\sherlock\variables\SherlockVariable), 'getAllScans', Array, 'method')
#10 /app/vendor/twig/twig/src/Template.php(182): __TwigTemplate_a9f1d457e494f706ea1cec5f2a8e924ce3dceb79e338563d4700eafed5226bca->block_content(Array, Array)
#11 /app/storage/runtime/compiled_templates/02/021f86db685c370f546a94efc2d982f0a58acfb30c2fa3f6f5a1921ed628c1ab.php(505): Twig\Template->displayBlock('content', Array, Array)
#12 /app/vendor/twig/twig/src/Template.php(182): __TwigTemplate_7b606482394e1467516575dbe664879a12c30ce33f854a6a8895e611ed1f9078->block_main(Array, Array)
#13 /app/storage/runtime/compiled_templates/02/021f86db685c370f546a94efc2d982f0a58acfb30c2fa3f6f5a1921ed628c1ab.php(324): Twig\Template->displayBlock('main', Array, Array)
#14 /app/vendor/twig/twig/src/Template.php(182): __TwigTemplate_7b606482394e1467516575dbe664879a12c30ce33f854a6a8895e611ed1f9078->block_body(Array, Array)
#15 /app/storage/runtime/compiled_templates/d6/d6bfa0db8ff79c36dff6dcc17b3c72e7d17cbebc491d45e79658eee2d2868ee8.php(90): Twig\Template->displayBlock('body', Array, Array)
#16 /app/vendor/twig/twig/src/Template.php(405): __TwigTemplate_1e686fbaaa0d7ee8d8634c69385bbe71aca5baedcda606bd0f64c7e53ce5368f->doDisplay(Array, Array)
#17 /app/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#18 /app/storage/runtime/compiled_templates/4b/4b1053da30d7526fd118036e973e0f742d56a0a8d16bf01baf6141777a68fb91.php(56): Twig\Template->display(Array, Array)
#19 /app/vendor/twig/twig/src/Template.php(405): __TwigTemplate_02e901dbeca2f3ca5784aa791226cf443dcfd3a2a1e5335fb560e69f5237444f->doDisplay(Array, Array)
#20 /app/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#21 /app/storage/runtime/compiled_templates/02/021f86db685c370f546a94efc2d982f0a58acfb30c2fa3f6f5a1921ed628c1ab.php(166): Twig\Template->display(Array, Array)
#22 /app/vendor/twig/twig/src/Template.php(405): __TwigTemplate_7b606482394e1467516575dbe664879a12c30ce33f854a6a8895e611ed1f9078->doDisplay(Array, Array)
#23 /app/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#24 /app/storage/runtime/compiled_templates/74/74d5015bdac6f1828f31d66be537e8efb5446a780de5c634999076e9bdf32215.php(63): Twig\Template->display(Array, Array)
#25 /app/vendor/twig/twig/src/Template.php(405): __TwigTemplate_619d9d69ec369eac51c6cf36b989a9657a060819d29d336716d6d7d17467cc43->doDisplay(Array, Array)
#26 /app/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#27 /app/storage/runtime/compiled_templates/3a/3a7367217573522e2ffd76492aa48b69367cae4ce46b7ec497630199f5834dbd.php(54): Twig\Template->display(Array, Array)
#28 /app/vendor/twig/twig/src/Template.php(405): __TwigTemplate_a9f1d457e494f706ea1cec5f2a8e924ce3dceb79e338563d4700eafed5226bca->doDisplay(Array, Array)
#29 /app/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#30 /app/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
#31 /app/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#32 /app/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#33 /app/vendor/craftcms/cms/src/web/View.php(389): Twig\Environment->render('sherlock/index', Array)
#34 /app/vendor/craftcms/cms/src/web/View.php(450): craft\web\View->renderTemplate('sherlock/index', Array)
#35 /app/vendor/craftcms/cms/src/web/Controller.php(257): craft\web\View->renderPageTemplate('sherlock/index', Array, 'cp')
#36 /app/vendor/putyourlightson/craft-sherlock/src/controllers/ScansController.php(62): craft\web\Controller->renderTemplate('sherlock/index')
#37 [internal function]: putyourlightson\sherlock\controllers\ScansController->actionIndex(NULL)
#38 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#39 /app/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#40 /app/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('index', Array)
#41 /app/vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('index', Array)
#42 /app/vendor/craftcms/cms/src/web/Application.php(278): yii\base\Module->runAction('sherlock/scans/...', Array)
#43 /app/vendor/yiisoft/yii2/web/Application.php(104): craft\web\Application->runAction('sherlock/scans/...', Array)
#44 /app/vendor/craftcms/cms/src/web/Application.php(263): yii\web\Application->handleRequest(Object(craft\web\Request))
#45 /app/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#46 /app/web/index.php(24): yii\base\Application->run()
#47 {main}

Next yii\db\Exception: SQLSTATE[42703]: Undefined column: 7 ERROR:  column "siteId" does not exist
LINE 3: WHERE ("siteId"=$1) AND (id > $2)
               ^
The SQL being executed was: SELECT *
FROM "craft_sherlock"
WHERE ("siteId"=1) AND (id > 0)
ORDER BY "dateCreated" DESC in /app/vendor/yiisoft/yii2/db/Schema.php:678
Stack trace:
#0 /app/vendor/yiisoft/yii2/db/Command.php(1307): yii\db\Schema->convertException(Object(PDOException), 'SELECT *\nFROM "...')
#1 /app/vendor/yiisoft/yii2/db/Command.php(1168): yii\db\Command->internalExecute('SELECT *\nFROM "...')
#2 /app/vendor/yiisoft/yii2/db/Command.php(410): yii\db\Command->queryInternal('fetchAll', NULL)
#3 /app/vendor/yiisoft/yii2/db/Query.php(249): yii\db\Command->queryAll()
#4 /app/vendor/yiisoft/yii2/db/ActiveQuery.php(133): yii\db\Query->all(NULL)
#5 /app/vendor/putyourlightson/craft-sherlock/src/services/ScansService.php(62): yii\db\ActiveQuery->all()
#6 /app/vendor/putyourlightson/craft-sherlock/src/variables/SherlockVariable.php(43): putyourlightson\sherlock\services\ScansService->getAllScans()
#7 /app/vendor/twig/twig/src/Extension/CoreExtension.php(1511): putyourlightson\sherlock\variables\SherlockVariable->getAllScans()
#8 /app/vendor/craftcms/cms/src/helpers/Template.php(106): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(putyourlightson\sherlock\variables\SherlockVariable), 'getAllScans', Array, 'method', false, false)
#9 /app/storage/runtime/compiled_templates/3a/3a7367217573522e2ffd76492aa48b69367cae4ce46b7ec497630199f5834dbd.php(102): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(putyourlightson\sherlock\variables\SherlockVariable), 'getAllScans', Array, 'method')
#10 /app/vendor/twig/twig/src/Template.php(182): __TwigTemplate_a9f1d457e494f706ea1cec5f2a8e924ce3dceb79e338563d4700eafed5226bca->block_content(Array, Array)
#11 /app/storage/runtime/compiled_templates/02/021f86db685c370f546a94efc2d982f0a58acfb30c2fa3f6f5a1921ed628c1ab.php(505): Twig\Template->displayBlock('content', Array, Array)
#12 /app/vendor/twig/twig/src/Template.php(182): __TwigTemplate_7b606482394e1467516575dbe664879a12c30ce33f854a6a8895e611ed1f9078->block_main(Array, Array)
#13 /app/storage/runtime/compiled_templates/02/021f86db685c370f546a94efc2d982f0a58acfb30c2fa3f6f5a1921ed628c1ab.php(324): Twig\Template->displayBlock('main', Array, Array)
#14 /app/vendor/twig/twig/src/Template.php(182): __TwigTemplate_7b606482394e1467516575dbe664879a12c30ce33f854a6a8895e611ed1f9078->block_body(Array, Array)
#15 /app/storage/runtime/compiled_templates/d6/d6bfa0db8ff79c36dff6dcc17b3c72e7d17cbebc491d45e79658eee2d2868ee8.php(90): Twig\Template->displayBlock('body', Array, Array)
#16 /app/vendor/twig/twig/src/Template.php(405): __TwigTemplate_1e686fbaaa0d7ee8d8634c69385bbe71aca5baedcda606bd0f64c7e53ce5368f->doDisplay(Array, Array)
#17 /app/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#18 /app/storage/runtime/compiled_templates/4b/4b1053da30d7526fd118036e973e0f742d56a0a8d16bf01baf6141777a68fb91.php(56): Twig\Template->display(Array, Array)
#19 /app/vendor/twig/twig/src/Template.php(405): __TwigTemplate_02e901dbeca2f3ca5784aa791226cf443dcfd3a2a1e5335fb560e69f5237444f->doDisplay(Array, Array)
#20 /app/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#21 /app/storage/runtime/compiled_templates/02/021f86db685c370f546a94efc2d982f0a58acfb30c2fa3f6f5a1921ed628c1ab.php(166): Twig\Template->display(Array, Array)
#22 /app/vendor/twig/twig/src/Template.php(405): __TwigTemplate_7b606482394e1467516575dbe664879a12c30ce33f854a6a8895e611ed1f9078->doDisplay(Array, Array)
#23 /app/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#24 /app/storage/runtime/compiled_templates/74/74d5015bdac6f1828f31d66be537e8efb5446a780de5c634999076e9bdf32215.php(63): Twig\Template->display(Array, Array)
#25 /app/vendor/twig/twig/src/Template.php(405): __TwigTemplate_619d9d69ec369eac51c6cf36b989a9657a060819d29d336716d6d7d17467cc43->doDisplay(Array, Array)
#26 /app/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#27 /app/storage/runtime/compiled_templates/3a/3a7367217573522e2ffd76492aa48b69367cae4ce46b7ec497630199f5834dbd.php(54): Twig\Template->display(Array, Array)
#28 /app/vendor/twig/twig/src/Template.php(405): __TwigTemplate_a9f1d457e494f706ea1cec5f2a8e924ce3dceb79e338563d4700eafed5226bca->doDisplay(Array, Array)
#29 /app/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#30 /app/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
#31 /app/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#32 /app/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#33 /app/vendor/craftcms/cms/src/web/View.php(389): Twig\Environment->render('sherlock/index', Array)
#34 /app/vendor/craftcms/cms/src/web/View.php(450): craft\web\View->renderTemplate('sherlock/index', Array)
#35 /app/vendor/craftcms/cms/src/web/Controller.php(257): craft\web\View->renderPageTemplate('sherlock/index', Array, 'cp')
#36 /app/vendor/putyourlightson/craft-sherlock/src/controllers/ScansController.php(62): craft\web\Controller->renderTemplate('sherlock/index')
#37 [internal function]: putyourlightson\sherlock\controllers\ScansController->actionIndex(NULL)
#38 /app/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#39 /app/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#40 /app/vendor/craftcms/cms/src/web/Controller.php(190): yii\base\Controller->runAction('index', Array)
#41 /app/vendor/yiisoft/yii2/base/Module.php(534): craft\web\Controller->runAction('index', Array)
#42 /app/vendor/craftcms/cms/src/web/Application.php(278): yii\base\Module->runAction('sherlock/scans/...', Array)
#43 /app/vendor/yiisoft/yii2/web/Application.php(104): craft\web\Application->runAction('sherlock/scans/...', Array)
#44 /app/vendor/craftcms/cms/src/web/Application.php(263): yii\web\Application->handleRequest(Object(craft\web\Request))
#45 /app/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#46 /app/web/index.php(24): yii\base\Application->run()
#47 {main}
Additional Information:
Array
(
    [0] => 42703
    [1] => 7
    [2] => ERROR:  column "siteId" does not exist
LINE 3: WHERE ("siteId"=$1) AND (id > $2)
               ^
)

It looks like the migration that adds the site ID was not correctly run, so I've fixed in 454af03 and released in version 3.1.3.