yiisoft / yii2-gii

Yii 2 Gii Extension
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
203 stars 192 forks source link

gii/crud has been generate view based at the old structure of model (cached data) #276

Open yii-bot opened 7 years ago

yii-bot commented 7 years ago

This issue has originally been reported by @bscheshirwork at https://github.com/yiisoft/yii2/issues/14210. Moved here by @samdark.


What steps will reproduce the problem?

What is the expected result?

new views (and search model) in previews & generate result

What do you get instead?

old views (same at previous)

Additional info

after console command

./yii cache/flush-schema
Flush cache schema for "db" connection? (yes|no) [no]:yes
Schema cache for component "db", was flushed.

all is ok.

Q A
Yii version 2.0.? dev-master 55c0799
PHP version 7.1.5
Operating system alpine
cebe commented 7 years ago

are you using APC cache?

bscheshirwork commented 7 years ago

I will install APCu and don't change configuration or settings of cache component (default yii2-advanced template settings) https://github.com/bscheshirwork/docker-php/blob/master/yii2-alpine/Dockerfile#L67

        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
./yii cache/index
The following caches were found in the system:

    * cache (yii\caching\FileCache)

So...

docker exec -ti dockerrun_php_1 php -i |grep 'apc.enable_cli'
apc.enable_cli => Off => Off
docker exec -ti dockerrun_php_1 php ./requirements.php
...
APC extension: WARNING!!!
Required by: ApcCache

This is can be as reason?

Console command migration and console command cache is not both use same CLI? Or use someone API?

cebe commented 7 years ago

If you flush cache on CLI but web is running in another container, that will have no effect. This is often the case with ApcCache, but can also occur with FileCache when files are located in different locations or containers.

cebe commented 7 years ago

That said, given that Gii is a dev tool we might add a flush schema cache call in the generator to ensure to always generate files from current schema.

bscheshirwork commented 7 years ago

Hm... backend db cache is a different/separate and don't flush after flush console db schema cache? Console run migrate with

Yii::$app->db->schema->refresh();

Has no effect to backend caches Yii::$app->db->schema and/or frontend and any of this is isolate...

I must use

 (new \yii\console\controllers\CacheController('cache', Yii::$app->module))->actionFlushSchema();

to clear all (is 3min for advances) version of db cache?

bscheshirwork commented 7 years ago

Oh... Its same command

        $connection = Yii::$app->get($db, false);
...
            $schema = $connection->getSchema();
            $schema->refresh();

and run all console command in same container

But it's work... %)

What else? Gii cache in high level don't clear if low-level db cache flush? %)