diff --git a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterPhpcr.php b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterPhpcr.php index 1cb94024e..e4149c7d9 100644 --- a/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterPhpcr.php +++ b/lib/Doctrine/ODM/PHPCR/Query/Builder/ConverterPhpcr.php @@ -197,13 +197,6 @@ public function getQuery(QueryBuilder $builder) ); } - // be explicit in what we select - if (empty($this->columns)) { - foreach (array_keys($this->sourceDocumentNodes) as $selectorName) { - $this->columns[] = $this->qomf->column($selectorName); - } - } - // for each document source add phpcr:{class,classparents} restrictions foreach ($this->sourceDocumentNodes as $sourceNode) { $documentFqn = $this->aliasMetadata[$sourceNode->getAlias()]->getName(); diff --git a/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/VerifyUniqueNodeTypesMappingCommand.php b/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/VerifyUniqueNodeTypesMappingCommand.php index 5995989dd..c887d9c89 100644 --- a/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/VerifyUniqueNodeTypesMappingCommand.php +++ b/lib/Doctrine/ODM/PHPCR/Tools/Console/Command/VerifyUniqueNodeTypesMappingCommand.php @@ -25,7 +25,8 @@ use Symfony\Component\Console\Output\OutputInterface; /** - * Show information about mapped documents + * Verify that any documents which are mapped as having unique + * node types are truly unique. */ class VerifyUniqueNodeTypesMappingCommand extends Command { @@ -37,11 +38,11 @@ protected function configure() parent::configure(); $this - ->setName('doctrine:phpcr:mapping:verify_unique_node_types') - ->setDescription('Verify that documents with unique node types are correctly mapped') + ->setName('doctrine:phpcr:mapping:verify-unique-node-types') + ->setDescription('Verify that documents claiming to have unique node types are truly unique') ->setHelp(<<%command.name% command checks all mapped PHPCR-ODM documents -and verifies that any marked as having unique node types are, in fact, unique. +and verifies that any claiming to use unique node types are truly unique. EOT ); } @@ -52,8 +53,20 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $documentManager = $this->getHelper('phpcr')->getDocumentManager(); + $uniqueNodeTypeHelper = new UniqueNodeTypeHelper(); - UniqueNodeTypeHelper::checkNodeTypeMappings($documentManager, $output); + $debugInformation = $uniqueNodeTypeHelper->checkNodeTypeMappings($documentManager); + + if (OutputInterface::VERBOSITY_DEBUG <= $output->getVerbosity()) { + foreach ($debugInformation as $className => $debug) { + $output->writeln(sprintf( + 'The document %s uses %snode type %s', + $className, + $debug['unique_node_type'] ? 'uniquely mapped ' : '', + $debug['node_type'] + )); + } + } return 0; } diff --git a/lib/Doctrine/ODM/PHPCR/Tools/Helper/UniqueNodeTypeHelper.php b/lib/Doctrine/ODM/PHPCR/Tools/Helper/UniqueNodeTypeHelper.php index 9063dfedb..021ca1c94 100644 --- a/lib/Doctrine/ODM/PHPCR/Tools/Helper/UniqueNodeTypeHelper.php +++ b/lib/Doctrine/ODM/PHPCR/Tools/Helper/UniqueNodeTypeHelper.php @@ -21,7 +21,6 @@ use Doctrine\ODM\PHPCR\DocumentManagerInterface; use Doctrine\ODM\PHPCR\Mapping\MappingException; -use Symfony\Component\Console\Output\OutputInterface; /** * Provides unique node type mapping verification. @@ -31,17 +30,18 @@ class UniqueNodeTypeHelper /** * Check each mapped PHPCR-ODM document for the given document manager, * throwing an exception if any document is set to use a unique node - * type but the node type is re-used. If an OutputInterface is provided, - * write some basic information to it. + * type but the node type is re-used. Returns an array of debug information. * * @param DocumentManagerInterface $documentManager The document manager to check mappings for. - * @param OutputInterface $output If provided, output will be written here. + * + * @return array * * @throws MappingException */ - public static function checkNodeTypeMappings(DocumentManagerInterface $documentManager, OutputInterface $output = null) + public function checkNodeTypeMappings(DocumentManagerInterface $documentManager) { $knownNodeTypes = array(); + $debugInformation = array(); $allMetadata = $documentManager->getMetadataFactory()->getAllMetadata(); foreach ($allMetadata as $classMetadata) { @@ -56,14 +56,12 @@ public static function checkNodeTypeMappings(DocumentManagerInterface $documentM $knownNodeTypes[$classMetadata->getNodeType()] = $classMetadata->name; - if (!is_null($output)) { - $output->writeln(sprintf( - 'The document %s uses %snode type %s', - $classMetadata->name, - $classMetadata->hasUniqueNodeType() ? 'uniquely mapped ' : '', - $classMetadata->getNodeType() - )); - } + $debugInformation[$classMetadata->name] = array( + 'unique_node_type' => $classMetadata->hasUniqueNodeType(), + 'node_type' => $classMetadata->getNodeType() + ); } + + return $debugInformation; } } diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Tools/Helper/UniqueNodeTypeHelperTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Tools/Helper/UniqueNodeTypeHelperTest.php index f7ac6f903..040823b14 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Tools/Helper/UniqueNodeTypeHelperTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Tools/Helper/UniqueNodeTypeHelperTest.php @@ -68,7 +68,8 @@ public function testCheckNodeTypeMappingsWithDuplicate() $metadataC )); - UniqueNodeTypeHelper::checkNodeTypeMappings($documentManager); + $uniqueNodeTypeHelper = new UniqueNodeTypeHelper(); + $uniqueNodeTypeHelper->checkNodeTypeMappings($documentManager); } /** @@ -93,6 +94,7 @@ public function testCheckNodeTypeMappingsWithoutDuplicate() $metadataC )); - UniqueNodeTypeHelper::checkNodeTypeMappings($documentManager); + $uniqueNodeTypeHelper = new UniqueNodeTypeHelper(); + $uniqueNodeTypeHelper->checkNodeTypeMappings($documentManager); } }