a-digital / cookie-consent-banner

Add a configurable cookie consent banner to the website.
MIT License
11 stars 14 forks source link

URGENT: Craft 3.7.22 breaks the plugin #37

Closed mightyfineyall closed 2 years ago

mightyfineyall commented 2 years ago

I updated one of my sites to yesterday's Craft 3.7.22 update, and immediately got Internal Server Errors on every page. The Cookie Consent Banner settings are also inaccessible. Plugin can be uninstalled and removed by Composer on the command line, but not via the CP. Throws an Array to String error when attempting removal via the CP.

2021-11-24 07:33:37 [-][1][60ec7cf48e27f607b23bf4bc9592a8b3][error][TypeError] TypeError: Argument 1 passed to craft\web\AssetBundle::_prependDevServer() must be of the type string, array given in /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/craftcms/cms/src/web/AssetBundle.php:56
Stack trace:
#0 [internal function]: craft\web\AssetBundle->_prependDevServer(Array)
#1 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/craftcms/cms/src/web/AssetBundle.php(41): array_map(Array, Array)
#2 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/craftcms/cms/src/web/AssetBundle.php(29): craft\web\AssetBundle->_updateResourcePaths()
#3 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/adigital/cookie-consent-banner/src/assetbundles/cookieconsentbanner/CookieConsentBannerAsset.php(78): craft\web\AssetBundle->init()
#4 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/yiisoft/yii2/base/BaseObject.php(109): adigital\cookieconsentbanner\assetbundles\cookieconsentbanner\CookieConsentBannerAsset->init()
#5 [internal function]: yii\base\BaseObject->__construct(Array)
#6 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/yiisoft/yii2/di/Container.php(412): ReflectionClass->newInstanceArgs(Array)
#7 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/yiisoft/yii2/di/Container.php(171): yii\di\Container->build('adigital\\cookie...', Array, Array)
#8 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/yiisoft/yii2/BaseYii.php(365): yii\di\Container->get('adigital\\cookie...', Array, Array)
#9 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/yiisoft/yii2/web/AssetManager.php(286): yii\BaseYii::createObject(Array)
#10 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/yiisoft/yii2/web/AssetManager.php(259): yii\web\AssetManager->loadBundle('adigital\\cookie...', Array, true)
#11 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/yiisoft/yii2/web/View.php(287): yii\web\AssetManager->getBundle('adigital\\cookie...')
#12 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/twig/twig/src/Extension/CoreExtension.php(1511): yii\web\View->registerAssetBundle('adigital\\cookie...')
#13 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/craftcms/cms/src/helpers/Template.php(106): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\web\View), 'registerAssetBu...', Array, 'method', false, false)
#14 /srv/users/xxuserxx/apps/xxsitexx/craft/storage/runtime/compiled_templates/32/329f9ac4de0bcefa8e1a2f30d8b6ae90056843e9e0edd0c5ea0e43d3290e3aa7.php(436): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig\Source), Object(craft\web\View), 'registerAssetBu...', Array, 'method')
#15 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/twig/twig/src/Template.php(405): __TwigTemplate_980afcca22ae0c12438b8bf133b68f5275f66824faa8281c62fd8ad5a78c77d8->doDisplay(Array, Array)
#16 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/twig/twig/src/Template.php(378): Twig\Template->displayWithErrorHandling(Array, Array)
#17 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/twig/twig/src/Template.php(390): Twig\Template->display(Array)
#18 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/twig/twig/src/TemplateWrapper.php(45): Twig\Template->render(Array, Array)
#19 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render(Array)
#20 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/craftcms/cms/src/web/View.php(408): Twig\Environment->render('cookie-consent-...', Array)
#21 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/adigital/cookie-consent-banner/src/CookieConsentBanner.php(202): craft\web\View->renderTemplate('cookie-consent-...', Array)
#22 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/craftcms/cms/src/base/Plugin.php(216): adigital\cookieconsentbanner\CookieConsentBanner->settingsHtml()
#23 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/craftcms/cms/src/web/View.php(1499): craft\base\Plugin->craft\base\{closure}()
#24 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/craftcms/cms/src/base/Plugin.php(217): craft\web\View->namespaceInputs(Object(Closure), 'settings')
#25 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/craftcms/cms/src/controllers/PluginsController.php(114): craft\base\Plugin->getSettingsResponse()
#26 [internal function]: craft\controllers\PluginsController->actionEditPluginSettings('cookie-consent-...', Object(adigital\cookieconsentbanner\CookieConsentBanner))
#27 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#28 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#29 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/yiisoft/yii2/base/Module.php(534): yii\base\Controller->runAction('edit-plugin-set...', Array)
#30 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/craftcms/cms/src/web/Application.php(287): yii\base\Module->runAction('plugins/edit-pl...', Array)
#31 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/yiisoft/yii2/web/Application.php(104): craft\web\Application->runAction('plugins/edit-pl...', Array)
#32 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/craftcms/cms/src/web/Application.php(272): yii\web\Application->handleRequest(Object(craft\web\Request))
#33 /srv/users/xxuserxx/apps/xxsitexx/craft/vendor/yiisoft/yii2/base/Application.php(392): craft\web\Application->handleRequest(Object(craft\web\Request))
#34 /srv/users/xxuserxx/apps/xxsitexx/craft/web/index.php(27): yii\base\Application->run()
#35 {main}
2021-11-24 07:33:37 [-][1][60ec7cf48e27f607b23bf4bc9592a8b3][info][application] $_GET = [
    'p' => 'admin/settings/plugins/cookie-consent-banner'
]
RyanRoberts commented 2 years ago

Yep getting this too. Ouch.

mark-adigital commented 2 years ago

This should no longer cause a conflict as of just-released 1.2.9. The problem was to do with how the options around whether the CSS and JS assets are pre-loaded/async or deferred were passed through the asset bundle - the plugin included all these in one array with the file path where Craft is now expecting only the string path to the asset.

I've updated this so that the options are specified separately, however the syntax I used previously is valid per Yii documentation and this means that options cannot be specified on a per-asset basis (not an issue with this plugin where there is only one JS and one CSS file), so I'll make P&T aware of this as I think the check they have added as of 3.7.22 assuming a string file path needs some better handling around it to also accept the first item in an array.

mightyfineyall commented 2 years ago

This should no longer cause a conflict as of just-released 1.2.9. The problem was to do with how the options around whether the CSS and JS assets are pre-loaded/async or deferred were passed through the asset bundle - the plugin included all these in one array with the file path where Craft is now expecting only the string path to the asset.

I've updated this so that the options are specified separately, however the syntax I used previously is valid per Yii documentation and this means that options cannot be specified on a per-asset basis (not an issue with this plugin where there is only one JS and one CSS file), so I'll make P&T aware of this as I think the check they have added as of 3.7.22 assuming a string file path needs some better handling around it to also accept the first item in an array.

Awesome, thanks for the prompt fix. Love the plugin - we use it on every site. Happy Thanksgiving!