From 59410589d53b4560eda315b745edd7fd0aa9d3f0 Mon Sep 17 00:00:00 2001
From: Daniel Berthereau <Daniel.github@Berthereau.net>
Date: Mon, 2 Apr 2018 00:00:00 +0200
Subject: [PATCH] Fixed oai-set from sites.

---
 Module.php                           | 24 ++++++++++++++++--------
 src/Entity/OaiPmhRepositoryToken.php |  2 +-
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/Module.php b/Module.php
index 4a5dcd9..61bc4b9 100644
--- a/Module.php
+++ b/Module.php
@@ -50,16 +50,16 @@ class Module extends AbstractModule
         */
         $sql = <<<'SQL'
 CREATE TABLE oai_pmh_repository_token (
-    id INT AUTO_INCREMENT NOT NULL,
-    verb VARCHAR(190) NOT NULL,
-    metadata_prefix VARCHAR(190) NOT NULL,
+    `id` INT AUTO_INCREMENT NOT NULL,
+    `verb` VARCHAR(190) NOT NULL,
+    `metadata_prefix` VARCHAR(190) NOT NULL,
     `cursor` INT NOT NULL,
     `from` DATETIME DEFAULT NULL,
-    until DATETIME DEFAULT NULL,
-    `set` INT DEFAULT NULL,
-    expiration DATETIME NOT NULL,
-    INDEX IDX_E9AC4F9524CD504D (expiration),
-    PRIMARY KEY(id)
+    `until` DATETIME DEFAULT NULL,
+    `set` VARCHAR(190) DEFAULT NULL,
+    `expiration` DATETIME NOT NULL,
+    INDEX IDX_E9AC4F9524CD504D (`expiration`),
+    PRIMARY KEY(`id`)
 ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
 SQL;
         $connection->exec($sql);
@@ -133,6 +133,14 @@ SQL;
             $settings->set('oaipmhrepository_hide_empty_sets',
                 $defaultSettings['oaipmhrepository_hide_empty_sets']);
         }
+
+        if (version_compare($oldVersion, '3.2.2', '<')) {
+            $connection = $serviceLocator->get('Omeka\Connection');
+            $sql = <<<'SQL'
+ALTER TABLE oai_pmh_repository_token CHANGE `set` `set` VARCHAR(190) DEFAULT NULL;
+SQL;
+            $connection->exec($sql);
+        }
     }
 
     protected function manageSettings($settings, $process, $key = 'config')
diff --git a/src/Entity/OaiPmhRepositoryToken.php b/src/Entity/OaiPmhRepositoryToken.php
index 2718e05..45b0dd3 100644
--- a/src/Entity/OaiPmhRepositoryToken.php
+++ b/src/Entity/OaiPmhRepositoryToken.php
@@ -59,7 +59,7 @@ class OaiPmhRepositoryToken extends AbstractEntity
     protected $until;
 
     /**
-     * @Column(name="`set`", type="integer", nullable=true)
+     * @Column(name="`set`", type="string", length=190, nullable=true)
      */
     protected $set;
 
-- 
GitLab