sarvan75 / yii-user-management

Automatically exported from code.google.com/p/yii-user-management
0 stars 0 forks source link

The table "{{users}}" for active record class "YumUser" cannot be found in the database. #108

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Make fresh installation of latest Yii and yii-user-management 0.8 
2. login with admin/admin
3. and get error...

What is the expected output? What do you see instead?

CDbException

The table "{{users}}" for active record class "YumUser" cannot be found in the 
database.

Q:\home\gdefutbol\framework\db\ar\CActiveRecord.php(2168)

2156     private $_model;
2157 
2158     /**
2159      * Constructor.
2160      * @param CActiveRecord $model the model instance
2161      */
2162     public function __construct($model)
2163     {
2164         $this->_model=$model;
2165 
2166         $tableName=$model->tableName();
2167         
if(($table=$model->getDbConnection()->getSchema()->getTable($tableName))===null)
2168             throw new CDbException(Yii::t('yii','The table "{table}" for 
active record class "{class}" cannot be found in the database.',
2169                 
array('{class}'=>get_class($model),'{table}'=>$tableName)));
2170         if($table->primaryKey===null)
2171             $table->primaryKey=$model->primaryKey();
2172         $this->tableSchema=$table;
2173         $this->columns=$table->columns;
2174 
2175         foreach($table->columns as $name=>$column)
2176         {
2177             if(!$column->isPrimaryKey && $column->defaultValue!==null)
2178                 $this->attributeDefaults[$name]=$column->defaultValue;
2179         }
2180 

Stack Trace
#0  
+
–
 Q:\home\gdefutbol\framework\db\ar\CActiveRecord.php(353): CActiveRecordMetaData->__construct(YumUser)

348         if(isset(self::$_models[$className]))
349             return self::$_models[$className];
350         else
351         {
352             $model=self::$_models[$className]=new $className(null);
353             $model->_md=new CActiveRecordMetaData($model);
354             $model->attachBehaviors($model->behaviors());
355             return $model;
356         }
357     }
358 

#1  
+
–
 Q:\home\gdefutbol\www\protected\modules\user\models\YumUser.php(45): CActiveRecord::model("YumUser")

40     public $password_changed = false;
41     private $_userRoleTable;
42     private $_friendshipTable;
43 
44     public static function model($className=__CLASS__) {
45         return parent::model($className);
46     }
47 
48     public function isOnline() {
49         return $this->lastaction > time() - 
Yum::module()->offlineIndicationTime;
50     }

#2  
+
–
 Q:\home\gdefutbol\www\protected\modules\user\controllers\YumAuthController.php(154): YumUser::model()

