masugadesign/link-vault-craft-cms

Exception error upon upgrade to Craft 3.6

Closed this issue · 1 comments

Describe the bug
I've upgraded from 3.6.0 RC3 to 3.6.7. Composer update went fine. When I go to the admin page, I got this exception error

Craft Version & Installed Plugin Version
Craft: 3.6.7
Plugin: 3.1.4

To Reproduce
Steps to reproduce the behavior:

  1. Go to '/admin/dashboard'

Screenshots

Integrity constraint violation – yii\db\IntegrityException
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'type' in where clause is ambiguous
The SQL being executed was: SELECT `fileName`, COUNT(*) AS `census`
FROM `linkvault_downloads` `d`
INNER JOIN `elements` `e` ON d.id=e.id
WHERE (`type`='Download') AND (`e`.`dateDeleted` IS null)
GROUP BY `fileName`
ORDER BY COUNT(*) DESC
LIMIT 10

Error Info: Array
(
    [0] => 23000
    [1] => 1052
    [2] => Column 'type' in where clause is ambiguous
)

↵
Caused by: PDOException
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'type' in where clause is ambiguous

in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/yiisoft/yii2/db/Command.php at line 1299

    1. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/yiisoft/yii2/db/Schema.php at line 678
    669670671672673674675676677678679680681682683684685686687

     
            $exceptionClass = '\yii\db\Exception';
            foreach ($this->exceptionMap as $error => $class) {
                if (strpos($e->getMessage(), $error) !== false) {
                    $exceptionClass = $class;
                }
            }
            $message = $e->getMessage() . "\nThe SQL being executed was: $rawSql";
            $errorInfo = $e instanceof \PDOException ? $e->errorInfo : null;
            return new $exceptionClass($message, $errorInfo, $e->getCode(), $e);
        }
     
        /**
         * Returns a value indicating whether a SQL statement is for read purpose.
         * @param string $sql the SQL statement
         * @return bool whether a SQL statement is for read purpose.
         */
        public function isReadQuery($sql)
        {

    2. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/yiisoft/yii2/db/Command.php at line 1304 – yii\db\Schema::convertException(PDOException, 'SELECT `fileName`, COUNT(*) AS `...')
    3. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/yiisoft/yii2/db/Command.php at line 1165 – yii\db\Command::internalExecute('SELECT `fileName`, COUNT(*) AS `...')
    4. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/yiisoft/yii2/db/Command.php at line 407 – yii\db\Command::queryInternal('fetchAll', null)
    5. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/yiisoft/yii2/db/Query.php at line 248 – yii\db\Command::queryAll()
    6. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/craftcms/cms/src/db/Query.php at line 152 – yii\db\Query::all(null)
    146147148149150151152153154155156157158

        /**
         * @inheritdoc
         */
        public function all($db = null)
        {
            try {
                return parent::all($db);
            } catch (QueryAbortedException $e) {
                return [];
            }
        }
     
        /**

    7. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/masugadesign/linkvault/src/services/GeneralService.php at line 228 – craft\db\Query::all()
    222223224225226227228229230231232233234

                    ->join('INNER JOIN', '{{%elements}} AS e', 'd.id=e.id')
                    ->where($criteria)
                    ->andWhere(['is', 'e.dateDeleted', new \yii\db\Expression('null')])
                    ->groupBy($columnName)
                    ->orderBy($order)
                    ->limit($limit)
                    ->all();
            return $results;
        }
     
        /**
         * Log a download to the linkvault_downloads table.
         * @param array $recordData

    8. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/masugadesign/linkvault/src/widgets/LinkVaultTopDownloadsWidget.php at line 31 – Masuga\LinkVault\services\GeneralService::groupCount('fileName', ['type' => 'Download'], 'COUNT(*) desc', 10)
    252627282930313233343536

        {
            $criteria = array(
                'type' => 'Download',
            );
            $order = 'COUNT(*) desc';
            $limit = 10;
            $rows = LinkVault::getInstance()->general->groupCount('fileName', $criteria, $order, $limit);
            return Craft::$app->view->renderTemplate('linkvault/_widgets/top-downloads', array(
                'rows' => $rows
            ));
        }
    }

    9. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/craftcms/cms/src/controllers/DashboardController.php at line 508 – Masuga\LinkVault\widgets\LinkVaultTopDownloadsWidget::getBodyHtml()
    502503504505506507508509510511512513514

        private function _getWidgetInfo(WidgetInterface $widget)
        {
            $view = $this->getView();
            $namespace = $view->getNamespace();
     
            // Get the body HTML
            $widgetBodyHtml = $widget->getBodyHtml();
     
            if ($widgetBodyHtml === false) {
                return false;
            }
     
            // Get the settings HTML + JS

    10. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/craftcms/cms/src/controllers/DashboardController.php at line 107 – craft\controllers\DashboardController::_getWidgetInfo(Masuga\LinkVault\widgets\LinkVaultTopDownloadsWidget)
    101102103104105106107108109110111112113

            $variables['widgets'] = [];
            $widgets = $dashboardService->getAllWidgets();
            $allWidgetJs = '';
     
            foreach ($widgets as $widget) {
                $view->startJsBuffer();
                $info = $this->_getWidgetInfo($widget);
                $widgetJs = $view->clearJsBuffer(false);
     
                if ($info === false) {
                    continue;
                }
     

    11. craft\controllers\DashboardController::actionIndex()
    12. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/yiisoft/yii2/base/InlineAction.php at line 57 – call_user_func_array([craft\controllers\DashboardController, 'actionIndex'], [])
    13. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/yiisoft/yii2/base/Controller.php at line 181 – yii\base\InlineAction::runWithParams([])
    14. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/craftcms/cms/src/web/Controller.php at line 190 – yii\base\Controller::runAction('index', [])
    184185186187188189190191192193194195196

        /**
         * @inheritdoc
         */
        public function runAction($id, $params = [])
        {
            try {
                return parent::runAction($id, $params);
            } catch (\Throwable $e) {
                if ($this->request->getAcceptsJson()) {
                    Craft::$app->getErrorHandler()->logException($e);
                    if (!YII_DEBUG && !$e instanceof UserException) {
                        $message = Craft::t('app', 'A server error occurred.');
                    } else {

    15. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/yiisoft/yii2/base/Module.php at line 534 – craft\web\Controller::runAction('index', [])
    16. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/craftcms/cms/src/web/Application.php at line 274 – yii\base\Module::runAction('dashboard/index', [])
    268269270271272273274275276277278279280

         * @param string $route
         * @param array $params
         * @return Response|null The result of the action, normalized into a Response object
         */
        public function runAction($route, $params = [])
        {
            $result = parent::runAction($route, $params);
     
            if ($result !== null) {
                if ($result instanceof Response) {
                    return $result;
                }
     

    17. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/yiisoft/yii2/web/Application.php at line 104 – craft\web\Application::runAction('dashboard/index', [])
    18. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/craftcms/cms/src/web/Application.php at line 259 – yii\web\Application::handleRequest(craft\web\Request)
    253254255256257258259260261262263264265

            if (($response = $this->_processActionRequest($request)) !== null) {
                return $response;
            }
     
            // If we're still here, finally let Yii do it's thing.
            try {
                return parent::handleRequest($request);
            } catch (\Throwable $e) {
                $this->_unregisterDebugModule();
                throw $e;
            }
        }
     

    19. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/vendor/yiisoft/yii2/base/Application.php at line 392 – craft\web\Application::handleRequest(craft\web\Request)
    20. in /Volumes/SanDisk1TB/Sites/OBFUSCATED/public/index.php at line 22 – yii\base\Application::run()
    16171819202122

    }
     
    // Load and run Craft
    define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
    /** @var craft\web\Application $app */
    $app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
    $app->run();

    21. in /Users/rudy/.composer/vendor/laravel/valet/server.php at line 219 – require('/Volumes/SanDisk1TB/Sites/resour...')
    213214215216217218219

     
        show_valet_404();
    }
     
    chdir(dirname($frontControllerPath));
     
    require $frontControllerPath;

Desktop (please complete the following information):

  • OS: [e.g. iOS] MacOS 10.15.7
  • Browser [e.g. chrome, safari] Firefox
  • Version [e.g. 22] 85.0.2

I just released Link Vault 3.1.7 with a fix for this. I noticed in my testing that Craft was ignoring my preferred widget column span setting for the widget. If you run into that as well, replace the colspan value in the settings DB column. I don't know where those "settings" came from but I think it is because the widget class used to have a property that set a default colspan value and apparently that value overrides what the user configures in Craft.

Screen Shot 2021-02-26 at 9 56 07 AM