| Issue 153: | Bug with calls like MyActiveRecord->withText()->withUser()->find(...) and null result | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
1. call MyActiveRecord->withText()->withUser()->find(...) (important: at
least 2 times withXXX()) with a criteria such that the result is NULL (no
record found)
2. then use another ActiveRecord like this: MyOtherActiveRecord-
>withSomething()->find(...) (important: at least one withXXX())
What is the expected output? What do you see instead?
It will complain about properties not found in MyOtherActiveRecord (unless
MyOtherActiveRecord doesn't have the same properties as MyActiveRecord).
Version:
prado 3.1.5a
Fix proposition:
The problem lies in class TActiveRecordRelation, method __call: If the
result of find() is null, the static variable $stack still references some
stuff related to the ActiveRecord. If you then use another ActiveRecord
these references are confusing it. Therefore I propose to clear the
"stack" if the result is null. Like this:
modify method TActiveRecordRelation::__call() as follows:
[code]
if ($validArray || ...) {
...
}
elseif($results instanceof TActiveRecordRelation)
$stack[] = $this; //call it later
elseif ($results === null) {
$stack = array();
}
[/code]
|
|
,
May 29, 2009
(No comment was entered for this change.)
Labels: -Milestone-3.1.5 Milestone-3.1.6
|
|
,
Jul 22, 2009
Move to 3.1.7
Labels: Milestone-3.1.7
|
|
,
Aug 17, 2009
This modifications maybe works :
else if ($results === null || !$validArray)
{
$stack = array();
}
|
|
|
|