149             return false;
150     }
151 
152     public function loginByUsername() {
153         if(Yum::module()->caseSensitiveUsers)
154             $user = YumUser::model()->find('username = :username', array(
155                         ':username' => $this->loginForm->username));
156         else
157             $user = YumUser::model()->find('upper(username) = :username', 
array(
158                         ':username' => 
strtoupper($this->loginForm->username)));
159 

#3  
+
–
 Q:\home\gdefutbol\www\protected\modules\user\controllers\YumAuthController.php(248): YumAuthController->loginByUsername()

243         if (isset($_POST['YumUserLogin'])) {
244             $this->loginForm->attributes = $_POST['YumUserLogin'];
245             // validate user input for the rest of login methods
246             if ($this->loginForm->validate()) {
247                 if (Yum::module()->loginType & 
UserModule::LOGIN_BY_USERNAME) {
248                     $success = $this->loginByUsername();
249                     if ($success)
250                         $login_type = 'username';
251                 }
252                 if (Yum::module()->loginType & UserModule::LOGIN_BY_EMAIL 
&& !$success) {
253                     $success = $this->loginByEmail();

#4  
+
–
 Q:\home\gdefutbol\framework\web\actions\CInlineAction.php(57): YumAuthController->actionLogin()

52                     throw new CHttpException(400,Yii::t('yii','Your request 
is invalid.'));
53             }
54             $method->invokeArgs($controller,$params);
55         }
56         else
57             $controller->$methodName();
58     }
59 }

#5  
+
–
 Q:\home\gdefutbol\framework\web\CController.php(300): CInlineAction->run()

295     {
296         $priorAction=$this->_action;
297         $this->_action=$action;
298         if($this->beforeAction($action))
299         {
300             $action->run();
301             $this->afterAction($action);
302         }
303         $this->_action=$priorAction;
304     }
305 

#6  
+
–
 Q:\home\gdefutbol\framework\web\filters\CFilterChain.php(133): CController->runAction(CInlineAction)

128             $filter=$this->itemAt($this->filterIndex++);
129             Yii::trace('Running filter '.($filter instanceof CInlineFilter 
? 
get_class($this->controller).'.filter'.$filter->name.'()':get_class($filter).'.f
ilter()'),'system.web.filters.CFilterChain');
130             $filter->filter($this);
131         }
132         else
133             $this->controller->runAction($this->action);
134     }
135 }

#7  
+
–
 Q:\home\gdefutbol\framework\web\filters\CFilter.php(41): CFilterChain->run()

36      */
37     public function filter($filterChain)
38     {
39         if($this->preFilter($filterChain))
40         {
41             $filterChain->run();
42             $this->postFilter($filterChain);
43         }
44     }
45 
46     /**

#8  
+
–
 Q:\home\gdefutbol\framework\web\CController.php(1088): CFilter->filter(CFilterChain)

1083      */
1084     public function filterAccessControl($filterChain)
1085     {
1086         $filter=new CAccessControlFilter;
1087         $filter->setRules($this->accessRules());
1088         $filter->filter($filterChain);
1089     }
1090 
1091     /**
1092      * Generates pagination information.
1093      * This method can be used to generate pagination information given 
item count

#9  
+
–
 Q:\home\gdefutbol\framework\web\filters\CInlineFilter.php(59): CController->filterAccessControl(CFilterChain)

54      * @param CFilterChain $filterChain the filter chain that the filter is 
on.
55      */
56     public function filter($filterChain)
57     {
58         $method='filter'.$this->name;
59         $filterChain->controller->$method($filterChain);
60     }
61 }

#10     
+
–
 Q:\home\gdefutbol\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter(CFilterChain)

