CMysqlSchema problem

I’m getting this error after moving an Yii application to a CentOS 5.3 linux box:


PHP Error


Descrição


Undefined index: Null


Arquivo Fonte


/home/john/public_html/cbpf/yii-cfc/framework-1.0.9/db/schema/mysql/CMysqlSchema.php(142)


00130: 

00131:     /**

00132:      * Creates a table column.

00133:      * @param array column metadata

00134:      * @return CDbColumnSchema normalized column metadata

00135:      */

00136:     protected function createColumn($column)

00137:     {

00138:             //var_dump($column); die;

00139:         $c=new CMysqlColumnSchema;

00140:         $c->name=$column['Field'];

00141:         $c->rawName=$this->quoteColumnName($c->name);

00142:         $c->allowNull=$column['Null']==='YES';

00143:         $c->isPrimaryKey=strpos($column['Key'],'PRI')!==false;

00144:         $c->isForeignKey=false;

00145:         $c->init($column['Type'],$column['Default']);

00146:         return $c;

00147:     }

00148: 

00149:     /**

00150:      * @return float server version.

00151:      */

00152:     protected function getServerVersion()

00153:     {

00154:         $version=$this->getDbConnection()->getAttribute(PDO::ATTR_SERVER_VERSION);

Rastreamento da Pilha


#0 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/db/schema/mysql/CMysqlSchema.php(114): CMysqlSchema->createColumn()

#1 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/db/schema/mysql/CMysqlSchema.php(66): CMysqlSchema->findColumns()

#2 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/db/schema/CDbSchema.php(73): CMysqlSchema->createTable()

#3 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/db/ar/CActiveRecord.php(2243): CMysqlSchema->getTable()

#4 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/db/ar/CActiveRecord.php(656): CActiveRecordMetaData->__construct()

#5 /home/john/public_html/cbpf/yii-cfc/protected/models/sistema/Usuario.php(11): model()

#6 /home/john/public_html/cbpf/yii-cfc/protected/components/UserIdentity.php(20): model()

#7 /home/john/public_html/cbpf/yii-cfc/protected/models/LoginForm.php(51): UserIdentity->authenticate()

#8 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/validators/CInlineValidator.php(39): LoginForm->authenticate()

#9 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/validators/CValidator.php(161): CInlineValidator->validateAttribute()

#10 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/base/CModel.php(187): CInlineValidator->validate()

#11 /home/john/public_html/cbpf/yii-cfc/protected/controllers/SiteController.php(17): LoginForm->validate()

#12 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/web/actions/CInlineAction.php(32): SiteController->actionLogin()

#13 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/web/CController.php(300): CInlineAction->run()

#14 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/web/filters/CFilterChain.php(129): SiteController->runAction()

#15 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/web/filters/CFilter.php(41): CFilterChain->run()

#16 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/web/CController.php(957): CAccessControlFilter->filter()

#17 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/web/filters/CInlineFilter.php(59): SiteController->filterAccessControl()

#18 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/web/filters/CFilterChain.php(126): CInlineFilter->filter()

#19 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/web/CController.php(283): CFilterChain->run()

#20 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/web/CController.php(257): SiteController->runActionWithFilters()

#21 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/web/CWebApplication.php(332): SiteController->run()

#22 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/web/CWebApplication.php(120): CWebApplication->runController()

#23 /home/john/public_html/cbpf/yii-cfc/framework-1.0.9/base/CApplication.php(135): CWebApplication->processRequest()

#24 /home/john/public_html/cbpf/yii-cfc/index.php(10): CWebApplication->run()

2009-10-10 00:52:54 Apache/2.2.3 (Red Hat) Yii Framework/1.0.9



Dump of $column var used in createColumn function:


array(5) {

["Field"]=> string(10) "id_usuario"

["COLUMN_TYPE"]=> string(16) "int(11) unsigned" 

["COLUMNS"]=> string(2) "NO" 

[""]=> NULL 

["def"]=> string(14) "auto_increment" 

}



Looks like the $column array doesn’t have all the indexes needed.

Any thoughts ?

MySQL version is 5.1.39.

PHP version is 5.3.0.

If I use the mysql utility and issue the command SHOW COLUMNS FROM <tablename> it returns all the column names correctly.

I think it’s not a bug in CMysqlSchema but somehow, in CentOS the result from “SHOW COLUMNS FROM <tablename>” gets treated different from other OSes.

I was using Ubuntu and everything was working fine.

I can’t verify this issue, I don’t personally have CentOS, but you may want to generate schema data in Ubuntu, and cache it while you develop in CentOS.