From df7dc0d4dd7fa7c08e74cf476dc441ef4112a6d2 Mon Sep 17 00:00:00 2001 From: Karsten Dambekalns Date: Wed, 21 Nov 2018 10:41:25 +0100 Subject: [PATCH] BUGFIX: Throw MappingException in loadMetaDataForClass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When no class schema can be found in `loadMetaDataForClass`, a Doctrine `MappingException` is now thrown. This makes our code work nicely with the change in https://github.com/doctrine/doctrine2/pull/7471/ that otherwise leads to errors like this as of ORM 2.6.3: ``` FlowAnnotationDriver.php: No class schema found for "some-non-mapped-class". 89 …\FlowAnnotationDriver_Original::getClassSchema("some-non-mapped-class") 88 …\FlowAnnotationDriver_Original::loadMetadataForClass("some-non-mapped-class", Neos\Flow\Persistence\Doctrine\Mapping\ClassMetadata) ``` Fixes #1453 --- .../Doctrine/Mapping/Driver/FlowAnnotationDriver.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Neos.Flow/Classes/Persistence/Doctrine/Mapping/Driver/FlowAnnotationDriver.php b/Neos.Flow/Classes/Persistence/Doctrine/Mapping/Driver/FlowAnnotationDriver.php index 7319a70907..b0f1e5d5e0 100644 --- a/Neos.Flow/Classes/Persistence/Doctrine/Mapping/Driver/FlowAnnotationDriver.php +++ b/Neos.Flow/Classes/Persistence/Doctrine/Mapping/Driver/FlowAnnotationDriver.php @@ -178,9 +178,13 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) * @var ORM\ClassMetadata $metadata */ - $class = $metadata->getReflectionClass(); - $classSchema = $this->getClassSchema($class->getName()); - $classAnnotations = $this->reader->getClassAnnotations($class); + try { + $class = $metadata->getReflectionClass(); + $classSchema = $this->getClassSchema($class->getName()); + $classAnnotations = $this->reader->getClassAnnotations($class); + } catch (ClassSchemaNotFoundException $exception) { + throw new ORM\MappingException(sprintf('Failure while fetching class schema class "%s": %s', $metadata->getName(), $exception->getMessage()), 1542792708, $exception); + } // Evaluate Entity annotation if (isset($classAnnotations[ORM\MappedSuperclass::class])) {