Since it's a minor version upgrade, I totally didn't expect it to completely break my site. There seems to be something significantly different in the way related objects are loaded.
I now get "Invalid argument supplied for foreach()" whenever I try to lazily access a related object.
In my model, I implement afterFind:
protected function afterFind() {
if(isset($this->id)) {
$tags = $this->tags;
$tagInputs = array();
foreach($tags as $tag)
$tagInputs[] = $tag->name;
....
}
....
}
The call to foreach throws the error.
Anyone have a clue as to why this isn't working in 1.0.3?
Everything ran like a charm in 1.0.2
Thanks
Mike
qiang
(Qiang Xue)
March 18, 2009, 8:08pm
2
I think this is caused by the fix of this issue: http://code.google.c…s/detail?id=153
I'm trying to fix it now.
qiang
(Qiang Xue)
March 18, 2009, 8:17pm
3
hmm…I couldn't reproduce the issue.
What is 'tags' in your code? Is it a column or a relation?
I used the blog demo to do the test and with your code, I couldn't see problem.
It's a relation:
'tags'=>array(self::MANY_MANY, 'Tag', 'PostTag(postId, tagId)'),
Also, when I comment out that bit of code, other relations that I attempt to load following that also throw the same error.
qiang
(Qiang Xue)
March 19, 2009, 12:01am
5
Could you please show me this AR class and possibly the corresponding table structure?
I just sent you a private message with the details. Keep in mind that everything works under 1.0.2.
qiang thanks again for your help! One of the many reasons I was able to stick with Yii is because of your prompt and courteous help.
Peace
Mike