ILIAS  release_8 Revision v8.24
class.ilFileObjectToStorageMigration.php
Go to the documentation of this file.
1<?php
2
21use ILIAS\Setup;
23
25{
26 private const FILE_PATH_REGEX = '/.*\/file_([\d]*)$/';
27 public const MIGRATION_LOG_CSV = "migration_log.csv";
29
30 protected bool $prepared = false;
31 private bool $confirmed = false;
34
38 public function getLabel(): string
39 {
40 return "Migration of File-Objects to Storage service";
41 }
42
47 {
48 return 10;
49 }
50
54 public function getPreconditions(Environment $environment): array
55 {
57 }
58
62 public function prepare(Environment $environment): void
63 {
64 $irss_helper = new ilResourceStorageMigrationHelper(
66 $environment
67 );
68
69 $legacy_files_dir = $irss_helper->getClientDataDir() . "/ilFile";
70 $this->helper = new ilFileObjectToStorageMigrationHelper(
71 $irss_helper
72 );
73
74 global $DIC;
75 $DIC['ilDB'] = $irss_helper->getDatabase(); // needed inside some method calls to ILIAS
76
77 $storage_configuration = new LocalConfig($irss_helper->getClientDataDir());
79
80 $this->runner = new ilFileObjectToStorageMigrationRunner(
81 $f->getLocal($storage_configuration),
82 $irss_helper,
83 self::MIGRATION_LOG_CSV
84 );
85
86 $this->database = $irss_helper->getDatabase();
87 }
88
92 public function step(Environment $environment): void
93 {
94 if ($this->helper === null) {
95 $environment->getResource(Environment::RESOURCE_ADMIN_INTERACTION)->inform(
96 "No migration possible, base-directory not found."
97 );
98 return;
99 }
100 $this->showConfirmation($environment);
101 $item = $this->helper->getNext();
102 $this->runner->migrate($item);
103 }
104
109 {
110 $r = $this->database->query("SELECT COUNT(file_id) AS amount FROM file_data WHERE rid IS NULL OR rid = '';");
111 $d = $this->database->fetchObject($r);
112
113 return (int) $d->amount;
114 }
115
120 protected function showConfirmation(Environment $environment): void
121 {
122 if (!$this->confirmed) {
123 $io = $environment->getResource(Setup\Environment::RESOURCE_ADMIN_INTERACTION);
124 $this->confirmed = $io->confirmExplicit(
125 'The migration of File-Objects should be done in ILIAS 7 not 8, see Modules/File/classes/Setup/MISSING_MIGRATION.md, type "Understood" to proceed',
126 'Understood'
127 );
128 }
129 }
130}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
prepare(Environment $environment)
@inheritDoc
step(Environment $environment)
@inheritDoc
getPreconditions(Environment $environment)
@inheritDoc
ilFileObjectToStorageMigrationHelper $helper
ilFileObjectToStorageMigrationRunner $runner
Class ilObjFileStakeholder.
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
global $DIC
Definition: feed.php:28
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
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.
Definition: Migration.php:29
Interface ilDBInterface.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...