diff --git a/core/model/DataObject.php b/core/model/DataObject.php index 80eb7c8fe..2ca99fc1a 100755 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -2605,8 +2605,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity // Get the tables to join to $tableClasses = ClassInfo::dataClassesFor($this->class); if(!$tableClasses) { - if(!ManifestBuilder::has_been_included()) { - user_error("DataObjects have been requested before the manifest is loaded. Please ensure you are not querying the database in _config.php.", E_USER_ERROR); + if (!DB::getConn()) { + throw new Exception('DataObjects have been requested before' + . ' a DB connection has been made. Please ensure you' + . ' are not querying the database in _config.php.'); } else { user_error("DataObject::buildSQL: Can't find data classes (classes linked to tables) for $this->class. Please ensure you run dev/build after creating a new DataObject.", E_USER_ERROR); }