Neos.ContentRepository/Classes/Command/NodeCommandControllerPlugin.php
protected function collectNodesWithInvalidWorkspace()
    {
        $nodes = [];
        $workspaceNames = [];

        foreach ($this->workspaceRepository->findAll() as $workspace) {
            $workspaceNames[] = $workspace->getName();
        }

        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->select('n')
            ->from(NodeData::class, 'n')
            ->add('where', $queryBuilder->expr()->orX(
                    $queryBuilder->expr()->notIn('n.workspace', $workspaceNames),
                    $queryBuilder->expr()->isNull('n.workspace')
                )
            );

        foreach ($queryBuilder->getQuery()->getArrayResult() as $nodeDataArray) {
            $this->dispatch(self::EVENT_NOTICE, sprintf('Node <i>%s</i> (identifier: <i>%s</i>) refers to an invalid workspace: <i>%s</i>', $nodeDataArray['path'], $nodeDataArray['identifier'], (isset($nodeDataArray['workspace']) ? $nodeDataArray['workspace'] : 'null')));
            $nodes[] = $nodeDataArray;
        }
        return $nodes;
    }
protected function collectNodesWithInvalidWorkspace()
    {
        $nodes = [];
        $workspaceNames = [];

        foreach ($this->workspaceRepository->findAll() as $workspace) {
            $workspaceNames[] = $workspace->getName();
        }

        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->select('n')
            ->from(NodeData::class, 'n')
            ->add('where', $queryBuilder->expr()->orX(
                    $queryBuilder->expr()->notIn('n.workspace', $workspaceNames),
                    $queryBuilder->expr()->isNull('n.workspace')
                )
            );

        foreach ($queryBuilder->getQuery()->getArrayResult() as $nodeDataArray) {
            $this->dispatch(self::EVENT_NOTICE, sprintf('Node <i>%s</i> (identifier: <i>%s</i>) refers to an invalid workspace: <i>%s</i>', $nodeDataArray['path'], $nodeDataArray['identifier'], (isset($nodeDataArray['workspace']) ? $nodeDataArray['workspace'] : 'null')));
            $nodes[] = $nodeDataArray;
        }
        return $nodes;
    }
protected function collectNodesWithInvalidWorkspace ( ) { $ nodes = [ ] ; $ workspaceNames = [ ] ; foreach ( $ this -> workspaceRepository -> findAll ( ) as $ workspace ) { $ workspaceNames [ ] = $ workspace -> getName ( ) ; } /** @var QueryBuilder $queryBuilder */ $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'n' ) -> from ( NodeData :: class , 'n' ) -> add ( 'where' , $ queryBuilder -> expr ( ) -> orX ( $ queryBuilder -> expr ( ) -> notIn ( 'n.workspace' , $ workspaceNames ) , $ queryBuilder -> expr ( ) -> isNull ( 'n.workspace' ) ) ) ; foreach ( $ queryBuilder -> getQuery ( ) -> getArrayResult ( ) as $ nodeDataArray ) { $ this -> dispatch ( self :: EVENT_NOTICE , sprintf ( 'Node <i>%s</i> (identifier: <i>%s</i>) refers to an invalid workspace: <i>%s</i>' , $ nodeDataArray [ 'path' ] , $ nodeDataArray [ 'identifier' ] , ( isset ( $ nodeDataArray [ 'workspace' ] ) ? $ nodeDataArray [ 'workspace' ] : 'null' ) ) ) ; $ nodes [ ] = $ nodeDataArray ; } return $ nodes ; }
Collects all nodes of the given node type which refer to an invalid workspace
configuration.

Note: due to the foreign key constraints in the database, there actually never should
be any node with n.workspace of a non-existing workspace because if that workspace
does not exist anymore, the value would turn NULL. But the query covers this nevertheless.
Better safe than sorry.

@return array
Collects all nodes of the given node type which refer to an invalid workspace configuration .