From 781691e5c8ed6f1585fc263a9223722fdaa3ba49 Mon Sep 17 00:00:00 2001 From: marcovtwout Date: Tue, 27 Mar 2012 11:43:21 +0200 Subject: [PATCH] FIX: Issue #553 - restore criteria on related model after find when using 'with' and 'scopes'. --- CHANGELOG | 1 + framework/db/ar/CActiveFinder.php | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index fe8ab22ab..82754373f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ Version 1.1.11 work in progress - Bug #454: Removed translation on CDbConnection exception as it was creating an endless loop if the application used CDbCache (mdomba) - Bug #517: Rule parameter sub-patterns are not checked correctly (ranvis) - Bug #539: Fixed CUrlRule::createUrl() to treat sub-patterns as Unicode as parseUrl() does (ranvis) +- Bug #553: Restore dbCriteria on related record after doing an AR-find with related scopes (marcovtwout) - Enh #136: Added ability to select database connection in Gii model generator (samdark) - Enh #165: Allow CCacheDependency to be reusable across multiple cache calls (phpnode) - Enh #171: Added support for PUT and DELETE request tunneled through POST via parameter named _method in POST body (musterknabe) diff --git a/framework/db/ar/CActiveFinder.php b/framework/db/ar/CActiveFinder.php index 0a97e5765..4233a03e8 100644 --- a/framework/db/ar/CActiveFinder.php +++ b/framework/db/ar/CActiveFinder.php @@ -217,6 +217,9 @@ class CActiveFinder extends CComponent $relation=clone $relation; $model=CActiveRecord::model($relation->className); + + $oldDbCriteria = $model->getDbCriteria(false); + if($relation instanceof CActiveRelation) { $oldAlias=$model->getTableAlias(false,false); @@ -272,6 +275,8 @@ class CActiveFinder extends CComponent } } + $model->setDbCriteria($oldDbCriteria); + // dynamic options if($options!==null) $relation->mergeWith($options);