summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-11-18 09:48:50 -0800
committerBharat Mediratta <bharat@menalto.com>2010-11-18 09:48:50 -0800
commitdca9b5f3fc8e80ee0667cac88d688e2287b1e7f4 (patch)
tree175bdf4d16b50e66e93c957fcc63e7c8f47d6502
parentadd586bbb129280badb484ae0fdaaa10372e4dc7 (diff)
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
-rw-r--r--system/libraries/ORM.php6
1 files changed, 5 insertions, 1 deletions
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();
+ }
}
/**