masugadesign / cp-filters-craft-cms

Add advanced element filtering to the Craft CMS control panel.
Other
16 stars 3 forks source link

Throws error on /admin/cpfilters #5

Closed ul8 closed 3 years ago

ul8 commented 4 years ago

After a fresh install of the plugin, first click on CPFilters menu item throws an exception.

My setup:

PHP version | 7.4.6 Linux 4.19.76-linuxkit PostgreSQL 11.6 Craft Pro 3.5.8

PDOException: SQLSTATE[42883]: Undefined function: 7 ERROR:  operator does not exist: integer ~~ unknown
LINE 3: WHERE "id" LIKE $1
                   ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts. in /var/www/html/vendor/yiisoft/yii2/db/Command.php:1293
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1293): PDOStatement->execute()
#1 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1159): yii\db\Command->internalExecute('SELECT "id"\nFRO...')
#2 /var/www/html/vendor/yiisoft/yii2/db/Command.php(444): yii\db\Command->queryInternal('fetchAll', 7)
#3 /var/www/html/vendor/yiisoft/yii2/db/Query.php(318): yii\db\Command->queryColumn()
#4 /var/www/html/vendor/craftcms/cms/src/db/Query.php(202): yii\db\Query->column(NULL)
#5 /var/www/html/vendor/craftcms/cms/src/elements/db/EntryQuery.php(926): craft\db\Query->column()
#6 /var/www/html/vendor/craftcms/cms/src/elements/db/EntryQuery.php(806): craft\elements\db\EntryQuery->_normalizeTypeId()
#7 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1326): craft\elements\db\EntryQuery->beforePrepare()
#8 /var/www/html/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare(Object(craft\db\pgsql\QueryBuilder))
#9 /var/www/html/vendor/yiisoft/yii2/db/Query.php(157): yii\db\QueryBuilder->build(Object(craft\elements\db\EntryQuery))
#10 /var/www/html/vendor/yiisoft/yii2/db/Query.php(478): yii\db\Query->createCommand(Object(craft\db\Connection))
#11 /var/www/html/vendor/craftcms/cms/src/db/Query.php(259): yii\db\Query->queryScalar('COUNT(*)', NULL)
#12 /var/www/html/vendor/yiisoft/yii2/db/Query.php(366): craft\db\Query->queryScalar('COUNT(*)', NULL)
#13 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1466): yii\db\Query->count('*', NULL)
#14 /var/www/html/vendor/twig/twig/src/Extension/CoreExtension.php(1499): craft\elements\db\ElementQuery->count()
#15 /var/www/html/vendor/craftcms/cms/src/helpers/Template.php(92): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\elements\db\EntryQuery), 'count', Array, 'method', false, false)
#16 /var/www/html/storage/runtime/compiled_templates/04/04ede9db1361d6b79415374e08c63cc513b671983a5ca346f6f44e4481d807c2.php(85): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\elements\db\EntryQuery), 'count', Array, 'method')
#17 /var/www/html/vendor/twig/twig/src/Template.php(407): __TwigTemplate_6b8171c384834fa91853229df8c25051ad821c05b1972327e47111707557d4a7->doDisplay(Array, Array)
#18 /var/www/html/vendor/twig/twig/src/Template.php(380): Twig\Template->displayWithErrorHandling(Array, Array)
#19 /var/www/html/vendor/twig/twig/src/Template.php(392): Twig\Template->display(Array)
#20 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#21 /var/www/html/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#22 /var/www/html/vendor/craftcms/cms/src/web/View.php(392): Twig\Environment->render('cpfilters/_inde...', Array)
#23 /var/www/html/vendor/craftcms/cms/src/web/View.php(453): craft\web\View->renderTemplate('cpfilters/_inde...', Array)
#24 /var/www/html/vendor/craftcms/cms/src/web/Controller.php(251): craft\web\View->renderPageTemplate('cpfilters/_inde...', Array, 'cp')
#25 /var/www/html/vendor/masugadesign/cpfilters/src/controllers/CpController.php(52): craft\web\Controller->renderTemplate('cpfilters/_inde...')
#26 [internal function]: Masuga\CpFilters\controllers\CpController->actionFilters()
#27 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#28 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#29 /var/www/html/vendor/craftcms/cms/src/web/Controller.php(189): yii\base\Controller->runAction('filters', Array)
#30 /var/www/html/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('filters', Array)
#31 /var/www/html/vendor/craftcms/cms/src/web/Application.php(280): yii\base\Module->runAction('cpfilters/cp/fi...', Array)
#32 /var/www/html/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('cpfilters/cp/fi...', Array)
#33 /var/www/html/vendor/craftcms/cms/src/web/Application.php(265): yii\web\Application->handleRequest(Object(craft\web\Request))
#34 /var/www/html/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#35 /var/www/html/web/index.php(21): yii\base\Application->run()
#36 {main}

Next yii\db\Exception: SQLSTATE[42883]: Undefined function: 7 ERROR:  operator does not exist: integer ~~ unknown
LINE 3: WHERE "id" LIKE $1
                   ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
The SQL being executed was: SELECT "id"
FROM "craft_entrytypes"
WHERE "id" LIKE '%' in /var/www/html/vendor/yiisoft/yii2/db/Schema.php:677
Stack trace:
#0 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1298): yii\db\Schema->convertException(Object(PDOException), 'SELECT "id"\nFRO...')
#1 /var/www/html/vendor/yiisoft/yii2/db/Command.php(1159): yii\db\Command->internalExecute('SELECT "id"\nFRO...')
#2 /var/www/html/vendor/yiisoft/yii2/db/Command.php(444): yii\db\Command->queryInternal('fetchAll', 7)
#3 /var/www/html/vendor/yiisoft/yii2/db/Query.php(318): yii\db\Command->queryColumn()
#4 /var/www/html/vendor/craftcms/cms/src/db/Query.php(202): yii\db\Query->column(NULL)
#5 /var/www/html/vendor/craftcms/cms/src/elements/db/EntryQuery.php(926): craft\db\Query->column()
#6 /var/www/html/vendor/craftcms/cms/src/elements/db/EntryQuery.php(806): craft\elements\db\EntryQuery->_normalizeTypeId()
#7 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1326): craft\elements\db\EntryQuery->beforePrepare()
#8 /var/www/html/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare(Object(craft\db\pgsql\QueryBuilder))
#9 /var/www/html/vendor/yiisoft/yii2/db/Query.php(157): yii\db\QueryBuilder->build(Object(craft\elements\db\EntryQuery))
#10 /var/www/html/vendor/yiisoft/yii2/db/Query.php(478): yii\db\Query->createCommand(Object(craft\db\Connection))
#11 /var/www/html/vendor/craftcms/cms/src/db/Query.php(259): yii\db\Query->queryScalar('COUNT(*)', NULL)
#12 /var/www/html/vendor/yiisoft/yii2/db/Query.php(366): craft\db\Query->queryScalar('COUNT(*)', NULL)
#13 /var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1466): yii\db\Query->count('*', NULL)
#14 /var/www/html/vendor/twig/twig/src/Extension/CoreExtension.php(1499): craft\elements\db\ElementQuery->count()
#15 /var/www/html/vendor/craftcms/cms/src/helpers/Template.php(92): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\elements\db\EntryQuery), 'count', Array, 'method', false, false)
#16 /var/www/html/storage/runtime/compiled_templates/04/04ede9db1361d6b79415374e08c63cc513b671983a5ca346f6f44e4481d807c2.php(85): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\elements\db\EntryQuery), 'count', Array, 'method')
#17 /var/www/html/vendor/twig/twig/src/Template.php(407): __TwigTemplate_6b8171c384834fa91853229df8c25051ad821c05b1972327e47111707557d4a7->doDisplay(Array, Array)
#18 /var/www/html/vendor/twig/twig/src/Template.php(380): Twig\Template->displayWithErrorHandling(Array, Array)
#19 /var/www/html/vendor/twig/twig/src/Template.php(392): Twig\Template->display(Array)
#20 /var/www/html/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#21 /var/www/html/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#22 /var/www/html/vendor/craftcms/cms/src/web/View.php(392): Twig\Environment->render('cpfilters/_inde...', Array)
#23 /var/www/html/vendor/craftcms/cms/src/web/View.php(453): craft\web\View->renderTemplate('cpfilters/_inde...', Array)
#24 /var/www/html/vendor/craftcms/cms/src/web/Controller.php(251): craft\web\View->renderPageTemplate('cpfilters/_inde...', Array, 'cp')
#25 /var/www/html/vendor/masugadesign/cpfilters/src/controllers/CpController.php(52): craft\web\Controller->renderTemplate('cpfilters/_inde...')
#26 [internal function]: Masuga\CpFilters\controllers\CpController->actionFilters()
#27 /var/www/html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#28 /var/www/html/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams(Array)
#29 /var/www/html/vendor/craftcms/cms/src/web/Controller.php(189): yii\base\Controller->runAction('filters', Array)
#30 /var/www/html/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('filters', Array)
#31 /var/www/html/vendor/craftcms/cms/src/web/Application.php(280): yii\base\Module->runAction('cpfilters/cp/fi...', Array)
#32 /var/www/html/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('cpfilters/cp/fi...', Array)
#33 /var/www/html/vendor/craftcms/cms/src/web/Application.php(265): yii\web\Application->handleRequest(Object(craft\web\Request))
#34 /var/www/html/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#35 /var/www/html/web/index.php(21): yii\base\Application->run()
#36 {main}
Additional Information:
Array
(
    [0] => 42883
    [1] => 7
    [2] => ERROR:  operator does not exist: integer ~~ unknown
LINE 3: WHERE "id" LIKE $1
                   ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
)
green17 commented 4 years ago

Getting the same.

benjaminkohl commented 3 years ago

Getting the same.

@green17 I'm curious—are you also using PostgreSQL?

green17 commented 3 years ago

@benjaminkohl no sorry MYSQL. It was a fresh install of the plugin, and the first click on CPFilters menu item throws an exception.

`yii\base\InvalidConfigException: Invalid typeId param value in /var/www/clients/client1/web/48/web/vendor/craftcms/cms/src/elements/db/EntryQuery.php:922 Stack trace:

0 /var/www/clients/client1/web/48/web/vendor/craftcms/cms/src/elements/db/EntryQuery.php(806): craft\elements\db\EntryQuery->_normalizeTypeId()

1 /var/www/clients/client1/web/48/web/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1325): craft\elements\db\EntryQuery->beforePrepare()

2 /var/www/clients/client1/web/48/web/vendor/yiisoft/yii2/db/QueryBuilder.php(227): craft\elements\db\ElementQuery->prepare()

3 /var/www/clients/client1/web/48/web/vendor/yiisoft/yii2/db/Query.php(157): yii\db\QueryBuilder->build()

4 /var/www/clients/client1/web/48/web/vendor/yiisoft/yii2/db/Query.php(478): yii\db\Query->createCommand()

5 /var/www/clients/client1/web/48/web/vendor/craftcms/cms/src/db/Query.php(259): yii\db\Query->queryScalar()

6 /var/www/clients/client1/web/48/web/vendor/yiisoft/yii2/db/Query.php(366): craft\db\Query->queryScalar()

7 /var/www/clients/client1/web/48/web/vendor/craftcms/cms/src/elements/db/ElementQuery.php(1465): yii\db\Query->count()

8 /var/www/clients/client1/web/48/web/vendor/twig/twig/src/Extension/CoreExtension.php(1499): craft\elements\db\ElementQuery->count()

9 /var/www/clients/client1/web/48/web/vendor/craftcms/cms/src/helpers/Template.php(90): twig_get_attribute()

10 /var/www/clients/client1/web/48/web/storage/runtime/compiled_templates/a5/a5ce46cf62f5f015a4c3a733ffa29c8b8ad6806f9587a0ae50e76e05cae4a697.php(85): craft\helpers\Template::attribute()

11 /var/www/clients/client1/web/48/web/vendor/twig/twig/src/Template.php(407): __TwigTemplate_86dbc690b13579773265756ecdebcc307136082a137e8edb36068c7d2f0661bb->doDisplay()

12 /var/www/clients/client1/web/48/web/vendor/twig/twig/src/Template.php(380): Twig\Template->displayWithErrorHandling()

13 /var/www/clients/client1/web/48/web/vendor/twig/twig/src/Template.php(392): Twig\Template->display()

14 /var/www/clients/client1/web/48/web/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render()

15 /var/www/clients/client1/web/48/web/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render()

16 /var/www/clients/client1/web/48/web/vendor/craftcms/cms/src/web/View.php(391): Twig\Environment->render()

17 /var/www/clients/client1/web/48/web/vendor/craftcms/cms/src/web/View.php(452): craft\web\View->renderTemplate()

18 /var/www/clients/client1/web/48/web/vendor/craftcms/cms/src/web/Controller.php(243): craft\web\View->renderPageTemplate()

19 /var/www/clients/client1/web/48/web/vendor/masugadesign/cpfilters/src/controllers/CpController.php(52): craft\web\Controller->renderTemplate()

20 [internal function]: Masuga\CpFilters\controllers\CpController->actionFilters()

21 /var/www/clients/client1/web/48/web/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()

22 /var/www/clients/client1/web/48/web/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams()

23 /var/www/clients/client1/web/48/web/vendor/craftcms/cms/src/web/Controller.php(181): yii\base\Controller->runAction()

24 /var/www/clients/client1/web/48/web/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction()

25 /var/www/clients/client1/web/48/web/vendor/craftcms/cms/src/web/Application.php(294): yii\base\Module->runAction()

26 /var/www/clients/client1/web/48/web/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction()

27 /var/www/clients/client1/web/48/web/vendor/craftcms/cms/src/web/Application.php(279): yii\web\Application->handleRequest()

28 /var/www/clients/client1/web/48/web/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest()

29 /var/www/clients/client1/web/48/web/index.php(33): yii\base\Application->run()

30 {main}`

