Skip to content

Commit

Permalink
Merge branch '9.0' into task/contentCacheFlusher-followup
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Schmitt committed Oct 23, 2024
2 parents 66c5513 + 300a279 commit ed605bd
Show file tree
Hide file tree
Showing 494 changed files with 10,382 additions and 8,273 deletions.
4 changes: 2 additions & 2 deletions .composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@test:behat-cli -c Neos.ContentRepository.Export/Tests/Behavior/behat.yml.dist",
"@test:behat-cli -c Neos.TimeableNodeVisibility/Tests/Behavior/behat.yml.dist",
"../../flow doctrine:migrate --quiet; ../../flow cr:setup",
"@test:behat-cli -c Neos.Neos/Tests/Behavior/behat.yml"
"@test:behat-cli -c Neos.Neos/Tests/Behavior/behat.yml.dist"
],
"test:behavioral:stop-on-failure": [
"@test:behat-cli -vvv --stop-on-failure -c Neos.ContentRepository.BehavioralTests/Tests/Behavior/behat.yml.dist",
Expand All @@ -47,7 +47,7 @@
"@test:behat-cli -vvv --stop-on-failure -c Neos.ContentRepository.Export/Tests/Behavior/behat.yml.dist",
"@test:behat-cli -vvv --stop-on-failure -c Neos.TimeableNodeVisibility/Tests/Behavior/behat.yml.dist",
"../../flow doctrine:migrate --quiet; ../../flow cr:setup",
"@test:behat-cli -vvv --stop-on-failure -c Neos.Neos/Tests/Behavior/behat.yml"
"@test:behat-cli -vvv --stop-on-failure -c Neos.Neos/Tests/Behavior/behat.yml.dist"
],
"test": [
"@test:unit",
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,10 @@ jobs:
# We enable the race condition tracker
presets:
'default':
projections:
'Neos.ContentRepository:ContentGraph':
catchUpHooks:
'Neos.ContentRepository.BehavioralTests:RaceConditionTracker':
factoryObjectName: Neos\ContentRepository\BehavioralTests\ProjectionRaceConditionTester\RaceTrackerCatchUpHookFactory
contentGraphProjection:
catchUpHooks:
'Neos.ContentRepository.BehavioralTests:RaceConditionTracker':
factoryObjectName: Neos\ContentRepository\BehavioralTests\ProjectionRaceConditionTester\RaceTrackerCatchUpHookFactory
ContentRepository:
BehavioralTests:
raceConditionTracker:
Expand Down Expand Up @@ -244,6 +243,7 @@ jobs:
touch ${{ github.workspace }}/Data/DebugDatabaseDumps/keep
./flow package:list --loading-order
FLOW_CONTEXT=Testing/Behat ./flow doctrine:migrate --quiet
cd Packages/Neos
# composer test:behavioral
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/postgresql-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,5 @@ jobs:
FLOW_CONTEXT=Testing/Behat ./flow behat:setup
FLOW_CONTEXT=Testing/Behat ./flow doctrine:create
FLOW_CONTEXT=Testing/Behat ./flow doctrine:migrationversion --add --version all
bin/behat --stop-on-failure -f progress -c Packages/Neos/Neos.Neos/Tests/Behavior/behat.yml
bin/behat --stop-on-failure -f progress -c Packages/Neos/Neos.Neos/Tests/Behavior/behat.yml.dist
bin/behat --stop-on-failure -f progress -c Packages/Neos/Neos.ContentRepository/Tests/Behavior/behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ Feature: Run projection integrity violation detection regarding root connection
And the command CreateRootWorkspace is executed with payload:
| Key | Value |
| workspaceName | "live" |
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |

Scenario: Create a cycle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Feature: Run integrity violation detection regarding hierarchy relations and nod
And the command CreateRootWorkspace is executed with payload:
| Key | Value |
| workspaceName | "live" |
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And I am in workspace "live" and dimension space point {}
And the command CreateRootNodeAggregateWithNode is executed with payload:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Feature: Run integrity violation detection regarding parent relations
And the command CreateRootWorkspace is executed with payload:
| Key | Value |
| workspaceName | "live" |
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And I am in workspace "live" and dimension space point {"language":"de"}
And the command CreateRootNodeAggregateWithNode is executed with payload:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ Feature: Run integrity violation detection regarding reference relations
And the command CreateRootWorkspace is executed with payload:
| Key | Value |
| workspaceName | "live" |
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And I am in workspace "live" and dimension space point {"language":"de"}
And the command CreateRootNodeAggregateWithNode is executed with payload:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Feature: Run integrity violation detection regarding sibling sorting
And the command CreateRootWorkspace is executed with payload:
| Key | Value |
| workspaceName | "live" |
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And I am in workspace "live" and dimension space point {"language":"de"}
And the command CreateRootNodeAggregateWithNode is executed with payload:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Feature: Run integrity violation detection regarding subtree tag inheritance
And the command CreateRootWorkspace is executed with payload:
| Key | Value |
| workspaceName | "live" |
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And I am in workspace "live" and dimension space point {"language":"de"}
And the command CreateRootNodeAggregateWithNode is executed with payload:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Feature: Run projection integrity violation detection regarding naming of tether
And the command CreateRootWorkspace is executed with payload:
| Key | Value |
| workspaceName | "live" |
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And I am in workspace "live" and dimension space point {"language":"de"}
And the command CreateRootNodeAggregateWithNode is executed with payload:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ Feature: Sibling positions are properly resolved
And the command CreateRootWorkspace is executed with payload:
| Key | Value |
| workspaceName | "live" |
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And I am in workspace "live" and dimension space point {"example": "general"}
And the command CreateRootNodeAggregateWithNode is executed with payload:
Expand Down
80 changes: 0 additions & 80 deletions Neos.ContentGraph.DoctrineDbalAdapter/src/ContentGraphFactory.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Neos.ContentGraph.DoctrineDbalAdapter package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/

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\Projection\ContentGraph\ContentGraphReadModelInterface;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStream;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreams;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamStatus;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspace;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\Core\SharedModel\Workspace\Workspaces;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceStatus;
use Neos\EventStore\Model\Event\Version;

/**
* @internal
*/
final readonly class ContentGraphReadModelAdapter implements ContentGraphReadModelInterface
{
public function __construct(
private Connection $dbal,
private NodeFactory $nodeFactory,
private ContentRepositoryId $contentRepositoryId,
private NodeTypeManager $nodeTypeManager,
private ContentGraphTableNames $tableNames
) {
}

public function buildContentGraph(WorkspaceName $workspaceName, ContentStreamId $contentStreamId): ContentGraph
{
return new ContentGraph($this->dbal, $this->nodeFactory, $this->contentRepositoryId, $this->nodeTypeManager, $this->tableNames, $workspaceName, $contentStreamId);
}

public function findWorkspaceByName(WorkspaceName $workspaceName): ?Workspace
{
$workspaceByNameStatement = <<<SQL
SELECT
name, baseWorkspaceName, currentContentStreamId, status
FROM
{$this->tableNames->workspace()}
WHERE
name = :workspaceName
LIMIT 1
SQL;
try {
$row = $this->dbal->fetchAssociative($workspaceByNameStatement, [
'workspaceName' => $workspaceName->value,
]);
} catch (Exception $e) {
throw new \RuntimeException(sprintf('Failed to load workspace from database: %s', $e->getMessage()), 1716486077, $e);
}
if ($row === false) {
return null;
}
return self::workspaceFromDatabaseRow($row);
}

public function findWorkspaces(): Workspaces
{
$workspacesStatement = <<<SQL
SELECT
name, baseWorkspaceName, currentContentStreamId, status
FROM
{$this->tableNames->workspace()}
SQL;
try {
$rows = $this->dbal->fetchAllAssociative($workspacesStatement);
} catch (Exception $e) {
throw new \RuntimeException(sprintf('Failed to load workspaces from database: %s', $e->getMessage()), 1716902981, $e);
}
return Workspaces::fromArray(array_map(self::workspaceFromDatabaseRow(...), $rows));
}

public function findContentStreamById(ContentStreamId $contentStreamId): ?ContentStream
{
$contentStreamByIdStatement = <<<SQL
SELECT
id, sourceContentStreamId, status, version, removed
FROM
{$this->tableNames->contentStream()}
WHERE
id = :contentStreamId
LIMIT 1
SQL;
try {
$row = $this->dbal->fetchAssociative($contentStreamByIdStatement, [
'contentStreamId' => $contentStreamId->value,
]);
} catch (Exception $e) {
throw new \RuntimeException(sprintf('Failed to load content stream from database: %s', $e->getMessage()), 1716903166, $e);
}
if ($row === false) {
return null;
}
return self::contentStreamFromDatabaseRow($row);
}

public function findContentStreams(): ContentStreams
{
$contentStreamsStatement = <<<SQL
SELECT
id, sourceContentStreamId, status, version, removed
FROM
{$this->tableNames->contentStream()}
SQL;
try {
$rows = $this->dbal->fetchAllAssociative($contentStreamsStatement);
} catch (Exception $e) {
throw new \RuntimeException(sprintf('Failed to load content streams from database: %s', $e->getMessage()), 1716903042, $e);
}
return ContentStreams::fromArray(array_map(self::contentStreamFromDatabaseRow(...), $rows));
}

public function countNodes(): int
{
$countNodesStatement = <<<SQL
SELECT
COUNT(*)
FROM
{$this->tableNames->node()}
SQL;
try {
return (int)$this->dbal->fetchOne($countNodesStatement);
} catch (Exception $e) {
throw new \RuntimeException(sprintf('Failed to count rows in database: %s', $e->getMessage()), 1701444590, $e);
}
}

/**
* @param array<string, mixed> $row
*/
private static function workspaceFromDatabaseRow(array $row): Workspace
{
return new Workspace(
WorkspaceName::fromString($row['name']),
isset($row['baseWorkspaceName']) ? WorkspaceName::fromString($row['baseWorkspaceName']) : null,
ContentStreamId::fromString($row['currentContentStreamId']),
WorkspaceStatus::from($row['status']),
);
}

/**
* @param array<string, mixed> $row
*/
private static function contentStreamFromDatabaseRow(array $row): ContentStream
{
return new ContentStream(
ContentStreamId::fromString($row['id']),
isset($row['sourceContentStreamId']) ? ContentStreamId::fromString($row['sourceContentStreamId']) : null,
ContentStreamStatus::from($row['status']),
Version::fromInteger((int)$row['version']),
(bool)$row['removed']
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ public function referenceRelation(): string
return $this->tableNamePrefix . '_referencerelation';
}

public function workspace(): string
{
return $this->tableNamePrefix . '_workspace';
}

public function contentStream(): string
{
return $this->tableNamePrefix . '_contentstream';
}

public function checkpoint(): string
{
return $this->tableNamePrefix . '_checkpoint';
Expand Down
Loading

0 comments on commit ed605bd

Please sign in to comment.