yiisoft / yii

Yii PHP Framework 1.1.x
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
4.84k stars 2.28k forks source link

Fatal error: Uncaught CDbException: The table "tablename" for active record class "TablenameRecord" cannot be found in the database. #4498

Closed alexius closed 1 year ago

alexius commented 1 year ago

There is another problem too - when we use the cache (php8+Yii+Redis), we get this problem:

Fatal error: Uncaught CDbException: The table "tablename" for active record class "TablenameRecord" cannot be found in the database. in /srv/www/htdocs/.../framework/db/ar/CActiveRecord.php on line 2391 CDbException: The table "tablename" for active record class "TablenameRecord" cannot be found in the database. in /srv/www/htdocs/.../framework/db/ar/CActiveRecord.php on line 2391 When we cancel the use of the cache, the error disappears. Just comment out these lines in main.conf:

'cache'=>array( 'class'=>'CRedisCache', 'hostname'=> 'localhost', 'port'=>6379, 'database'=>1, )

The table is existed in DB.

Here is a trace:

CActiveRecord->getTableSchema( ) | .../CActiveRecord.php:1526 CActiveRecord->getMetaData( ) | .../CActiveRecord.php:663 CActiveRecordMetaData->__construct( $model = class TablenameRecord { private ${CComponent}_e = NULL; private ${CComponent}_m = NULL; private ${CModel}_errors = []; private ${CModel}_validators = NULL; private ${CModel}_scenario = ''; private ${CActiveRecord}_new = FALSE; private ${CActiveRecord}_attributes = []; private ${CActiveRecord}_related = []; private ${CActiveRecord}_c = NULL; private ${CActiveRecord}_pk = NULL; private ${CActiveRecord}_alias = 't' } ) | .../CActiveRecord.php:413

What steps will reproduce the problem?

It happens during opening the page of web site.

What is the expected result?

The page should by loaded normally.

What do you get instead?

Got fatal error.

Additional info

Q A
Yii version 1.1.27
PHP version 8.1.2
Operating system Ubuntu 22.04.1 LTS
marcovtwout commented 1 year ago

@alexius "It happens during opening the page of web site." is not enough info for anyone to reproduce your issue. Please provide detailed code/steps if you think this is a framework bug that should be investigated and fixed. If you need general support, try options here: https://www.yiiframework.com/community

alexius commented 1 year ago

@marcovtwout I will try to get more info. For now, it's difficult to say what exactly produces this error.

marcovtwout commented 1 year ago

So far this doesn't look like a framework issue, closing.