Skip to content
Snippets Groups Projects
Commit b6925cbf authored by Jared Hancock's avatar Jared Hancock
Browse files

orm: Crash if accessing non-existent magic property

parent 2eb9930f
Branches
Tags
No related merge requests found
...@@ -494,7 +494,7 @@ class DynamicFormEntry extends VerySimpleModel { ...@@ -494,7 +494,7 @@ class DynamicFormEntry extends VerySimpleModel {
function getForm() { function getForm() {
if (!isset($this->_form)) { if (!isset($this->_form)) {
$this->_form = DynamicForm::lookup($this->get('form_id')); $this->_form = DynamicForm::lookup($this->get('form_id'));
if ($this->id) if (isset($this->id))
$this->_form->data($this); $this->_form->data($this);
} }
return $this->_form; return $this->_form;
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
vim: expandtab sw=4 ts=4 sts=4: vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/ **********************************************************************/
class OrmException extends Exception {}
class VerySimpleModel { class VerySimpleModel {
static $meta = array( static $meta = array(
'table' => false, 'table' => false,
...@@ -46,6 +48,13 @@ class VerySimpleModel { ...@@ -46,6 +48,13 @@ class VerySimpleModel {
$v = $this->ht[$field] = $class::lookup($this->ht[$j['local']]); $v = $this->ht[$field] = $class::lookup($this->ht[$j['local']]);
return $v; return $v;
} }
throw new OrmException(sprintf('%s: %s: Field not defined',
get_class($this), $field));
}
function __isset($field) {
return array_key_exists($field, $this->ht)
|| isset(static::$meta['joins'][$field]);
} }
function set($field, $value) { function set($field, $value) {
...@@ -86,7 +95,8 @@ class VerySimpleModel { ...@@ -86,7 +95,8 @@ class VerySimpleModel {
// Construct related lists // Construct related lists
if (isset(static::$meta['joins'])) { if (isset(static::$meta['joins'])) {
foreach (static::$meta['joins'] as $name => $j) { foreach (static::$meta['joins'] as $name => $j) {
if (isset($j['list']) && $j['list']) { if (isset($this->{$j['local']})
&& isset($j['list']) && $j['list']) {
$fkey = $j['fkey']; $fkey = $j['fkey'];
$this->{$name} = new InstrumentedList( $this->{$name} = new InstrumentedList(
// Send Model, Foriegn-Field, Local-Id // Send Model, Foriegn-Field, Local-Id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment