Skip to content

Commit fe5df38

Browse files
authored
Merge pull request #7114 from pmattmann/feature/perf-content-nodes
Performance: /api/content_node/checklist_nodes
2 parents 450fe62 + d1ae072 commit fe5df38

File tree

4 files changed

+134
-152
lines changed

4 files changed

+134
-152
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20250324224924 extends AbstractMigration {
14+
public function getDescription(): string {
15+
return 'ContentNode.RootId not nullable';
16+
}
17+
18+
public function up(Schema $schema): void {
19+
// this up() migration is auto-generated, please modify it to your needs
20+
$this->addSql('ALTER TABLE content_node ALTER rootId SET NOT NULL');
21+
}
22+
23+
public function down(Schema $schema): void {
24+
// this down() migration is auto-generated, please modify it to your needs
25+
$this->addSql('ALTER TABLE content_node ALTER rootid DROP NOT NULL');
26+
}
27+
}

api/src/Entity/ContentNode.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ abstract class ContentNode extends BaseEntity implements BelongsToContentNodeTre
6262
#[Gedmo\SortableGroup] // this is needed to avoid that all root nodes are in the same sort group (parent:null, slot: '')
6363
#[Groups(['read'])]
6464
#[ORM\ManyToOne(targetEntity: ColumnLayout::class, inversedBy: 'rootDescendants')]
65-
#[ORM\JoinColumn(nullable: true, onDelete: 'CASCADE')] // TODO make not null in the DB using a migration, and get fixtures to run
65+
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
6666
public ?ColumnLayout $root = null;
6767

6868
/**
@@ -186,6 +186,11 @@ public function getParent(): ?HasParentInterface {
186186
return $this->parent;
187187
}
188188

189+
public function setParent(?ContentNode $parent) {
190+
$this->parent = $parent;
191+
$this->root ??= $parent?->root;
192+
}
193+
189194
/**
190195
* Holds the actual data of the content node.
191196
*/

api/tests/Api/ContentNodes/RootColumnLayout/CreateRootColumnLayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function testCreateColumnLayoutValidatesMissingParent() {
3535
$this->assertJsonContains([
3636
'violations' => [
3737
[
38-
'propertyPath' => 'parent',
38+
'propertyPath' => 'root',
3939
'message' => 'This value should not be null.',
4040
],
4141
],

0 commit comments

Comments
 (0)