thyseus / yii-user-management

a user management module collection for the yii framework
185 stars 122 forks source link

Duplicate entry, when accessing the user management #11

Closed omphteliba closed 12 years ago

omphteliba commented 12 years ago

Hi,

when i try to access the user management 'http://localhost/whatever/index.php/user/user' i get the following error:

CDbCommand failed to execute the SQL statement: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'username'. The SQL statement executed was: INSERT INTO user (lastaction) VALUES (:yp0)

yum tries to add a new user without name to the table "user"

yii: yii-1.1.10.r3566 yum: 0.8rc6

thyseus commented 12 years ago

hmm, this is interesting. It should not INSERT but UPDATE the lastaction column in the user table. Which database & version do you user?

omphteliba commented 12 years ago

Phpmyadmin tells me: MySQL client version: mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $

omphteliba commented 12 years ago

i have disabled the "lastaction" functionality, so i can use YUM.

BjornGameDev commented 12 years ago

I'm having the exact same issue, with the same version of yum and yii.

EDIT: Here is error stack: http://bmgdesign.net/error.html

thyseus commented 12 years ago

please tell me if this commit fixes the issue:

https://github.com/thyseus/yii-user-management/commit/07b4febbf8ae5a9bad4149a96ca2cae78e40502a

thank you

omphteliba commented 12 years ago

Didn't fix it for me. Gave me a new error:

YumUser and its behaviors do not have a method or closure named "isNewRecord".

CException

YumUser and its behaviors do not have a method or closure named "isNewRecord".

C:\xampp\htdocs\yii\framework\base\CComponent.php(266)

