Skip to content

Commit

Permalink
Released version 3.6.20.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Berthereau authored and Daniel Berthereau committed Mar 18, 2024
1 parent 09f7d26 commit ebf44de
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/module.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ author_link = "https://gitlab.com/Daniel-KM"
module_link = "https://gitlab.com/Daniel-KM/Omeka-S-module-IiifServer"
support_link = "https://gitlab.com/Daniel-KM/Omeka-S-module-IiifServer/-/issues"
configurable = true
version = "3.6.19"
version = "3.6.20"
omeka_version_constraint = "^4.0.0"
40 changes: 40 additions & 0 deletions data/scripts/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*
* @var \Omeka\Api\Manager $api
* @var \Omeka\Settings\Settings $settings
* @var \Common\Stdlib\EasyMeta $easyMeta
* @var \Doctrine\DBAL\Connection $connection
* @var \Doctrine\ORM\EntityManager $entityManager
* @var \Omeka\Mvc\Controller\Plugin\Messenger $messenger
Expand All @@ -20,6 +21,8 @@
$api = $plugins->get('api');
$settings = $services->get('Omeka\Settings');
$translate = $plugins->get('translate');
$urlPlugin = $plugins->get('url');
$easyMeta = $services->get('EasyMeta');
$connection = $services->get('Omeka\Connection');
$messenger = $plugins->get('messenger');
$entityManager = $services->get('Omeka\EntityManager');
Expand Down Expand Up @@ -355,3 +358,40 @@
);
$messenger->addWarning($message);
}


if (version_compare($oldVersion, '3.6.20', '<')) {
$structureProperty = $settings->get('iiifserver_manifest_structures_property');
$structurePropertyId = $easyMeta->propertyId($structureProperty);
if ($structurePropertyId) {
// Module classes are not available during upgrade.
$qb = $connection->createQueryBuilder();
$qb
->select('COUNT(value.id)')
->from('value', 'value')
->innerJoin('value', 'item', 'item', 'item.id = value.resource_id')
->where('value.property_id = ' . $structurePropertyId)
->andWhere('value.value IS NOT NULL')
->andWhere('value.value != ""')
->orderBy('value.id', 'asc');
$structures = $connection->executeQuery($qb)->fetchOne();
if ($structures) {
require_once dirname(__DIR__, 2) . '/src/Job/UpgradeStructures.php';
$dispatcher = $services->get(\Omeka\Job\Dispatcher::class);
$job = $dispatcher->dispatch(\IiifServer\Job\UpgradeStructures::class);
$message = new PsrMessage(
'A job was launched to upgrade the format of "table of contents". Replaced tocs will be stored in logs ({link}job #{job_id}{link_end}, {link_log}logs{link_end}).', // @translate' // @translate
[
'link' => sprintf('<a href="%s">', htmlspecialchars($urlPlugin->fromRoute('admin/id', ['controller' => 'job', 'id' => $job->getId()]))),
'job_id' => $job->getId(),
'link_end' => '</a>',
'link_log' => class_exists('Log\Entity\Log')
? sprintf('<a href="%1$s">', $urlPlugin->fromRoute('admin/default', ['controller' => 'log'], ['query' => ['job_id' => $job->getId()]]))
: sprintf('<a href="%1$s">', $urlPlugin->fromRoute('admin/id', ['controller' => 'job', 'action' => 'log', 'id' => $job->getId()])),
]
);
$message->setEscapeHtml(false);
$messenger->addWarning($message);
}
}
}

0 comments on commit ebf44de

Please sign in to comment.