From 03b58e8ec6ff19ebc9d072a26e7b8be3f53dd9ef Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 18 Aug 2011 22:25:56 -0500 Subject: [PATCH 1/2] fixed belongs_to eager loading bug. --- system/db/eloquent/hydrator.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/system/db/eloquent/hydrator.php b/system/db/eloquent/hydrator.php index 6c7b3d6c..682bd4b3 100644 --- a/system/db/eloquent/hydrator.php +++ b/system/db/eloquent/hydrator.php @@ -66,13 +66,15 @@ class Hydrator { */ private static function eagerly($eloquent, &$parents, $include) { - // We temporarily spoof the belongs_to key to allow the query to be fetched without - // any problems, since the belongs_to method actually gets the attribute. - $eloquent->attributes[$spoof = $include.'_id'] = 0; + // We temporarily spoof the query attributes to allow the query to be fetched without + // any problems, since the belongs_to method actually gets the related attribute. + $first = reset($parents); + + $eloquent->attributes = $first->attributes; $relationship = $eloquent->$include(); - unset($eloquent->attributes[$spoof]); + $eloquent->attributes = array(); // Reset the WHERE clause and bindings on the query. We'll add our own WHERE clause soon. // This will allow us to load a range of related models instead of only one. From b31f13d99f04019fde225382f586c71b7837e8c7 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 18 Aug 2011 22:27:21 -0500 Subject: [PATCH 2/2] incremented version and change log. --- changelog.md | 8 ++++++++ public/index.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 1a3bd2c1..b4716a5c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Laravel Change Log +## Version 1.5.4 + +- Fix bug in Eloquent belongs_to relationship eager loading. + +### Upgrading From 1.5.3 + +- Replace **system** directory. + ## Version 1.5.3 - Various bug fixes. diff --git a/public/index.php b/public/index.php index d84a4d8f..4600f7a5 100644 --- a/public/index.php +++ b/public/index.php @@ -3,7 +3,7 @@ * Laravel - A clean and classy framework for PHP web development. * * @package Laravel - * @version 1.5.3 + * @version 1.5.4 * @author Taylor Otwell * @link http://laravel.com */