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

Error when not checking any "Allowed Sites": expects parameter 1 to be array, string given #1

Closed
riusi88 opened this issue May 7, 2020 · 0 comments · Fixed by #3
Closed

Comments

@riusi88
Copy link

riusi88 commented May 7, 2020

Hi there, thanks for publishing this plugin! It's especially useful for enabling and disabling Assets on a per site basis.

I just want to point out an error that can occur when a user has not selected any "Allowed Sites". The plugin expects at least one site to be selected or it fails. I imaging this is only a problem to due user error, because in most use cases you'd select 2 or more sites. Perhaps some additional user instructions, making that field required, or catching the error in some other way that doesn't cause a PHP Warning would be useful.

yii\base\ErrorException: array_flip() expects parameter 1 to be array, string given in /.../craft3/vendor/eastslopestudio/craft3-sites-field/src/fields/SitesField.php:110 Stack trace: #0 /.../craft3/vendor/craftcms/cms/src/web/ErrorHandler.php(74): craft\web\ErrorHandler->handleError() #1 /.../craft3/vendor/eastslopestudio/craft3-sites-field/src/fields/SitesField.php(110): craft\web\ErrorHandler->handleError() #2 /.../craft3/vendor/eastslopestudio/craft3-sites-field/src/fields/SitesField.php(110): ::array_flip() #3 /.../craft3/vendor/twig/twig/src/Extension/CoreExtension.php(1499): eastslopestudio\sitesfield\fields\SitesField->getInputHtml() #4 /.../craft3/vendor/craftcms/cms/src/helpers/Template.php(96): ::twig_get_attribute() #5 /.../craft3/storage/runtime/compiled_templates/95/95d5917e3e1a910e7884eaf8d1347797b3753f4b760d2c08b0aa6d63a4ef663e.php(87): craft\helpers\Template::attribute() #6 /.../craft3/vendor/twig/twig/src/Template.php(407): __TwigTemplate_071e1e55eb195a6cf8eba3b8348e4b85685e67c6ba5f463c27d58f956809eb82->doDisplay() #7 /.../craft3/vendor/twig/twig/src/Template.php(380): __TwigTemplate_071e1e55eb195a6cf8eba3b8348e4b85685e67c6ba5f463c27d58f956809eb82->displayWithErrorHandling() #8 /.../craft3/storage/runtime/compiled_templates/0c/0ce7b8e9fc65b61725957b0d1f63bf10f16f9f594a4f75d9d94ce13cfa1ef3b0.php(58): __TwigTemplate_071e1e55eb195a6cf8eba3b8348e4b85685e67c6ba5f463c27d58f956809eb82->display() #9 /.../craft3/vendor/twig/twig/src/Template.php(407): __TwigTemplate_9fcf4d9dc0aa9a38816fc5539be0d6c5794613dc8cbeb8a265bd07b4ad6e2e18->doDisplay() #10 /.../craft3/vendor/twig/twig/src/Template.php(380): __TwigTemplate_9fcf4d9dc0aa9a38816fc5539be0d6c5794613dc8cbeb8a265bd07b4ad6e2e18->displayWithErrorHandling() #11 /.../craft3/storage/runtime/compiled_templates/05/05b66ce26fbc887af7b850b38604b5cd30ef54976e0736f3bd891cc5b0d41889.php(79): __TwigTemplate_9fcf4d9dc0aa9a38816fc5539be0d6c5794613dc8cbeb8a265bd07b4ad6e2e18->display() #12 /.../craft3/vendor/twig/twig/src/Template.php(407): __TwigTemplate_3920a61ae88c72964c8cbc036a1356c36a5e05d2df2bd92d03d5b1bb70cb12e4->doDisplay() #13 /.../craft3/vendor/twig/twig/src/Template.php(380): __TwigTemplate_3920a61ae88c72964c8cbc036a1356c36a5e05d2df2bd92d03d5b1bb70cb12e4->displayWithErrorHandling() #14 /.../craft3/storage/runtime/compiled_templates/bd/bdf39f751c3d6bf3be99ab61d9fcf965a1f96030b5b2daea527101eb8dbae090.php(156): __TwigTemplate_3920a61ae88c72964c8cbc036a1356c36a5e05d2df2bd92d03d5b1bb70cb12e4->display() #15 /.../craft3/vendor/twig/twig/src/Template.php(184): __TwigTemplate_c360492d2e155b1ca81a181f10b70d7856a0eb45083fabe55810f95f494c6485->block_content() #16 /.../craft3/storage/runtime/compiled_templates/ba/bac20fc3d32ca95f877a19ed50607a746b9ad0773b7e8948d8975a94cdcc0969.php(411): __TwigTemplate_7e674fe7390739f7ab89e00b822d7c2e3f6a8c14e65bd4f34e63bc317296092f->displayBlock() #17 /.../craft3/vendor/twig/twig/src/Template.php(184): __TwigTemplate_7e674fe7390739f7ab89e00b822d7c2e3f6a8c14e65bd4f34e63bc317296092f->block_main() #18 /.../craft3/vendor/twig/twig/src/Template.php(147): __TwigTemplate_7e674fe7390739f7ab89e00b822d7c2e3f6a8c14e65bd4f34e63bc317296092f->displayBlock() #19 /.../craft3/storage/runtime/compiled_templates/17/179b7e0b3cba5dbba1f8b6abf149e5371181e8e3869c19e5ae902eac3b65eec8.php(548): __TwigTemplate_badead698d5569f678dd2ba2d496da99fbf6e24277b1da285eb0b105e5bb76cf->displayParentBlock() #20 /.../craft3/vendor/twig/twig/src/Template.php(184): __TwigTemplate_badead698d5569f678dd2ba2d496da99fbf6e24277b1da285eb0b105e5bb76cf->block_main() #21 /.../craft3/storage/runtime/compiled_templates/ba/bac20fc3d32ca95f877a19ed50607a746b9ad0773b7e8948d8975a94cdcc0969.php(266): __TwigTemplate_7e674fe7390739f7ab89e00b822d7c2e3f6a8c14e65bd4f34e63bc317296092f->displayBlock() #22 /.../craft3/vendor/twig/twig/src/Template.php(184): __TwigTemplate_7e674fe7390739f7ab89e00b822d7c2e3f6a8c14e65bd4f34e63bc317296092f->block_body() #23 /.../craft3/storage/runtime/compiled_templates/ca/ca6024c16ded25a4b1bb63162fb96ad3559ec39f09c1239772157a735555c527.php(75): __TwigTemplate_670637c6baabb479c4f032f1faaa28cec4b1ae6d265cb173a99378124b846f35->displayBlock() #24 /.../craft3/vendor/twig/twig/src/Template.php(407): __TwigTemplate_670637c6baabb479c4f032f1faaa28cec4b1ae6d265cb173a99378124b846f35->doDisplay() #25 /.../craft3/vendor/twig/twig/src/Template.php(380): __TwigTemplate_670637c6baabb479c4f032f1faaa28cec4b1ae6d265cb173a99378124b846f35->displayWithErrorHandling() #26 /.../craft3/storage/runtime/compiled_templates/ba/ba804c39d74392e74422053f5fb393c14f37467a447874735548ea6eb82f9070.php(56): __TwigTemplate_670637c6baabb479c4f032f1faaa28cec4b1ae6d265cb173a99378124b846f35->display() #27 /.../craft3/vendor/twig/twig/src/Template.php(407): __TwigTemplate_972a82f5d754ca5276021352ffc406ba145eaf22a3d256629d57d8344a147819->doDisplay() #28 /.../craft3/vendor/twig/twig/src/Template.php(380): __TwigTemplate_972a82f5d754ca5276021352ffc406ba145eaf22a3d256629d57d8344a147819->displayWithErrorHandling() #29 /.../craft3/storage/runtime/compiled_templates/ba/bac20fc3d32ca95f877a19ed50607a746b9ad0773b7e8948d8975a94cdcc0969.php(138): __TwigTemplate_972a82f5d754ca5276021352ffc406ba145eaf22a3d256629d57d8344a147819->display() #30 /.../craft3/vendor/twig/twig/src/Template.php(407): __TwigTemplate_7e674fe7390739f7ab89e00b822d7c2e3f6a8c14e65bd4f34e63bc317296092f->doDisplay() #31 /.../craft3/vendor/twig/twig/src/Template.php(380): __TwigTemplate_7e674fe7390739f7ab89e00b822d7c2e3f6a8c14e65bd4f34e63bc317296092f->displayWithErrorHandling() #32 /.../craft3/storage/runtime/compiled_templates/17/179b7e0b3cba5dbba1f8b6abf149e5371181e8e3869c19e5ae902eac3b65eec8.php(222): __TwigTemplate_7e674fe7390739f7ab89e00b822d7c2e3f6a8c14e65bd4f34e63bc317296092f->display() #33 /.../craft3/vendor/twig/twig/src/Template.php(407): __TwigTemplate_badead698d5569f678dd2ba2d496da99fbf6e24277b1da285eb0b105e5bb76cf->doDisplay() #34 /.../craft3/vendor/twig/twig/src/Template.php(380): __TwigTemplate_badead698d5569f678dd2ba2d496da99fbf6e24277b1da285eb0b105e5bb76cf->displayWithErrorHandling() #35 /.../craft3/storage/runtime/compiled_templates/bd/bdf39f751c3d6bf3be99ab61d9fcf965a1f96030b5b2daea527101eb8dbae090.php(120): __TwigTemplate_badead698d5569f678dd2ba2d496da99fbf6e24277b1da285eb0b105e5bb76cf->display() #36 /.../craft3/vendor/twig/twig/src/Template.php(407): __TwigTemplate_c360492d2e155b1ca81a181f10b70d7856a0eb45083fabe55810f95f494c6485->doDisplay() #37 /.../craft3/vendor/twig/twig/src/Template.php(380): __TwigTemplate_c360492d2e155b1ca81a181f10b70d7856a0eb45083fabe55810f95f494c6485->displayWithErrorHandling() #38 /.../craft3/vendor/twig/twig/src/Template.php(392): __TwigTemplate_c360492d2e155b1ca81a181f10b70d7856a0eb45083fabe55810f95f494c6485->display() #39 /.../craft3/vendor/twig/twig/src/TemplateWrapper.php(45): __TwigTemplate_c360492d2e155b1ca81a181f10b70d7856a0eb45083fabe55810f95f494c6485->render() #40 /.../craft3/vendor/twig/twig/src/Environment.php(318): Twig\TemplateWrapper->render() #41 /.../craft3/vendor/craftcms/cms/src/web/View.php(397): craft\web\twig\Environment->render() #42 /.../craft3/vendor/craftcms/cms/src/web/View.php(458): craft\web\View->renderTemplate() #43 /.../craft3/vendor/craftcms/cms/src/web/Controller.php(235): craft\web\View->renderPageTemplate() #44 /.../craft3/vendor/craftcms/cms/src/controllers/EntriesController.php(248): craft\controllers\EntriesController->renderTemplate() #45 /.../craft3/vendor/yiisoft/yii2/base/InlineAction.php(57): craft\controllers\EntriesController->actionEditEntry() #46 /.../craft3/vendor/yiisoft/yii2/base/InlineAction.php(57): ::call_user_func_array:{/.../craft3/vendor/yiisoft/yii2/base/InlineAction.php:57}() #47 /.../craft3/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams() #48 /.../craft3/vendor/craftcms/cms/src/web/Controller.php(178): craft\controllers\EntriesController->runAction() #49 /.../craft3/vendor/yiisoft/yii2/base/Module.php(528): craft\controllers\EntriesController->runAction() #50 /.../craft3/vendor/craftcms/cms/src/web/Application.php(291): craft\web\Application->runAction() #51 /.../craft3/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction() #52 /.../craft3/vendor/craftcms/cms/src/web/Application.php(276): craft\web\Application->handleRequest() #53 /.../craft3/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest() #54 /.../craft3/web/index.php(42): craft\web\Application->run() #55 {main}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant