Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Cleanup and stabilize Neos.ContentGraph.DoctrineDbalAdapter #5088

Merged
merged 9 commits into from
May 26, 2024
29 changes: 18 additions & 11 deletions Neos.ContentGraph.DoctrineDbalAdapter/src/ContentGraphFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Neos\ContentGraph\DoctrineDbalAdapter;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\ContentGraph;
use Neos\ContentGraph\DoctrineDbalAdapter\Domain\Repository\NodeFactory;
use Neos\ContentRepository\Core\ContentGraphFactoryInterface;
Expand Down Expand Up @@ -46,22 +47,28 @@ public function buildForWorkspace(WorkspaceName $workspaceName): ContentGraph
'workspace'
));

$row = $this->dbal->executeQuery(
'
SELECT * FROM ' . $tableName . '
WHERE workspaceName = :workspaceName
LIMIT 1
',
[
$currentContentStreamIdStatement = <<<SQL
SELECT
currentcontentstreamid
FROM
{$tableName}
WHERE
workspaceName = :workspaceName
LIMIT 1
SQL;
mhsdesign marked this conversation as resolved.
Show resolved Hide resolved
try {
$currentContentStreamId = $this->dbal->fetchOne($currentContentStreamIdStatement, [
'workspaceName' => $workspaceName->value,
]
)->fetchAssociative();
]);
} catch (Exception $e) {
throw new \RuntimeException(sprintf('Failed to load workspace content stream id from database: %s', $e->getMessage()), 1716486077, $e);
}

if ($row === false) {
if ($currentContentStreamId === false) {
throw WorkspaceDoesNotExist::butWasSupposedTo($workspaceName);
}

return $this->buildForWorkspaceAndContentStream($workspaceName, ContentStreamId::fromString($row['currentcontentstreamid']));
return $this->buildForWorkspaceAndContentStream($workspaceName, ContentStreamId::fromString($currentContentStreamId));
}

public function buildForWorkspaceAndContentStream(WorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraph
Expand Down
Loading
Loading