From 4b138cfe0b3b13538a60d9a259deaee5e220d7ab Mon Sep 17 00:00:00 2001 From: Zauberfisch Date: Mon, 28 Oct 2013 01:12:46 +0000 Subject: [PATCH] Check if remote class exists in DataObject->getRemoteJoinField() --- model/DataObject.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/model/DataObject.php b/model/DataObject.php index 73014946d..404272373 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -1528,6 +1528,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity if(!$remoteClass) { throw new Exception("Unknown $type component '$component' on class '$this->class'"); } + if(!ClassInfo::exists(strtok($remoteClass, '.'))) { + throw new Exception( + "Class '$remoteClass' not found, but used in $type component '$component' on class '$this->class'" + ); + } if($fieldPos = strpos($remoteClass, '.')) { return substr($remoteClass, $fieldPos + 1) . 'ID'; @@ -1546,8 +1551,9 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $message = "No has_one found on class '$remoteClass'"; if($type == 'has_many') { - // include a hint for missing has_many that is missing a has_one - $message .= ", the has_many relation from '$this->class' to '$remoteClass' requires a has_one on '$remoteClass'"; + // include a hint for has_many that is missing a has_one + $message .= ", the has_many relation from '$this->class' to '$remoteClass'"; + $message .= " requires a has_one on '$remoteClass'"; } throw new Exception($message); }