Gii fails to generate model with timeout

Hi there,

Today I found a bit strange situation to me. I opened Gii installed inside my website and when tried to use it to generate model for one of my tables I got error: “Maximum execution time of 60 seconds exceeded in D:\Dev\xampp\yii\db\CDbCommand.php on line 364” followed by “Maximum execution time of 60 seconds exceeded in D:\Dev\xampp\yii\web\CHttpSession.php on line 108”. It repeats, so right now I’m unable to generate Model, for the first time in whole Yii history!

The strangest part is that both DB connection is 100% properly configured and communication to server and DB works like a charm, because seconds after error message from Yii I go to my webapp main page, where in view I wrote a sample SQL statement to test if everything is OK with DB, connection and configuration (I know that using SQLs in view is a very bad manner, but it was just a temporal test).

In other words - I can use my website normally, connection to DB works, results from DB are generated within nanoseconds (all right, I’m kidding, but really fast) and in the same time Gii failes to generate really simple model (table with four columns and three records) with 60 seconds timeout.

I have no bloody idea, what can be wrong? :( Can it be that this strange Gii behaviour is related to using Oracle as RDBMS (never used Gii on it before, always on SQLite or MySQL)? Or that table name contains underscore (_) in name <-- that suspicion is made after attempt with using Giix instead of Gii. It failed too, but not with timeout only with error message that… DB table name can only contain letters, dots and optional asterisk at the end.

Has anyone run into the same situation? Is there anything I can do right now or the only solution left to me is to write model classes by hand?

The 60 seconds timeout is the default PHP timeout for executing scripts…

It means that some part of your script is very very slow… could be the database connection that is slow?

You can increase this timeout in php.ini

Yes, I’m aware of that.

Since I’m using Gii, there are no parts of my code. Gii is hanging with timeout. Rest of webpage works fast, with no problems. Therefore I think that this has to be something different, than connection to database. DB is on the same computer as Yii app (accessed locally via localhost). And I’m able to display whole WWW_USERS table within less then one second, while Gii can’t create model for this table within 60 seconds. This must be something different, but what?

Yes, I know. But in my opinion this will not change anything as rest of the page works fine only Gii hangs with timeout.

P.S.: It hangs on Preview stage. I wasn’t even able to go to actual file creation step.

I don’t see other way to this than to debug… line by line… or better method by method… until you find where is the bottleneck… could be that in the end you find something that needs to be improved in Gii :)

I would rather say that this is caused by Oracle and ActiveRecord at all. I heard at least five different people saying that I’m mad trying to use PHP with Oracle in ActiveRecord manner and that DAO is the only option. Which, to be honest, makes me sad, as I have to use Oracle and love AR.

I’ll do some debug to see if I can find something specific.

For right now I have two additional observations:

[list=1][]Connection works for sure, even inside Gii. If I type non-existing table name into Model generator it is handled without any problems and after 2-3 second I receive correct error message saying that table was not found in database.[]I have strange problems enlarging max_execution_time setting in php.ini. I’ve set it to 600 seconds but Gii still hangs after only 60 seconds. I’ve tried to both restart server (Apache2 inside XAMPP 1.7.3) and whole machine running it, with no result - still hanging on 60 seconds, though configuration remains set to 600 seconds. They wrote here that they might be something overwritten in server configuration itself. For example: Apache has a Timeout directive, according to mentioned document. But I can’t find neither this nor any other time-related directive inside httpd.conf, therefore I have no idea, why scripts hangs after only 60 seconds.[/list]

As I said, I’ll try to do some debug.

I went back to the problem after a week and found out following:

  1. I switched my DB (in app configuration) for a moment to MySQL and model generation in Gii went with no problems.

  2. Right now (after switching back to Oracle) Gii does not fails with timeout, only displays error message saying "Undefined index: SCHEMA_NAME".

Here is a dump of logging component for above error, if this can say something:

Undefined index: SCHEMA_NAME ({srv_path}\yii\db\schema\oci\COciSchema.php:273)

Stack trace:

#0 {srv_path}\yii\gii\generators\model\ModelCode.php(234): COciSchema->getTables()

#1 {srv_path}\yii\gii\generators\model\ModelCode.php(87): ModelCode->generateRelations()

#2 {srv_path}\yii\gii\CCodeGenerator.php(158): ModelCode->prepare()

#3 {srv_path}\yii\gii\CCodeGenerator.php(61): ModelGenerator->prepare()

#4 {srv_path}\yii\web\actions\CInlineAction.php(50): ModelGenerator->actionIndex()

#5 {srv_path}\yii\web\CController.php(300): CInlineAction->run()

#6 {srv_path}\yii\web\CController.php(278): ModelGenerator->runAction()

#7 {srv_path}\yii\web\CController.php(257): ModelGenerator->runActionWithFilters()

#8 {srv_path}\yii\web\CWebApplication.php(324): ModelGenerator->run()

#9 {srv_path}\yii\web\CWebApplication.php(121): CWebApplication->runController()

#10 {srv_path}\yii\base\CApplication.php(135): CWebApplication->processRequest()

#11 {srv_path}\htdocs\{app_name}\index.php(17): CWebApplication->run()

I’m not that far experienced with gii and yii core code, but it seems to me that this is a bug in DB component in Oracle Schema, not in my application.

mdomba, can you please tell me if this is worth opening bug ticket?

I don’t have oracle, only mysql & postgres, so I can’t realy help you much here…

Just checked the COciSchema.php on line 273, I have there the begin of the function findTableName()

Try with the latest Yii from trunk … there where some fixes about OCI …

All right, thanks! I’ll give it a try.

The only think that surprises me is that only Gii fails on it. I’m using Active Record (as Gii uses, if I’m not mistaken) in the same application and it works very well - i.e. all models and CRUD files I generated with Gii to another project and only adopted to this Oracle application works fine. This would suggest that even if COciSchema reports the error, it should be somewhere inside Gii, not Active Record. Am I right?

If someone is interested in this topic, please continue in this Wiki article, where one of possible solutions (for making Gii work and speeding up ActiveRecord on Oracle) is presented.

Use cache.

The first try on Gii will fail, but it will build the cache.

The next attempts will work like a charm!

About using cache I answered in article (as comment to it).

I’m not pretty sure, if this is a good idea to saying users that something is not working, because you’re not using cache? Cache isn’t obligatory or mandatory to be used in every project and Gii should work also without it for Oracle. Sorry, but I find is as a bug and that is why I reported it here to gather more information about it.


Is this problem now solved in Yii or is solution provided?

I have the time-out error on creating a model with Gii (yii-1.1.7.r3135) from a table in an Oracle (11g) database.

These are the dll’s i have (not) enabled in php.ini:








‘looks’ ok, but i am not sure.