125     {
126         if($this->offsetExists($this->filterIndex))
127         {
128             $filter=$this->itemAt($this->filterIndex++);
129             Yii::trace('Running filter '.($filter instanceof CInlineFilter 
? 
get_class($this->controller).'.filter'.$filter->name.'()':get_class($filter).'.f
ilter()'),'system.web.filters.CFilterChain');
130             $filter->filter($this);
131         }
132         else
133             $this->controller->runAction($this->action);
134     }
135 }

#11     
+
–
 Q:\home\gdefutbol\framework\web\CController.php(283): CFilterChain->run()

278             $this->runAction($action);
279         else
280         {
281             $priorAction=$this->_action;
282             $this->_action=$action;
283             CFilterChain::create($this,$action,$filters)->run();
284             $this->_action=$priorAction;
285         }
286     }
287 
288     /**

#12     
+
–
 Q:\home\gdefutbol\framework\web\CController.php(257): CController->runActionWithFilters(CInlineAction, array("accessControl"))

252         {
253             if(($parent=$this->getModule())===null)
254                 $parent=Yii::app();
255             if($parent->beforeControllerAction($this,$action))
256             {
257                 $this->runActionWithFilters($action,$this->filters());
258                 $parent->afterControllerAction($this,$action);
259             }
260         }
261         else
262             $this->missingAction($actionID);

#13     
+
–
 Q:\home\gdefutbol\framework\web\CWebApplication.php(328): CController->run("")

323         {
324             list($controller,$actionID)=$ca;
325             $oldController=$this->_controller;
326             $this->_controller=$controller;
327             $controller->init();
328             $controller->run($actionID);
329             $this->_controller=$oldController;
330         }
331         else
332             throw new CHttpException(404,Yii::t('yii','Unable to resolve 
the request "{route}".',
333                 
array('{route}'=>$route===''?$this->defaultController:$route)));

#14     
+
–
 Q:\home\gdefutbol\framework\web\CWebApplication.php(121): CWebApplication->runController("user/auth")

116             foreach(array_splice($this->catchAllRequest,1) as $name=>$value)
117                 $_GET[$name]=$value;
118         }
119         else
120             $route=$this->getUrlManager()->parseUrl($this->getRequest());
121         $this->runController($route);
122     }
123 
124     /**
125      * Registers the core application components.
126      * This method overrides the parent implementation by registering 
additional core components.

#15     
+
–
 Q:\home\gdefutbol\framework\base\CApplication.php(155): CWebApplication->processRequest()

150      */
151     public function run()
152     {
153         if($this->hasEventHandler('onBeginRequest'))
154             $this->onBeginRequest(new CEvent($this));
155         $this->processRequest();
156         if($this->hasEventHandler('onEndRequest'))
157             $this->onEndRequest(new CEvent($this));
158     }
159 
160     /**

#16     
+
–
 Q:\home\gdefutbol\www\index.php(13): CApplication->run()

08 defined('YII_DEBUG') or define('YII_DEBUG',true);
09 // specify how many levels of call stack should be shown in each log message
10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
11 
12 require_once($yii);
13 Yii::createWebApplication($config)->run();

2011-01-26 23:57:00 Apache/2.2.4 (Win32) mod_ssl/2.2.4 OpenSSL/0.9.8k PHP/5.3.3 
Yii Framework/1.1.6

Original issue reported on code.google.com by sergey.m...@gmail.com on 26 Jan 2011 at 9:33

GoogleCodeExporter commented 9 years ago
It seems like isset function is not functioning properly, because 
Yum::module()->usersTable working good without checking at YumUser.php.

Original comment by sergey.m...@gmail.com on 26 Jan 2011 at 10:06

GoogleCodeExporter commented 9 years ago
CComponent.php:187     if(method_exists($this,$getter)) -- Check error goes here

I can't understand what's going wrong here?

Original comment by sergey.m...@gmail.com on 26 Jan 2011 at 10:36

GoogleCodeExporter commented 9 years ago
I've figured out what's wrong:

i just added __ISSET() method to UserModule.php

The code is:

    public function __isset($name) {
        if(substr($name, -5) === 'Table')
             return isset($this->_tables[substr($name, 0, -5)]) ? TRUE : FALSE;
        if(substr($name, -4) === 'View')
             return isset($this->_views[substr($name, 0, -4)])  ? TRUE : FALSE;
        if(substr($name, -3) === 'Url')
             return isset($this->_urls[substr($name, 0, -3)])   ? TRUE : FALSE;

        return parent::__isset($name);        

Original comment by sergey.m...@gmail.com on 27 Jan 2011 at 9:39

GoogleCodeExporter commented 9 years ago
This is more correct version:

    public function __isset($name) {
        if(substr($name, -5) === 'Table')
             return isset($this->_tables[substr($name, 0, -5)]);
        if(substr($name, -4) === 'View')
             return isset($this->_views[substr($name, 0, -4)]);
        if(substr($name, -3) === 'Url')
             return isset($this->_urls[substr($name, 0, -3)]);

        return parent::__isset($name);        
    }

Original comment by sergey.m...@gmail.com on 27 Jan 2011 at 9:40

GoogleCodeExporter commented 9 years ago
This does also happen to YumActivity for me...

CDbException

Beschreibung

Die Tabelle "{{activities}}" für die ActiveRecord-Klasse "YumActivity" kann 
nicht in der Datenbank gefunden werden.

Quelldatei

/Users/sbauer/Projekte/yii/db/ar/CActiveRecord.php(2159)

02147:     private $_model;
02148: 
02149:     /**
02150:      * Constructor.
02151:      * @param CActiveRecord the model instance
02152:      */
02153:     public function __construct($model)
02154:     {
02155:         $this->_model=$model;
02156: 
02157:         $tableName=$model->tableName();
02158:         
if(($table=$model->getDbConnection()->getSchema()->getTable($tableName))===null)
02159:             throw new CDbException(Yii::t('yii','The table "{table}" for 
active record class "{class}" cannot be found in the database.',
02160:                 
array('{class}'=>get_class($model),'{table}'=>$tableName)));
02161:         if($table->primaryKey===null)
02162:             $table->primaryKey=$model->primaryKey();
02163:         $this->tableSchema=$table;
02164:         $this->columns=$table->columns;
02165: 
02166:         foreach($table->columns as $name=>$column)
02167:         {
02168:             if(!$column->isPrimaryKey && $column->defaultValue!==null)
02169:                 $this->attributeDefaults[$name]=$column->defaultValue;
02170:         }
02171: 
Verfolgung des Aufrufstapels

#0 /Users/sbauer/Projekte/yii/db/ar/CActiveRecord.php(353): 
CActiveRecordMetaData->__construct(Object(YumActivity))
#1 /Users/sbauer/Projekte/yii/db/ar/CActiveRecord.php(367): 
CActiveRecord::model('YumActivity')
#2 
/Users/sbauer/Projekte/artaius/protected/modules/user/models/YumActiveRecord.php
(24): CActiveRecord->getMetaData()
#3 /Users/sbauer/Projekte/yii/db/ar/CActiveRecord.php(62): 
YumActiveRecord->getMetaData()
#4 
/Users/sbauer/Projekte/artaius/protected/modules/user/controllers/YumActivityCon
troller.php(70): CActiveRecord->__construct()
#5 
/Users/sbauer/Projekte/artaius/protected/modules/user/models/YumUser.php(145): 
YumActivityController::logActivity(Object(YumUser), 'user_updated')
#6 /Users/sbauer/Projekte/yii/db/ar/CActiveRecord.php(1049): 
YumUser->afterSave()
#7 /Users/sbauer/Projekte/yii/db/ar/CActiveRecord.php(759): 
CActiveRecord->update(NULL)
#8 
/Users/sbauer/Projekte/artaius/protected/modules/user/models/YumUser.php(56): 
CActiveRecord->save()
#9 
/Users/sbauer/Projekte/artaius/protected/modules/user/controllers/YumController.
php(24): YumUser->setLastAction()
#10 /Users/sbauer/Projekte/yii/web/CController.php(298): 
YumController->beforeAction(Object(CInlineAction))
#11 /Users/sbauer/Projekte/yii/web/filters/CFilterChain.php(133): 
CController->runAction(Object(CInlineAction))
#12 /Users/sbauer/Projekte/yii/web/filters/CFilter.php(41): CFilterChain->run()
#13 /Users/sbauer/Projekte/yii/web/CController.php(1049): 
CFilter->filter(Object(CFilterChain))
#14 /Users/sbauer/Projekte/yii/web/filters/CInlineFilter.php(59): 
CController->filterAccessControl(Object(CFilterChain))
#15 /Users/sbauer/Projekte/yii/web/filters/CFilterChain.php(130): 
CInlineFilter->filter(Object(CFilterChain))
#16 /Users/sbauer/Projekte/yii/web/CController.php(283): CFilterChain->run()
#17 /Users/sbauer/Projekte/yii/web/CController.php(257): 
CController->runActionWithFilters(Object(CInlineAction), Array)
#18 /Users/sbauer/Projekte/yii/web/CWebApplication.php(324): 
CController->run('')
#19 /Users/sbauer/Projekte/yii/web/CWebApplication.php(121): 
CWebApplication->runController('user/auth')
#20 /Users/sbauer/Projekte/yii/base/CApplication.php(135): 
CWebApplication->processRequest()
#21 /Users/sbauer/Projekte/artaius/index.php(21): CApplication->run()
#22 {main}
27.01.2011 12:20:15 Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l 
PHP/5.3.1 mod_perl/2.0.4 Perl/v5.10.1 Yii Framework/1.1.4

Original comment by gjlnetw...@gmail.com on 27 Jan 2011 at 11:21

GoogleCodeExporter commented 9 years ago
Just adding: of course this happens with YumActivity *after* adding your code 
to UserModule.php. So your fix solves at least the problem with the user table.

Original comment by gjlnetw...@gmail.com on 27 Jan 2011 at 11:25

GoogleCodeExporter commented 9 years ago
Ok, got it..

For activites, it's doing a lookup for the key "activities", but the key in the 
_tables array is actually called "activity."

So, changing this:
            'activitiy' => 'activities',

to this:
            'activities' => 'activities',

Solves the latter issue.

Original comment by gjlnetw...@gmail.com on 27 Jan 2011 at 11:37

GoogleCodeExporter commented 9 years ago
Use fixed file instead of original.

Original comment by sergey.m...@gmail.com on 23 Feb 2011 at 10:37

Attachments:

GoogleCodeExporter commented 9 years ago
i close this issue since it is fixed in svn.

please also make sure to set tablePrefix => '' on the db component to let 
everything run properly

Original comment by thyseus on 16 Mar 2011 at 8:22

GoogleCodeExporter commented 9 years ago
I still get the same exception "The table "{{users}}" for active record class 
"YumUser" cannot be found in the database. " 
but I have just downloaded your last version from svn and I dont use 
table_prefix. what can be the problem? am I doing smt wrong?

Original comment by mustafah...@gmail.com on 29 Jun 2011 at 7:25

GoogleCodeExporter commented 9 years ago
after replacing UserModule.php I get this error:

include(YumMessage.php): failed to open stream: No such file or directory 

Original comment by mohamada...@gmail.com on 18 Jul 2011 at 7:31

GoogleCodeExporter commented 9 years ago
I also see the same error after replacing UserModule.php 

Original comment by engg.ri...@gmail.com on 5 Aug 2011 at 1:01

GoogleCodeExporter commented 9 years ago
This error makes me angry to developers :)

