19declare(strict_types=1);
33 return "PollImagesMigration";
54 $this->db = $environment->getResource(
Environment::RESOURCE_DATABASE);
55 $io = $environment->
getResource(Environment::RESOURCE_ADMIN_INTERACTION);
64 $res = $this->db->query(
"SELECT id, image FROM il_poll WHERE migrated = 0 LIMIT 1");
65 $row =
$res->fetchAssoc();
66 $image = $row[
"image"] ??
"";
74 $file_path = $this->getImageFullPath($image,
$id);
75 $thumbnail_path = $this->getThumbnailImagePath($image,
$id);
76 $org_path = $this->getOrgImagePath($image,
$id);
77 $stakeholder = (
new ilPollImageRepositoryStakeholder())->withUserId(6);
80 $rid = $irss_helper->movePathToStorage($file_path, 6,
null,
null,
false);
81 $rid_thumbnail = $irss_helper->movePathToStorage($thumbnail_path, 6,
null,
null,
false);
82 $org_thumbnail = $irss_helper->movePathToStorage($org_path, 6,
null,
null,
false);
84 $res_existing = $this->db->query(
"SELECT * FROM il_poll_image WHERE object_id = " . $this->db->quote(
$id,
ilDBConstants::T_INTEGER));
85 $row_existing = $res_existing->fetchAssoc();
87 if (is_null($row_existing)) {
88 $this->db->manipulate(
89 "INSERT INTO il_poll_image (object_id, rid) VALUES "
94 $irss_helper->getResourceBuilder()->remove($irss_helper->getResourceBuilder()->get($rid), $stakeholder);
97 $this->logError(
'Image ' . $file_path .
' of poll with object ID ' .
$id .
' could not be moved to storage.');
100 if (!is_null($rid_thumbnail)) {
101 $irss_helper->getResourceBuilder()->remove($irss_helper->getResourceBuilder()->get($rid_thumbnail), $stakeholder);
103 if (!is_null($org_thumbnail)) {
104 $irss_helper->getResourceBuilder()->remove($irss_helper->getResourceBuilder()->get($org_thumbnail), $stakeholder);
112 $res = $this->db->query(
113 'SELECT COUNT(*) AS count FROM il_poll WHERE migrated = 0'
115 $row = $this->db->fetchAssoc(
$res);
116 return (
int) $row[
'count'];
121 return $this->getLegacyPath(
$id) .
'/' . $img;
126 return $this->getLegacyPath(
$id) .
"/thb_" . $img;
131 return $this->getLegacyPath(
$id) .
"/org_" . $img;
142 if ($this->io ===
null) {
146 $this->io->error(
$text);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Wrapper around symfonies input and output facilities to provide just the functionality required for t...
static createPathFromId(int $a_container_id, string $a_name)
getImageFullPath(string $img, int $id)
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
step(Environment $environment)
Run one step of the migration.
getPreconditions(Environment $environment)
Objectives the migration depend on.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
getThumbnailImagePath(string $img, int $id)
getOrgImagePath(string $img, int $id)
prepare(Environment $environment)
Prepare the migration by means of some environment.
Class ilResourceStorageMigrationHelper.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
A migration is a potentially long lasting operation that can be broken into discrete steps.