Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getEavAttribute('attributeName') returns no data #9

Open
alexglue opened this issue Feb 18, 2015 · 0 comments
Open

getEavAttribute('attributeName') returns no data #9

alexglue opened this issue Feb 18, 2015 · 0 comments

Comments

@alexglue
Copy link

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:

  1. do not use 'safeAttributes' => [], with empty array
  2. or do not use preload = false with empty array!
  3. 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);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant