1
0
mirror of synced 2025-01-31 12:32:59 +03:00

Merge remote branch 'origin/DDC-597'

This commit is contained in:
beberlei 2010-07-01 19:43:15 +02:00
commit 178f35aaa1

View File

@ -55,12 +55,13 @@ class SchemaValidator
/** /**
* Checks the internal consistency of mapping files. * Checks the internal consistency of mapping files.
* *
* There are several checks that can't be done at runtime or are to expensive, which can be verified * There are several checks that can't be done at runtime or are too expensive, which can be verified
* with this command. For example: * with this command. For example:
* *
* 1. Check if a relation with "mappedBy" is actually connected to that specified field. * 1. Check if a relation with "mappedBy" is actually connected to that specified field.
* 2. Check if "mappedBy" and "inversedBy" are consistent to each other. * 2. Check if "mappedBy" and "inversedBy" are consistent to each other.
* 3. Check if "referencedColumnName" attributes are really pointing to primary key columns. * 3. Check if "referencedColumnName" attributes are really pointing to primary key columns.
* 4. Check if there are public properties that might cause problems with lazy loading.
* *
* @return array * @return array
*/ */
@ -71,9 +72,9 @@ class SchemaValidator
$classes = $cmf->getAllMetadata(); $classes = $cmf->getAllMetadata();
foreach ($classes AS $class) { foreach ($classes AS $class) {
$ce = array();
/* @var $class ClassMetadata */ /* @var $class ClassMetadata */
foreach ($class->associationMappings AS $fieldName => $assoc) { foreach ($class->associationMappings AS $fieldName => $assoc) {
$ce = array();
if (!$cmf->hasMetadataFor($assoc->targetEntityName)) { if (!$cmf->hasMetadataFor($assoc->targetEntityName)) {
$ce[] = "The target entity '" . $assoc->targetEntityName . "' specified on " . $class->name . '#' . $fieldName . ' is unknown.'; $ce[] = "The target entity '" . $assoc->targetEntityName . "' specified on " . $class->name . '#' . $fieldName . ' is unknown.';
} }
@ -171,10 +172,17 @@ class SchemaValidator
} }
} }
} }
}
if ($ce) { foreach ($class->reflClass->getProperties(\ReflectionProperty::IS_PUBLIC) as $publicAttr) {
$errors[$class->name] = $ce; if ($publicAttr->isStatic()) {
continue;
} }
$ce[] = "Field '".$publicAttr->getName()."' in class '".$class->name."' must be private or protected. Public fields break lazy-loading.";
}
if ($ce) {
$errors[$class->name] = $ce;
} }
} }
@ -183,7 +191,7 @@ class SchemaValidator
/** /**
* Check if the Database Schema is in sync with the current metadata state. * Check if the Database Schema is in sync with the current metadata state.
* *
* @return bool * @return bool
*/ */
public function schemaInSyncWithMetadata() public function schemaInSyncWithMetadata()