-
-
Notifications
You must be signed in to change notification settings - Fork 152
Open
Labels
type:bugBugBug
Description
What steps will reproduce the problem?
Have User model where getId() method does not return Primary Key.
We have custom alphanumeric key that we are using publicly.
What's expected?
User switching should work
What do you get instead?
HTTP 500 response:
{
"name":"Exception",
"message":"Argument 1 passed to yii\\debug\\models\\UserSwitch::setUserByIdentity() must implement interface yii\\web\\IdentityInterface, null given, called in /var/www/src/vendor/yiisoft/yii2-debug/src/controllers/UserController.php on line 48",
"code":0,
"type":"TypeError",
"file":"/var/www/src/vendor/yiisoft/yii2-debug/src/models/UserSwitch.php",
"line":124,
"stack-trace":[
"#0 /var/www/src/vendor/yiisoft/yii2-debug/src/controllers/UserController.php(48): yii\\debug\\models\\UserSwitch->setUserByIdentity(NULL)",
"#1 [internal function]: yii\\debug\\controllers\\UserController->actionSetIdentity()",
"#2 /var/www/src/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)",
"#3 /var/www/src/vendor/yiisoft/yii2/base/Controller.php(178): yii\\base\\InlineAction->runWithParams(Array)",
"#4 /var/www/src/vendor/yiisoft/yii2/base/Module.php(552): yii\\base\\Controller->runAction('set-identity', Array)",
"#5 /var/www/src/vendor/yiisoft/yii2/web/Application.php(103): yii\\base\\Module->runAction('debug/user/set-...', Array)",
"#6 /var/www/src/vendor/yiisoft/yii2/base/Application.php(384): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))",
"#7 /var/www/src/frontend/web/index.php(20): yii\\base\\Application->run()",
"#8 {main}"
]
}
Additional info
It seems that GridView is using DataProvider's getKeys method to index rows with data-key attribute. And user switching JS is using this key to build AJAX query to switch the user.
DataProvider does have parameter key that you can configure to get correct value as key. But problem is that there is no possibility (that I know of) to configure User panel so that DataProvider would use correct key.
| Q | A |
|---|---|
| Yii version | 2.0.46 |
| Yii2-debug version | 2.1.22 |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
type:bugBugBug