Permalink
Browse files

Fix a bug in ORM where calling reload() on an unloaded instance retur…

…ns 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
  • Loading branch information...
bharat committed Nov 18, 2010
1 parent add586b commit dca9b5f3fc8e80ee0667cac88d688e2287b1e7f4
Showing with 5 additions and 1 deletion.
  1. +5 −1 system/libraries/ORM.php
View
@@ -1002,7 +1002,11 @@ public function clear()
*/
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();
+ }
}
/**

0 comments on commit dca9b5f

Please sign in to comment.