From dca9b5f3fc8e80ee0667cac88d688e2287b1e7f4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 18 Nov 2010 09:48:50 -0800 Subject: Fix a bug in ORM where calling reload() on an unloaded instance returns the first instance in the database, which is super bad. Kohana ticket: http://dev.kohanaframework.org/issues/3397 Related G3 ticket: http://sourceforge.net/apps/trac/gallery/ticket/1489 --- system/libraries/ORM.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/ORM.php b/system/libraries/ORM.php index 4dd2eaf0..eb34221c 100644 --- a/system/libraries/ORM.php +++ b/system/libraries/ORM.php @@ -1002,7 +1002,11 @@ class ORM_Core { */ public function reload() { - return $this->find($this->object[$this->primary_key]); + if ($this->_loaded) { + return $this->find($this->object[$this->primary_key]); + } else { + return $this->clear(); + } } /** -- cgit v1.2.3