So, I download User Manager Module fo Yii but I cann't use it cause of errors, 
and for the current moment this management module is incompetent

Original comment by yura888...@gmail.com on 5 Sep 2011 at 5:30

GoogleCodeExporter commented 9 years ago
Hello,

Any news on the yummessage.php cannot open stream problem?

Original comment by b.tuinma...@gmail.com on 8 Nov 2011 at 10:59

GoogleCodeExporter commented 9 years ago
I have the same problem about YoumMessage.php please help

Original comment by propel...@gmail.com on 21 Feb 2012 at 1:44

GoogleCodeExporter commented 9 years ago
I have the same problem about YoumMessage.php

Original comment by ashraf.a...@gmail.com on 29 Mar 2012 at 3:50

GoogleCodeExporter commented 9 years ago
all becouse table have name 'user' - not 'users'.

Original comment by vasilyev...@gmail.com on 13 Apr 2012 at 12:44

GoogleCodeExporter commented 9 years ago
hey,.any update for YoumMessage.php: cant open stream?

Original comment by eliemaga...@gmail.com on 15 Jul 2012 at 9:14

GoogleCodeExporter commented 9 years ago
Please make sure that you have the following in your application configuration:

'user' => array(
'usersTable' => 'user',
...

Original comment by rikirusd...@gmail.com on 20 Aug 2012 at 3:54

GoogleCodeExporter commented 9 years ago
i want YumMessage.php....

include(YumMessage.php): failed to open stream: No such file or directory 

After replacing UserModule.php  for urs over originals

Original comment by rkram...@aucventures.com on 12 Oct 2012 at 6:12

GoogleCodeExporter commented 9 years ago
Simply change the line $this->_tableName = '{{users}}'; to $this->_tableName = 
'{{user}}'; in models/user/model/YumUser.php . Thanks and enjoy :)

Original comment by sahaniya...@gmail.com on 9 Jan 2013 at 6:27