Skip to content

Commit

Permalink
Fix/entry wrong type (#880)
Browse files Browse the repository at this point in the history
  • Loading branch information
BentiGorlich authored Jul 2, 2024
1 parent 1aac20d commit 1096279
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions migrations/Version20240701113000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use App\Entity\Entry;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

class Version20240701113000 extends AbstractMigration
{
public function getDescription(): string
{
return 'fix the type of posts without a url, but with an image';
}

public function up(Schema $schema): void
{
$type = Entry::ENTRY_TYPE_IMAGE;
$this->addSql("UPDATE entry SET type = '$type', has_embed = true WHERE image_id IS NOT NULL AND url IS NULL");
}

public function down(Schema $schema): void
{
}
}
2 changes: 1 addition & 1 deletion src/Service/EntryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private function setType(EntryDto $dto, Entry $entry): Entry
$isImageUrl = ImageManager::isImageUrl($dto->url);
}

if (($dto->image && !$dto->body) || $isImageUrl) {
if (($dto->image && !$dto->url) || $isImageUrl) {
$entry->type = Entry::ENTRY_TYPE_IMAGE;
$entry->hasEmbed = true;

Expand Down

0 comments on commit 1096279

Please sign in to comment.