hi all,
I’m not sure this is a bug but it looks like one to me. Here is what happened : I wrote a behavior that under certain circumstances (for instance the owner model doesn’t have a specific attribute) is supposed to disable itself. When this behavior is the only one attached to a component, everything is ok, but when a component already has other behaviors and mine is added, the following exception is raised.
Description
Undefined offset: 1
Source File
I:\home\project\lib\php\yii\yii-1.1.5.r2654\framework\collections\CListIterator.php(73)
To reproduce here is a DummyBehavior to create in application/components :
<?php
class DummyBehavior extends CActiveRecordBehavior {
public function beforeSave($event) {
$this->enabled=false;
}
}
?>
… then add it to an existing CActiveRecord model :
<?php
// ....
public function behaviors(){
return array(
'dummyBehavior' => array(
'class' => 'application.components.DummyBehavior',
),
'dummyBehavior2' => array(
'class' => 'application.components.DummyBehavior',
)
);
}
…and then save the model.
For instance I used this technique to add the zii.behaviors.CTimeStampBehavior to all my models (add behavior to their common base class) and disable it when there is no create or update column defined for a table. As enabled is a public member, it seemed logical …
What do you think ? bug or not bug ?
ciao