Closed albertborsos closed 3 months ago
I was not fully accurate in the description. schemaCachingDuration
has effect, because it caches the schema, but after the duration it does not invalidate the cached schema.
If I read the code correctly, the duration is used between requests. But within one request table data is always cached (in https://github.com/yiisoft/yii/blob/master/framework/db/schema/CDbSchema.php#L34 which is always checked first in https://github.com/yiisoft/yii/blob/master/framework/db/schema/CDbSchema.php#L74). Can you confirm this is the case for you?
If you need to force new schema data within one request, you can call schema->refresh() as you've probably already seen.
thanks @marcovtwout , we have issues between requests. So you are right, my test cases are not correct. I will update it soon.
Since then I realized we use a custom cache which stores data in couchbase (correctly with expiration), but I have to investigate it more deeply.
For now, I close this ticket, since there is a lack of chance there is this bug in the framework for 10+ years.
Thanks.
I realized the
CDbConnection.schemaCachingDuration
property has no effect. We use this config only in staging and production, but after the deploy we get exceptions for missing attributes.That is why I wrote this test to prove that
schemaCachingDuration
settings does not work.You can run this test from the
tests
folder:php ../vendor/bin/phpunit framework/db/CDbConnectionTest.php --filter testSchemaCachingDuration