kinoli / groupie

Assign users to specific user groups upon registration. Especially useful for front-end signup forms.
Other
3 stars 0 forks source link

Possible Array Issue when 'groups' field not supplied? #4

Closed chadcrowell closed 5 years ago

chadcrowell commented 5 years ago

I have Groupie installed but am not using it yet actively. So, my reg form doesn't have a "groups" hidden field. I had a customer today that wasn't able to complete their order and the error appears to be with Groupie. Looks like it is getting NULL for $requestedUserGroups. Maybe its the result of no "groups" field and an if($requestedUserGroups) conditional is in order?

2019-09-12 07:09:50 [-][-][f2d8ffeba239b36278a55f42b632e32c][error][yii\base\ErrorException:2] yii\base\ErrorException: array_intersect(): Expected parameter 1 to be an array, null given in /home/gcx/craft.gcx.com/vendor/kinoli/groupie/src/Groupie.php:101
Stack trace:
#0 /home/gcx/craft.gcx.com/vendor/craftcms/cms/src/web/ErrorHandler.php(80): yii\base\ErrorHandler->handleError(2, 'array_intersect...', '/home/gcx/craft...', 101)
#1 [internal function]: craft\web\ErrorHandler->handleError(2, 'array_intersect...', '/home/gcx/craft...', 101, Array)
#2 /home/gcx/craft.gcx.com/vendor/kinoli/groupie/src/Groupie.php(101): array_intersect(NULL, Array)
#3 [internal function]: kinoli\groupie\Groupie->kinoli\groupie\{closure}(Object(craft\events\UserAssignGroupEvent))
#4 /home/gcx/craft.gcx.com/vendor/yiisoft/yii2/base/Event.php(312): call_user_func(Object(Closure), Object(craft\events\UserAssignGroupEvent))
#5 /home/gcx/craft.gcx.com/vendor/yiisoft/yii2/base/Component.php(636): yii\base\Event::trigger('craft\\services\\...', 'afterAssignUser...', Object(craft\events\UserAssignGroupEvent))
#6 /home/gcx/craft.gcx.com/vendor/craftcms/cms/src/services/Users.php(1006): yii\base\Component->trigger('afterAssignUser...', Object(craft\events\UserAssignGroupEvent))
#7 /home/gcx/craft.gcx.com/vendor/craftcms/cms/src/controllers/UsersController.php(1164): craft\services\Users->assignUserToDefaultGroup(Object(craft\elements\User))
#8 [internal function]: craft\controllers\UsersController->actionSaveUser()
#9 /home/gcx/craft.gcx.com/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#10 /home/gcx/craft.gcx.com/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#11 /home/gcx/craft.gcx.com/vendor/craftcms/cms/src/web/Controller.php(187): yii\base\Controller->runAction('save-user', Array)
#12 /home/gcx/craft.gcx.com/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('save-user', Array)
#13 /home/gcx/craft.gcx.com/vendor/craftcms/cms/src/web/Application.php(299): yii\base\Module->runAction('users/save-user', Array)
#14 /home/gcx/craft.gcx.com/vendor/craftcms/cms/src/web/Application.php(566): craft\web\Application->runAction('users/save-user', Array)
#15 /home/gcx/craft.gcx.com/vendor/craftcms/cms/src/web/Application.php(278): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#16 /home/gcx/craft.gcx.com/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#17 /home/gcx/craft.gcx.com/public_html/index.php(21): yii\base\Application->run()
#18 {main}
2019-09-12 07:09:50 [-][-][f2d8ffeba239b36278a55f42b632e32c][info][application] $_GET = [
    'p' => 'checkout/register-signin'
]
kinoli commented 5 years ago

Thanks for finding this. The latest release v1.0.1 has the fix for it.

chadcrowell commented 5 years ago

Great thanks! Packagist still showing v1.0.0 can you make sure everything gets updated so Craft sees the update?

kinoli commented 5 years ago

Sorry, it should be updated now.