Skip to content

Commit 7daf428

Browse files
committed
3666: Refactor rootDir normalization to ensure values are always normalized, fix type errors, fix values not being set
1 parent 80ba29f commit 7daf428

29 files changed

Lines changed: 112 additions & 38 deletions
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 Version20250205115916 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return '';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql('ALTER TABLE package ADD suggests VARCHAR(255) DEFAULT NULL');
24+
$this->addSql('UPDATE detection_result SET root_dir = REPLACE(root_dir, \'/public\', \'\') WHERE root_dir LIKE \'%/public\'');
25+
}
26+
27+
public function down(Schema $schema): void
28+
{
29+
// this down() migration is auto-generated, please modify it to your needs
30+
$this->addSql('ALTER TABLE package DROP suggests');
31+
}
32+
}

src/Command/ReplayDetectionResultsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
117117

118118
$count = $this->entityManager->getRepository(DetectionResult::class)->count($criteria);
119119

120-
$this->entityManager->getConnection()->getConfiguration()->setSQLLogger(null);
120+
$this->entityManager->getConnection()->getConfiguration()->setMiddlewares([new \Doctrine\DBAL\Logging\Middleware(new \Psr\Log\NullLogger())]);
121121
$iterable = $queryBuilder->getQuery()->toIterable();
122122

123123
$limit = intval($input->getOption('limit'));

src/Entity/AbstractBaseEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#[ORM\MappedSuperclass]
1313
#[ORM\HasLifecycleCallbacks]
14-
abstract class AbstractBaseEntity
14+
abstract class AbstractBaseEntity implements \Stringable
1515
{
1616
#[ApiProperty(identifier: true)]
1717
#[ORM\Id]

src/Entity/AbstractHandlerResult.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace App\Entity;
66

7-
use App\Utils\RootDirNormalizer;
87
use Doctrine\ORM\Mapping as ORM;
98
use Symfony\Component\Serializer\Annotation\Groups;
109
use Symfony\Component\Serializer\Annotation\SerializedName;
@@ -32,7 +31,7 @@ public function getRootDir(): string
3231

3332
public function setRootDir(string $rootDir): self
3433
{
35-
$this->rootDir = RootDirNormalizer::normalize($rootDir);
34+
$this->rootDir = $rootDir;
3635

3736
return $this;
3837
}

src/Entity/Advisory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function __construct()
4848
$this->packageVersions = new ArrayCollection();
4949
}
5050

51+
#[\Override]
5152
public function __toString(): string
5253
{
5354
$id = $this->cve ?? $this->advisoryId;

src/Entity/DetectionResult.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use ApiPlatform\Metadata\ApiResource;
88
use ApiPlatform\Metadata\Post;
99
use App\Repository\DetectionResultRepository;
10+
use App\Utils\RootDirNormalizer;
1011
use Doctrine\ORM\Mapping as ORM;
1112
use Symfony\Component\Serializer\Annotation\Groups;
1213

@@ -43,6 +44,7 @@ class DetectionResult extends AbstractBaseEntity implements \Stringable
4344
#[ORM\Column(type: 'datetime_immutable')]
4445
private \DateTimeImmutable $lastContact;
4546

47+
#[\Override]
4648
public function __toString(): string
4749
{
4850
return '['.$this->type.'] '.$this->server.$this->rootDir.' @ '.$this->lastContact->format(DATE_ATOM);
@@ -67,7 +69,7 @@ public function getRootDir(): string
6769

6870
public function setRootDir(string $rootDir): self
6971
{
70-
$this->rootDir = $rootDir;
72+
$this->rootDir = RootDirNormalizer::normalize($rootDir);
7173

7274
return $this;
7375
}

src/Entity/DockerImage.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function __construct()
3030
$this->dockerImageTags = new ArrayCollection();
3131
}
3232

33+
#[\Override]
3334
public function __toString(): string
3435
{
3536
$name = $this->organization;

src/Entity/DockerImageTag.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function __construct()
3131
$this->installations = new ArrayCollection();
3232
}
3333

34+
#[\Override]
3435
public function __toString(): string
3536
{
3637
return $this->dockerImage.':'.$this->getTag();

src/Entity/Domain.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Domain extends AbstractHandlerResult implements \Stringable
2525
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
2626
private Site $site;
2727

28+
#[\Override]
2829
public function __toString(): string
2930
{
3031
return $this->address;

src/Entity/GitRepo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function __construct()
3030
$this->gitTags = new ArrayCollection();
3131
}
3232

33+
#[\Override]
3334
public function __toString(): string
3435
{
3536
return $this->getOrganization().'/'.$this->getRepo();

0 commit comments

Comments
 (0)