-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Model.php:
'eavAttr' => array(
'class' => 'application.components.behaviors.EEavBehavior',
'tableName' => 'project_eav',
'entityField' => 'project_id',
'safeAttributes' => [], //empty array! btw, I have three eav-fields for this model
'preload' => false, //preload false!
'cacheId' => 'cache'
)
i have three attributes stored in db for Model->id instance:
attribute1=OK
attribute2=OK
attribute3=OK
Now, you should turn on CMemCache etc,
then make flush_all; //!important
and use in template smth like this:
$appealText = $this->project->getEavAttribute('attribute1'); //it's OK!
$appealText = $this->project->getEavAttribute('attribute2'); //it's NULL!
$appealText = $this->project->getEavAttribute('attribute3'); //it's NULL!
Thats all folks! you have a broken cache data!
The possible solution are following:
- do not use 'safeAttributes' => [], with empty array
- or do not use preload = false with empty array!
- or use smth like this:
$eavAttributes = $this->project->getEavAttributes(['attribute1','attribute2','attribute3']);
before getting the first one!
The root of evil is:
public function getEavAttribute($attribute) {
$values = $this->getEavAttributes(array($attribute)); //storing to cache only the first value!
return $this->attributes->itemAt($attribute);
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels