From 52e350d968775c6c1203ff0ad24ac8fd6cdd4a50 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 13 Mar 2014 23:21:55 +0100 Subject: [PATCH 01/19] Add Preset Migration --- .../DoctrineMigrations/PresetMigration.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 lib/Alchemy/Phrasea/Setup/DoctrineMigrations/PresetMigration.php diff --git a/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/PresetMigration.php b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/PresetMigration.php new file mode 100644 index 0000000000..d9a73625fc --- /dev/null +++ b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/PresetMigration.php @@ -0,0 +1,33 @@ +tableExists('Presets'); + } + + public function doUpSql(Schema $schema) + { + $this->addSql("CREATE TABLE Presets (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, sbas_id INT NOT NULL, title VARCHAR(128) NOT NULL, data LONGTEXT NOT NULL, created DATETIME NOT NULL, INDEX IDX_1C48F8F3A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB"); + $this->addSql("ALTER TABLE Presets ADD CONSTRAINT FK_1C48F8F3A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)"); + } + + public function doDownSql(Schema $schema) + { + $this->addSql("DROP TABLE Presets"); + } +} From ac1485f99c3915aa8b133f394baf82ec5f263d5a Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 13 Mar 2014 23:22:21 +0100 Subject: [PATCH 02/19] Add Aggregate Token Migration --- .../AggregateTokenMigration.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 lib/Alchemy/Phrasea/Setup/DoctrineMigrations/AggregateTokenMigration.php diff --git a/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/AggregateTokenMigration.php b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/AggregateTokenMigration.php new file mode 100644 index 0000000000..76bb5b5b45 --- /dev/null +++ b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/AggregateTokenMigration.php @@ -0,0 +1,33 @@ +tableExists('AggregateTokens'); + } + + public function doUpSql(Schema $schema) + { + $this->addSql("CREATE TABLE AggregateTokens (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, value VARCHAR(64) DEFAULT NULL, INDEX IDX_4232BC51A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB"); + $this->addSql("ALTER TABLE AggregateTokens ADD CONSTRAINT FK_4232BC51A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)"); + } + + public function doDownSql(Schema $schema) + { + $this->addSql("DROP TABLE AggregateTokens"); + } +} From 003396aa711badce45de30d4baa6822b8bc42fb2 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 13 Mar 2014 23:22:38 +0100 Subject: [PATCH 03/19] Register migrations --- lib/conf.d/migrations.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/conf.d/migrations.yml b/lib/conf.d/migrations.yml index c63fcd51a0..5d58335458 100644 --- a/lib/conf.d/migrations.yml +++ b/lib/conf.d/migrations.yml @@ -60,3 +60,12 @@ migrations: migration19: version: token class: Alchemy\Phrasea\Setup\DoctrineMigrations\TokenMigration + migration20: + version: api + class: Alchemy\Phrasea\Setup\DoctrineMigrations\ApiMigration + migration21: + version: aggregate-token + class: Alchemy\Phrasea\Setup\DoctrineMigrations\AggregateTokenMigration + migration22: + version: preset + class: Alchemy\Phrasea\Setup\DoctrineMigrations\PresetMigration From f84f8f17fdfadd52542602e73301f57744073623 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 13 Mar 2014 23:24:01 +0100 Subject: [PATCH 04/19] Fix missing namespaces --- lib/classes/patchAbstract.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/classes/patchAbstract.php b/lib/classes/patchAbstract.php index 6fc7a3fdaf..956a119476 100644 --- a/lib/classes/patchAbstract.php +++ b/lib/classes/patchAbstract.php @@ -11,6 +11,7 @@ use Doctrine\ORM\NoResultException; use Doctrine\ORM\EntityManager; +use Doctrine\ORM\Query; use Doctrine\ORM\Query\ResultSetMapping; abstract class patchAbstract implements patchInterface From 5d690332855d3abf968cb45fc2843e8ec2e9b50d Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 13 Mar 2014 23:26:58 +0100 Subject: [PATCH 05/19] Fix Users Migration in case of failure --- .../Version/PreSchemaUpgrade/Upgrade39Users.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/Upgrade39Users.php b/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/Upgrade39Users.php index 699e5ab3db..50263adfac 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/Upgrade39Users.php +++ b/lib/Alchemy/Phrasea/Setup/Version/PreSchemaUpgrade/Upgrade39Users.php @@ -73,7 +73,6 @@ class Upgrade39Users implements PreSchemaUpgradeInterface */ public function rollback(EntityManager $em, \appbox $appbox, Configuration $conf) { - $this->renameTable($em, 'down'); // truncate created tables $this->emptyTables($em); // rollback schema @@ -124,14 +123,14 @@ class Upgrade39Users implements PreSchemaUpgradeInterface private function alterTablesDown(EntityManager $em) { foreach ([ - 'Baskets' => "ALTER TABLE Baskets CHANGE user_id usr_id", - 'LazaretSessions' => "ALTER TABLE LazaretSessions CHANGE user_id usr_id", - 'Sessions' => "ALTER TABLE Sessions CHANGE user_id usr_id", - 'StoryWZ' => "ALTER TABLE StoryWZ CHANGE user_id usr_id", - 'UsrAuthProviders' => "ALTER TABLE UsrAuthProviders CHANGE user_id usr_id", - 'UsrListOwners' => "ALTER TABLE UsrListOwners CHANGE user_id usr_id", - 'UsrListsContent' => "ALTER TABLE UsrListsContent CHANGE user_id usr_id", - 'ValidationParticipants' => "ALTER TABLE ValidationParticipants CHANGE user_id usr_id", + 'Baskets' => "ALTER TABLE Baskets CHANGE user_id usr_id INT DEFAULT NULL", + 'LazaretSessions' => "ALTER TABLE LazaretSessions CHANGE user_id usr_id INT DEFAULT NULL", + 'Sessions' => "ALTER TABLE Sessions CHANGE user_id usr_id INT DEFAULT NULL", + 'StoryWZ' => "ALTER TABLE StoryWZ CHANGE user_id usr_id INT DEFAULT NULL", + 'UsrAuthProviders' => "ALTER TABLE UsrAuthProviders CHANGE user_id usr_id INT DEFAULT NULL", + 'UsrListOwners' => "ALTER TABLE UsrListOwners CHANGE user_id usr_id INT DEFAULT NULL", + 'UsrListsContent' => "ALTER TABLE UsrListsContent CHANGE user_id usr_id INT DEFAULT NULL", + 'ValidationParticipants' => "ALTER TABLE ValidationParticipants CHANGE user_id usr_id INT DEFAULT NULL", ] as $table => $sql) { if ($this->tableExists($em, $table)) { $em->getConnection()->executeUpdate($sql); From 1516ae5d3aaf15175ad1ce5f9cb714ab1bdee426 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 13 Mar 2014 23:27:38 +0100 Subject: [PATCH 06/19] Remove alteratiion of AggregateToken --- .../Setup/DoctrineMigrations/DeleteUsrIdFieldMigration.php | 2 -- .../Phrasea/Setup/DoctrineMigrations/UserFieldMigration.php | 4 ---- 2 files changed, 6 deletions(-) diff --git a/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/DeleteUsrIdFieldMigration.php b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/DeleteUsrIdFieldMigration.php index 740e5897df..cf5b46b285 100644 --- a/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/DeleteUsrIdFieldMigration.php +++ b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/DeleteUsrIdFieldMigration.php @@ -37,7 +37,6 @@ class DeleteUsrIdFieldMigration extends AbstractMigration $this->addSql("ALTER TABLE LazaretSessions DROP usr_id"); $this->addSql("ALTER TABLE ValidationParticipants DROP usr_id"); $this->addSql("ALTER TABLE FeedPublishers DROP usr_id"); - $this->addSql("ALTER TABLE AggregateTokens DROP usr_id"); $this->addSql("ALTER TABLE FtpExports DROP usr_id"); $this->addSql("DROP INDEX unique_provider_per_user ON UsrAuthProviders"); $this->addSql("ALTER TABLE UsrAuthProviders DROP usr_id"); @@ -50,7 +49,6 @@ class DeleteUsrIdFieldMigration extends AbstractMigration public function doDownSql(Schema $schema) { - $this->addSql("ALTER TABLE AggregateTokens ADD usr_id INT NOT NULL"); $this->addSql("ALTER TABLE Baskets ADD usr_id INT NOT NULL"); $this->addSql("ALTER TABLE FeedPublishers ADD usr_id INT NOT NULL"); $this->addSql("ALTER TABLE FeedTokens ADD usr_id INT NOT NULL"); diff --git a/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/UserFieldMigration.php b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/UserFieldMigration.php index 9e57e02104..fd2715ed20 100644 --- a/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/UserFieldMigration.php +++ b/lib/Alchemy/Phrasea/Setup/DoctrineMigrations/UserFieldMigration.php @@ -36,8 +36,6 @@ class UserFieldMigration extends AbstractMigration $this->addSql("CREATE INDEX IDX_17850D7BA76ED395 ON ValidationParticipants (user_id)"); $this->addSql("ALTER TABLE FeedPublishers ADD CONSTRAINT FK_31AFAB2A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)"); $this->addSql("CREATE INDEX IDX_31AFAB2A76ED395 ON FeedPublishers (user_id)"); - $this->addSql("ALTER TABLE AggregateTokens ADD CONSTRAINT FK_4232BC51A76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)"); - $this->addSql("CREATE INDEX IDX_4232BC51A76ED395 ON AggregateTokens (user_id)"); $this->addSql("ALTER TABLE FtpExports ADD CONSTRAINT FK_CFCEEE7AA76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)"); $this->addSql("CREATE INDEX IDX_CFCEEE7AA76ED395 ON FtpExports (user_id)"); $this->addSql("ALTER TABLE UsrAuthProviders ADD CONSTRAINT FK_947F003FA76ED395 FOREIGN KEY (user_id) REFERENCES Users (id)"); @@ -50,8 +48,6 @@ class UserFieldMigration extends AbstractMigration public function doDownSql(Schema $schema) { - $this->addSql("ALTER TABLE AggregateTokens DROP FOREIGN KEY FK_4232BC51A76ED395"); - $this->addSql("DROP INDEX IDX_4232BC51A76ED395 ON AggregateTokens"); $this->addSql("ALTER TABLE Baskets DROP FOREIGN KEY FK_13461873A76ED395"); $this->addSql("DROP INDEX IDX_13461873A76ED395 ON Baskets"); $this->addSql("ALTER TABLE FeedPublishers DROP FOREIGN KEY FK_31AFAB2A76ED395"); From ea248e0e31677a09983192de51dd5438922e8280 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 13 Mar 2014 23:28:34 +0100 Subject: [PATCH 07/19] Fix Feeds Migration --- lib/classes/patch/390alpha7a.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/classes/patch/390alpha7a.php b/lib/classes/patch/390alpha7a.php index ecdb7e931e..15ca9e2f19 100644 --- a/lib/classes/patch/390alpha7a.php +++ b/lib/classes/patch/390alpha7a.php @@ -55,7 +55,7 @@ class patch_390alpha7a extends patchAbstract */ public function getDoctrineMigrations() { - return ['feed']; + return ['aggregate-token', 'feed']; } /** @@ -127,7 +127,7 @@ class patch_390alpha7a extends patchAbstract $feed->setIsPublic($row['public']); $feed->setCreatedOn(new \DateTime($row['created_on'])); $feed->setUpdatedOn(new \DateTime($row['updated_on'])); - $feed->setCollection($row['base_id'] ? collection::get_from_base_id($app, $row['base_id']) : null); + $feed->setBaseId($row['base_id']); $fpStmt->execute([':feed_id' => $row['id']]); $fpRes = $fpStmt->fetchAll(\PDO::FETCH_ASSOC); From 64215085514843e50f42fd78e0b74de00a5be928 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 13 Mar 2014 23:29:24 +0100 Subject: [PATCH 08/19] Fix rename of api logs table --- lib/classes/patch/390alpha14a.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/classes/patch/390alpha14a.php b/lib/classes/patch/390alpha14a.php index 84f0e9e824..d26453d9e2 100644 --- a/lib/classes/patch/390alpha14a.php +++ b/lib/classes/patch/390alpha14a.php @@ -59,7 +59,7 @@ class patch_390alpha14a extends patchAbstract $app['conf']->remove(['main', 'api-timers']); if ($this->tableHasField($app['EM'], 'api_logs', 'api_log_ressource')) { - $sql = 'UPDATE api_logs SET api_log_resource = api_log_ressource'; + $sql = "ALTER TABLE api_logs CHANGE api_log_ressource api_log_resource varchar(64)"; $app['phraseanet.appbox']->get_connection()->executeUpdate($sql); } From a23bf7a4ace777bffa5a76c543aa475424e36e82 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 13 Mar 2014 23:30:04 +0100 Subject: [PATCH 09/19] Fix tokens table migration --- lib/classes/patch/390alpha15a.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/classes/patch/390alpha15a.php b/lib/classes/patch/390alpha15a.php index 3e58e25e18..057a13d380 100644 --- a/lib/classes/patch/390alpha15a.php +++ b/lib/classes/patch/390alpha15a.php @@ -60,10 +60,19 @@ class patch_390alpha15a extends patchAbstract return true; } - $sql = 'INSERT INTO Tokens - (value, user_id, type, data, created, updated, expiration) - (SELECT value, usr_id, type, datas, created_on, created_on, expire_on FROM tokens_backup)'; - $appbox->get_connection()->exec($sql); + $app['EM']->getConnection()->executeUpdate(' + INSERT INTO Tokens + ( + `value`, user_id, `type`, `data`, + created, updated, expiration + ) + ( + SELECT + tb.`value`, tb.usr_id, tb.`type`, tb.datas, + tb.created_on, tb.created_on, tb.expire_on + FROM tokens_backup tb + INNER JOIN Users u ON (u.id = tb.usr_id) + )'); return true; } From 66e1832357e7a8079faeb067e09cc61a68112002 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 13 Mar 2014 23:30:29 +0100 Subject: [PATCH 10/19] Fix edit_preset table migration --- lib/classes/patch/390alpha16a.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/classes/patch/390alpha16a.php b/lib/classes/patch/390alpha16a.php index fe6e6408b3..5e78de9513 100644 --- a/lib/classes/patch/390alpha16a.php +++ b/lib/classes/patch/390alpha16a.php @@ -50,7 +50,7 @@ class patch_390alpha16a extends patchAbstract */ public function getDoctrineMigrations() { - return []; + return ['preset']; } /** @@ -58,7 +58,7 @@ class patch_390alpha16a extends patchAbstract */ public function apply(base $appbox, Application $app) { - $sql = ' SELECT edit_preset_id, creation_date, title, xml + $sql = ' SELECT edit_preset_id, creation_date, title, xml, usr_id, sbas_id FROM edit_presets'; $em = $app['EM']; @@ -74,6 +74,9 @@ class patch_390alpha16a extends patchAbstract $preset->setTitle($row['title']); $fields = []; if (false !== ($sx = @simplexml_load_string($row['xml']))) { + if (false === isset($sx->fields)) { + continue; + } foreach ($sx->fields->children() as $name => $value) { $fields[] = ['name' => $name, 'value' => $value]; } From 633fad7c750958393bd881ea98fd0aef6a78960a Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Thu, 13 Mar 2014 23:31:18 +0100 Subject: [PATCH 11/19] Fix Orders migration --- lib/Alchemy/Phrasea/Model/Entities/User.php | 4 ++-- lib/classes/patch/390alpha1a.php | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Alchemy/Phrasea/Model/Entities/User.php b/lib/Alchemy/Phrasea/Model/Entities/User.php index b8c2cc6219..89e7ade4ae 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/User.php +++ b/lib/Alchemy/Phrasea/Model/Entities/User.php @@ -51,7 +51,7 @@ class User private $id; /** - * @ORM\Column(type="string", length=128) + * @ORM\Column(type="string", length=128, options={"collate"="utf8_bin"}) */ private $login; @@ -61,7 +61,7 @@ class User private $email; /** - * @ORM\Column(type="string", length=128, nullable=true) + * @ORM\Column(type="string", length=128, nullable=true, options={"collate"="utf8_bin"}) */ private $password; diff --git a/lib/classes/patch/390alpha1a.php b/lib/classes/patch/390alpha1a.php index b43f976107..419520934c 100644 --- a/lib/classes/patch/390alpha1a.php +++ b/lib/classes/patch/390alpha1a.php @@ -12,9 +12,11 @@ use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Model\Entities\Order; use Alchemy\Phrasea\Model\Entities\OrderElement; +use Doctrine\ORM\Query; use Doctrine\ORM\NoResultException; use Gedmo\Timestampable\TimestampableListener; + class patch_390alpha1a extends patchAbstract { /** @var string */ @@ -92,7 +94,9 @@ class patch_390alpha1a extends patchAbstract $todo = $stmt->fetch(\PDO::FETCH_ASSOC); $stmt->closeCursor(); - $user = $this->loadUser($app['EM'], $row['usr_id']); + if (null === $user = $this->loadUser($app['EM'], $row['usr_id'])) { + continue; + } try { $basket = $app['EM']->createQuery('SELECT PARTIAL b.{id} FROM Phraseanet:Basket b WHERE b.id = :id') From 8edc194a85704504420f84a94f4819a08b3b8a82 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Fri, 14 Mar 2014 15:20:07 +0100 Subject: [PATCH 12/19] Add binary string type --- .../Phrasea/Model/Types/BinaryString.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 lib/Alchemy/Phrasea/Model/Types/BinaryString.php diff --git a/lib/Alchemy/Phrasea/Model/Types/BinaryString.php b/lib/Alchemy/Phrasea/Model/Types/BinaryString.php new file mode 100644 index 0000000000..a9020d2ecf --- /dev/null +++ b/lib/Alchemy/Phrasea/Model/Types/BinaryString.php @@ -0,0 +1,35 @@ +getName() === 'mysql') { + return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration)." ". $platform->getCollationFieldDeclaration('utf8_bin'); + } + + throw new RuntimeException(sprintf('Type %s is not supported.', self::BINARY_STRING)); + } +} From dcde280b09c03aa01ac34c334d83cebe110e35a9 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Fri, 14 Mar 2014 15:20:25 +0100 Subject: [PATCH 13/19] Fix cae sensistive sql fields by setting binary_string --- lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php | 1 + lib/Alchemy/Phrasea/Model/Entities/User.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php index 1eba97d48c..3d3c6c1fbb 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php @@ -168,6 +168,7 @@ class ORMServiceProvider implements ServiceProviderInterface 'longblob' => 'Alchemy\Phrasea\Model\Types\LongBlob', 'varbinary' => 'Alchemy\Phrasea\Model\Types\VarBinary', 'binary' => 'Alchemy\Phrasea\Model\Types\Binary', + 'binary_string' => 'Alchemy\Phrasea\Model\Types\BinaryString', ]; foreach ($types as $type => $class) { diff --git a/lib/Alchemy/Phrasea/Model/Entities/User.php b/lib/Alchemy/Phrasea/Model/Entities/User.php index 89e7ade4ae..de8eb87ed1 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/User.php +++ b/lib/Alchemy/Phrasea/Model/Entities/User.php @@ -51,7 +51,7 @@ class User private $id; /** - * @ORM\Column(type="string", length=128, options={"collate"="utf8_bin"}) + * @ORM\Column(type="binary_string", length=128) */ private $login; @@ -61,12 +61,12 @@ class User private $email; /** - * @ORM\Column(type="string", length=128, nullable=true, options={"collate"="utf8_bin"}) + * @ORM\Column(type="binary_string", length=128) */ private $password; /** - * @ORM\Column(type="string", length=64, nullable=true) + * @ORM\Column(type="binary_string", length=64, nullable=true) */ private $nonce; From 26f8e18f6137bede292a2f3d3d3763fa6cfb5a49 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Sun, 16 Mar 2014 01:00:27 +0100 Subject: [PATCH 14/19] Remove undeclared migration --- lib/conf.d/migrations.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/conf.d/migrations.yml b/lib/conf.d/migrations.yml index 5d58335458..2cc0b1cde8 100644 --- a/lib/conf.d/migrations.yml +++ b/lib/conf.d/migrations.yml @@ -60,9 +60,6 @@ migrations: migration19: version: token class: Alchemy\Phrasea\Setup\DoctrineMigrations\TokenMigration - migration20: - version: api - class: Alchemy\Phrasea\Setup\DoctrineMigrations\ApiMigration migration21: version: aggregate-token class: Alchemy\Phrasea\Setup\DoctrineMigrations\AggregateTokenMigration From 01aedd332667dc91717d9501dfe8ece7f7f2680f Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Sun, 16 Mar 2014 02:11:56 +0100 Subject: [PATCH 15/19] Check if 'servername' key exists --- lib/classes/patch/390alpha9b.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/classes/patch/390alpha9b.php b/lib/classes/patch/390alpha9b.php index 509cf78827..58856fda34 100644 --- a/lib/classes/patch/390alpha9b.php +++ b/lib/classes/patch/390alpha9b.php @@ -195,8 +195,10 @@ class patch_390alpha9b extends patchAbstract unset($config['main']['languages']); } - $config = array_merge(['servername' => $config['main']['servername']], $config); - unset($config['main']['servername']); + if (isset($config['main']['servername'])) { + $config = array_merge(['servername' => $config['main']['servername']], $config); + unset($config['main']['servername']); + } if (isset($config['task-manager'])) { $config['main']['task-manager'] = $config['task-manager']; From e4e71cc7e326a9680228c53aaf8b6edb36a7bc66 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Sun, 16 Mar 2014 02:12:24 +0100 Subject: [PATCH 16/19] Add 390alpha18a patch --- lib/classes/patch/390alpha18a.php | 95 +++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 lib/classes/patch/390alpha18a.php diff --git a/lib/classes/patch/390alpha18a.php b/lib/classes/patch/390alpha18a.php new file mode 100644 index 0000000000..97ae8583bb --- /dev/null +++ b/lib/classes/patch/390alpha18a.php @@ -0,0 +1,95 @@ +release; + } + + /** + * {@inheritdoc} + */ + public function require_all_upgrades() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function concern() + { + return $this->concern; + } + + /** + * {@inheritdoc} + */ + public function getDoctrineMigrations() + { + return ['user', 'lazaret', 'feed', 'session']; + } + + /** + * {@inheritdoc} + */ + public function apply(base $appbox, Application $app) + { + $app['EM']->getConnection()->executeUpdate(' + DELETE lf FROM LazaretFiles lf + INNER JOIN LazaretSessions ls ON (ls.id = lf.lazaret_session_id) + LEFT JOIN Users u ON (ls.user_id = u.id) + WHERE u.id IS NULL' + ); + + $app['EM']->getConnection()->executeUpdate(' + DELETE ls FROM LazaretSessions AS ls + LEFT JOIN Users u ON (ls.user_id = u.id) + WHERE u.id IS NULL' + ); + + $app['EM']->getConnection()->executeUpdate(' + DELETE fi FROM FeedItems AS fi + INNER JOIN FeedEntries fe ON (fe.id = fi.entry_id) + LEFT JOIN Users u ON (fe.publisher_id = u.id) + WHERE u.id IS NULL' + ); + + $app['EM']->getConnection()->executeUpdate(' + DELETE fe FROM FeedEntries AS fe + LEFT JOIN Users u ON (fe.publisher_id = u.id) + WHERE u.id IS NULL' + ); + + $app['EM']->getConnection()->executeUpdate( + 'DELETE se FROM Sessions AS se + LEFT JOIN Users u ON (se.user_id = u.id) + WHERE u.id IS NULL' + ); + + return true; + } +} From 0ae6acff7d62b6367ebe6c4385b926bcf97c4954 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Sun, 16 Mar 2014 02:12:52 +0100 Subject: [PATCH 17/19] Bump to 3.9.0-alpha18 version --- lib/Alchemy/Phrasea/Core/Version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/Core/Version.php b/lib/Alchemy/Phrasea/Core/Version.php index ad36ce78fe..4cff4e295f 100644 --- a/lib/Alchemy/Phrasea/Core/Version.php +++ b/lib/Alchemy/Phrasea/Core/Version.php @@ -13,7 +13,7 @@ namespace Alchemy\Phrasea\Core; class Version { - protected static $number = '3.9.0-alpha.16'; + protected static $number = '3.9.0-alpha.18'; protected static $name = 'Epanterias'; public static function getNumber() From 9e660d8b3f6d15cb46550fce26e9e90c6bcc2850 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Sun, 16 Mar 2014 06:28:51 +0100 Subject: [PATCH 18/19] Fix binary string type --- lib/Alchemy/Phrasea/Model/Types/BinaryString.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/Model/Types/BinaryString.php b/lib/Alchemy/Phrasea/Model/Types/BinaryString.php index a9020d2ecf..c9b6788ada 100644 --- a/lib/Alchemy/Phrasea/Model/Types/BinaryString.php +++ b/lib/Alchemy/Phrasea/Model/Types/BinaryString.php @@ -30,6 +30,14 @@ class BinaryString extends Type return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration)." ". $platform->getCollationFieldDeclaration('utf8_bin'); } - throw new RuntimeException(sprintf('Type %s is not supported.', self::BINARY_STRING)); + return $platform->getVarcharTypeDeclarationSQL($fieldDeclaration); + } + + /** + * {@inheritdoc} + */ + public function getDefaultLength(AbstractPlatform $platform) + { + return $platform->getVarcharDefaultLength(); } } From aaa60866b5e94e884e6df9db276807c422dbcc56 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Sun, 16 Mar 2014 15:50:10 +0100 Subject: [PATCH 19/19] Password can be null --- lib/Alchemy/Phrasea/Model/Entities/User.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/Model/Entities/User.php b/lib/Alchemy/Phrasea/Model/Entities/User.php index de8eb87ed1..4c91f2ecc8 100644 --- a/lib/Alchemy/Phrasea/Model/Entities/User.php +++ b/lib/Alchemy/Phrasea/Model/Entities/User.php @@ -61,7 +61,9 @@ class User private $email; /** - * @ORM\Column(type="binary_string", length=128) + * The password can be null when the user is a template. + * + * @ORM\Column(type="binary_string", length=128, nullable=true) */ private $password;