benjaminkohl commented 3 years ago

The default config file sets all the filterable group ID settings to a string of '*'. Can you both create a cpfilters.php config file in your Craft config folder and set settings to the following and let me know if the plugin starts working for you?

Alternatively, you can replace each null value with an array of integer IDs.

<?php

return [

    // IDs of entry types that should be filterable using this tool.
    'filterableEntryTypeIds' => null,

    // IDs of asset volumes that should be filterable.
    'filterableAssetVolumeIds' => null,

    // IDs of category groups that should be filterable.
    'filterableCategoryGroupIds' => null,

    // IDs of tag groups that should be filterable.
    'filterableTagGroupIds' => null,

    // Additional field types that can be used as filter criteria.
    'additionalFieldTypes' => [],

];
ul8 commented 3 years ago

@benjaminkohl That fixed it for me, thanks!

benjaminkohl commented 3 years ago

Hi, @green17, can you also try the fix I proposed in this comment? I am wondering if maybe some versions of MySQL might also be a concern with the syntax that was used as the default config values.

ryanmasuga commented 3 years ago

Did you get this to work, @green17 ?

sjcallender commented 3 years ago

The cpfilters.php config file works fixes it for me. Thanks!

cakleimeier commented 3 years ago

This issue was fixed with the release of version 1.1.1