From 57d007929e2a1c8f71b94441c104395b138f58d3 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Tue, 25 Nov 2014 08:49:53 -0600 Subject: [PATCH] orm: Call __onload() after refetching new objects --- include/class.orm.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/class.orm.php b/include/class.orm.php index 26ef6e6b8..3ea8898bd 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -361,6 +361,7 @@ class VerySimpleModel { } $pk = static::$meta['pk']; + $wasnew = $this->__new__; if ($this->__new__) { if (count($pk) == 1) @@ -368,7 +369,6 @@ class VerySimpleModel { $this->ht[$pk[0]] = $ex->insert_id(); $this->__new__ = false; Signal::send('model.created', $this); - $this->__onload(); } else { $data = array('dirty' => $this->dirty); @@ -383,6 +383,8 @@ class VerySimpleModel { $self = static::lookup($this->get('pk')); $this->ht = $self->ht; } + if ($wasnew) + $this->__onload(); $this->dirty = array(); return $this->get($pk[0]); } -- GitLab