Fixed default tag category

This commit is contained in:
Marcin Kurczewski 2014-11-09 16:12:36 +01:00
parent 178b17897c
commit 2ede81e1d8
5 changed files with 22 additions and 4 deletions

View file

@ -32,7 +32,7 @@ class TagViewProxy extends AbstractViewProxy
$result->name = $tag->getName();
$result->usages = $tag->getUsages();
$result->banned = $tag->isBanned();
$result->category = !empty($tag->getCategory()) ? $tag->getCategory() : 'default';
$result->category = $tag->getCategory();
if (!empty($config[self::FETCH_IMPLICATIONS]))
$result->implications = $this->fromArray($tag->getImpliedTags());

View file

@ -6,7 +6,7 @@ final class Tag extends Entity
private $name;
private $creationTime;
private $banned = false;
private $category;
private $category = 'default';
const LAZY_LOADER_IMPLIED_TAGS = 'implications';
const LAZY_LOADER_SUGGESTED_TAGS = 'suggestions';

View file

@ -0,0 +1,19 @@
<?php
namespace Szurubooru\Upgrades;
use Szurubooru\DatabaseConnection;
class Upgrade32 implements IUpgrade
{
public function run(DatabaseConnection $databaseConnection)
{
$pdo = $databaseConnection->getPDO();
$pdo->exec('
UPDATE snapshots SET
data = REPLACE(data, \'"category":null\', \'"category":"default"\'),
dataDifference = REPLACE(dataDifference, \'"category",null\', \'"category","default"\')');
$pdo->exec('UPDATE tags SET category = \'default\' WHERE category IS NULL');
$pdo->exec('ALTER TABLE tags CHANGE category category VARCHAR(25) NOT NULL DEFAULT \'default\'');
}
}

View file

@ -48,6 +48,7 @@ return [
$container->get(\Szurubooru\Upgrades\Upgrade29::class),
$container->get(\Szurubooru\Upgrades\Upgrade30::class),
$container->get(\Szurubooru\Upgrades\Upgrade31::class),
$container->get(\Szurubooru\Upgrades\Upgrade32::class),
];
}),

View file

@ -16,7 +16,6 @@ final class TagDaoFilterTest extends AbstractDatabaseTestCase
$tag1 = $this->getTestTag('test 1');
$tag2 = $this->getTestTag('test 2');
$tag3 = $this->getTestTag('test 3');
$tag1->setCategory(null);
$tag2->setCategory('misc');
$tag3->setCategory('other');
$tagDao = $this->getTagDao();
@ -40,7 +39,6 @@ final class TagDaoFilterTest extends AbstractDatabaseTestCase
$tag1 = $this->getTestTag('test 1');
$tag2 = $this->getTestTag('test 2');
$tag3 = $this->getTestTag('test 3');
$tag1->setCategory(null);
$tag2->setCategory('misc');
$tag3->setCategory('other');
$tagDao = $this->getTagDao();