254 public function __call($name,$parameters) 255 { 256 if($this->_m!==null) 257 { 258 foreach($this->_m as $object) 259 { 260 if($object->getEnabled() && method_exists($object,$name)) 261 return call_user_func_array(array($object,$name),$parameters); 262 } 263 } 264 if(class_exists('Closure', false) && $this->canGetProperty($name) && $this->$name instanceof Closure) 265 return call_user_func_array($this->$name, $parameters); 266 throw new CException(Yii::t('yii','{class} and its behaviors do not have a method or closure named "{name}".', 267 array('{class}'=>get_class($this), '{name}'=>$name))); 268 } 269 270 /* 271 * Returns the named behavior object. 272 * The name 'asa' stands for 'as a'. 273 * @param string $behavior the behavior name 274 * @return IBehavior the behavior object, or null if the behavior does not exist 275 / 276 public function asa($behavior) 277 { 278 return isset($this->_m[$behavior]) ? $this->_m[$behavior] : null;

Stack Trace

0

+ C:\xampp\htdocs\yii\framework\db\ar\CActiveRecord.php(226): CComponent->__call("isNewRecord", array())

1

– C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php(82): CActiveRecord->__call("isNewRecord", array())

77 78 // If Online status is enabled, we need to set the timestamp of the 79 // last action when a user does something 80 public function setLastAction() 81 { 82 if (!Yii::app()->user->isGuest && !$this->isNewRecord()) { 83 $this->lastaction = time(); 84 return $this->save(false, array('lastaction')); 85 } 86 } 87

2

– C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php(82): YumUser->isNewRecord()

77 78 // If Online status is enabled, we need to set the timestamp of the 79 // last action when a user does something 80 public function setLastAction() 81 { 82 if (!Yii::app()->user->isGuest && !$this->isNewRecord()) { 83 $this->lastaction = time(); 84 return $this->save(false, array('lastaction')); 85 } 86 } 87

3

– C:\xampp\htdocs\omivk\protected\modules\user\controllers\YumController.php(24): YumUser->setLastAction()

19 } 20 } 21 22 public function beforeAction($action) { 23 if(Yum::module()->enableOnlineStatus && !Yii::app()->user->isGuest) 24 Yii::app()->user->data()->setLastAction(); 25 26 return parent::beforeAction($action); 27 } 28 29 public function loadModel($model = false) {

4

+ C:\xampp\htdocs\omivk\protected\modules\user\controllers\YumUserController.php(100): YumController->beforeAction(CInlineAction)

5

+ C:\xampp\htdocs\yii\framework\web\CController.php(307): YumUserController->beforeAction(CInlineAction)

6

+ C:\xampp\htdocs\yii\framework\web\filters\CFilterChain.php(134): CController->runAction(CInlineAction)

7

+ C:\xampp\htdocs\yii\framework\web\filters\CFilter.php(41): CFilterChain->run()

8

+ C:\xampp\htdocs\yii\framework\web\CController.php(1146): CFilter->filter(CFilterChain)

9

+ C:\xampp\htdocs\yii\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(CFilterChain)

10

+ C:\xampp\htdocs\yii\framework\web\filters\CFilterChain.php(131): CInlineFilter->filter(CFilterChain)

11

+ C:\xampp\htdocs\yii\framework\web\CController.php(292): CFilterChain->run()

12

+ C:\xampp\htdocs\yii\framework\web\CController.php(266): CController->runActionWithFilters(CInlineAction, array("accessControl"))

13

+ C:\xampp\htdocs\yii\framework\web\CWebApplication.php(276): CController->run("admin")

14

+ C:\xampp\htdocs\yii\framework\web\CWebApplication.php(135): CWebApplication->runController("user/user/admin")

15

+ C:\xampp\htdocs\yii\framework\base\CApplication.php(162): CWebApplication->processRequest()

16

+ C:\xampp\htdocs\omivk\index.php(18): CApplication->run() 2012-07-11 09:21:11 Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1 Yii Framework/1.1.10 Application Log Timestamp Level Category Message 09:21:10.246315 trace system.CModule

Loading "log" application component in C:\xampp\htdocs\omivk\index.php (18)

09:21:10.249495 trace system.CModule

Loading "request" application component in C:\xampp\htdocs\omivk\index.php (18)

09:21:10.250823 trace system.CModule

Loading "urlManager" application component in C:\xampp\htdocs\omivk\index.php (18)

09:21:10.251945 trace system.CModule

Loading "cache" application component in C:\xampp\htdocs\omivk\index.php (18)

09:21:10.252796 trace system.base.CModule

Loading "user" module in C:\xampp\htdocs\omivk\index.php (18)

09:21:10.257785 trace system.CModule

Loading "user" application component in C:\xampp\htdocs\omivk\protected\modules\user\UserModule.php (239) in C:\xampp\htdocs\omivk\index.php (18)

09:21:10.259428 trace system.CModule

Loading "session" application component in C:\xampp\htdocs\omivk\protected\modules\user\UserModule.php (239) in C:\xampp\htdocs\omivk\index.php (18)

09:21:10.266544 trace system.CModule

Loading "db" application component in C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php (235) in C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php (49) in C:\xampp\htdocs\omivk\protected\modules\user\components\YumWebUser.php (12)

09:21:10.267452 trace system.db.CDbConnection

Opening DB connection in C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php (235) in C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php (49) in C:\xampp\htdocs\omivk\protected\modules\user\components\YumWebUser.php (12)

09:21:10.282816 trace system.db.CDbCommand

Querying SQL: SHOW COLUMNS FROM user in C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php (49) in C:\xampp\htdocs\omivk\protected\modules\user\components\YumWebUser.php (12) in C:\xampp\htdocs\omivk\protected\modules\user\components\YumWebUser.php (153)

09:21:10.295984 trace system.db.CDbCommand

Querying SQL: SHOW CREATE TABLE user in C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php (49) in C:\xampp\htdocs\omivk\protected\modules\user\components\YumWebUser.php (12) in C:\xampp\htdocs\omivk\protected\modules\user\components\YumWebUser.php (153)

09:21:10.296463 trace system.base.CModule

Loading "role" module in C:\xampp\htdocs\omivk\protected\modules\user\models\Yum.php (153) in C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php (379) in C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php (49)

09:21:10.299029 trace system.db.ar.CActiveRecord

YumUser.findByPk() in C:\xampp\htdocs\omivk\protected\modules\user\components\YumWebUser.php (12) in C:\xampp\htdocs\omivk\protected\modules\user\components\YumWebUser.php (153) in C:\xampp\htdocs\omivk\protected\modules\user\UserModule.php (239)

09:21:10.301812 trace system.db.CDbCommand

Querying SQL: SELECT * FROM user t WHERE t.id='1' LIMIT 1 in C:\xampp\htdocs\omivk\protected\modules\user\components\YumWebUser.php (12) in C:\xampp\htdocs\omivk\protected\modules\user\components\YumWebUser.php (153) in C:\xampp\htdocs\omivk\protected\modules\user\UserModule.php (239)

09:21:10.303333 trace system.web.filters.CFilterChain

Running filter YumUserController.filteraccessControl() in C:\xampp\htdocs\omivk\index.php (18)

09:21:10.304574 trace system.CModule

Loading "coreMessages" application component in C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php (82) in C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php (82) in C:\xampp\htdocs\omivk\protected\modules\user\controllers\YumController.php (24)

09:21:11.306119 error exception.CException

exception 'CException' with message 'YumUser and its behaviors do not have a method or closure named "isNewRecord".' in C:\xampp\htdocs\yii\framework\base\CComponent.php:266 Stack trace:

0 C:\xampp\htdocs\yii\framework\db\ar\CActiveRecord.php(226):

CComponent->__call('isNewRecord', Array)

1 C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php(82):

CActiveRecord->__call('isNewRecord', Array)

2 C:\xampp\htdocs\omivk\protected\modules\user\models\YumUser.php(82):

YumUser->isNewRecord()

3

C:\xampp\htdocs\omivk\protected\modules\user\controllers\YumController.php(24): YumUser->setLastAction()

4

C:\xampp\htdocs\omivk\protected\modules\user\controllers\YumUserController.php(100): YumController->beforeAction(Object(CInlineAction))

5 C:\xampp\htdocs\yii\framework\web\CController.php(307):

YumUserController->beforeAction(Object(CInlineAction))

6 C:\xampp\htdocs\yii\framework\web\filters\CFilterChain.php(134):

CController->runAction(Object(CInlineAction))

7 C:\xampp\htdocs\yii\framework\web\filters\CFilter.php(41):

CFilterChain->run()

8 C:\xampp\htdocs\yii\framework\web\CController.php(1146):

CFilter->filter(Object(CFilterChain))

9 C:\xampp\htdocs\yii\framework\web\filters\CInlineFilter.php(59):

CController->filterAccessControl(Object(CFilterChain))

10 C:\xampp\htdocs\yii\framework\web\filters\CFilterChain.php(131):

CInlineFilter->filter(Object(CFilterChain))

11 C:\xampp\htdocs\yii\framework\web\CController.php(292):

CFilterChain->run()

12 C:\xampp\htdocs\yii\framework\web\CController.php(266):

CController->runActionWithFilters(Object(CInlineAction), Array)

13 C:\xampp\htdocs\yii\framework\web\CWebApplication.php(276):

CController->run('admin')

14 C:\xampp\htdocs\yii\framework\web\CWebApplication.php(135):

CWebApplication->runController('user/user/admin')

15 C:\xampp\htdocs\yii\framework\base\CApplication.php(162):

CWebApplication->processRequest()

16 C:\xampp\htdocs\omivk\index.php(18): CApplication->run()

17 {main}

REQUEST_URI=/omivk/index.php/user/user/admin HTTP_REFERER=http://localhost/omivk/index.php/user/auth


09:21:11.307127 trace system.CModule

Loading "errorHandler" application component

thyseus commented 12 years ago

sorry, i was somewhat tired. just pull again or remove the (), then it should work (https://github.com/thyseus/yii-user-management/commit/bd375b419339271d639c619f688765201e947c70)

omphteliba commented 12 years ago

Thanks a lot that worked for me!

BjornGameDev commented 12 years ago

Works.