19 declare(strict_types=1);
37 return "Migration of DataCollection files to the Resource Storage Service.";
45 return self::DEFAULT_AMOUNT_OF_STEPS;
59 public function prepare(\
ILIAS\Setup\Environment $environment): void
70 public function step(\
ILIAS\Setup\Environment $environment): void
72 $integer_storage =
"il_dcl_stloc2_value";
73 $string_storage =
"il_dcl_stloc1_value";
74 $db = $this->helper->getDatabase();
78 $legacy_file_field = $db->fetchObject(
80 "SELECT * FROM il_dcl_field AS field WHERE datatype_id = 6 LIMIT 1;" 85 $legacy_file_records = $db->queryF(
86 "SELECT * FROM il_dcl_record_field AS record_field WHERE record_field.field_id = %s;",
88 [$legacy_file_field->id]
90 while ($record = $db->fetchObject($legacy_file_records)) {
92 $legacy_file_record = $db->fetchObject(
94 "SELECT id, rid, file_id, record_field_id 95 FROM $integer_storage AS storage 96 JOIN file_data AS file ON file.file_id = storage.value 97 WHERE storage.record_field_id = %s;",
102 if ($legacy_file_record ===
null) {
106 $rid = $legacy_file_record->rid ??
null;
108 $db->insert($string_storage, [
109 'id' => [
'integer', $db->nextId($string_storage)],
110 'record_field_id' => [
'integer', (
int) $legacy_file_record->record_field_id],
111 'value' => [
'text', $rid],
116 "DELETE FROM $integer_storage WHERE id = %s;",
118 [(
int) $legacy_file_record->id]
122 $this->helper->moveResourceToNewStakeholderAndOwner(
125 $this->helper->getStakeholder()
130 $file_id = (
int) $legacy_file_record->file_id;
132 "DELETE FROM file_data WHERE file_id = %s",
137 "DELETE FROM history WHERE obj_id = %s",
139 [(
int) $legacy_file_record->id]
142 "DELETE FROM object_data WHERE obj_id = %s AND type = %s",
144 [(
int) $legacy_file_record->id,
'file']
152 $db->update(
"il_dcl_field", [
155 'id' => [
'integer', (
int) $legacy_file_field->id],
164 $legacy_file_field_amount = $this->helper->getDatabase()->fetchObject(
165 $this->helper->getDatabase()->query(
166 "SELECT COUNT(field.id) AS amount FROM il_dcl_field AS field WHERE field.datatype_id = 6;" 170 return (
int) $legacy_file_field_amount?->amount;
const DEFAULT_AMOUNT_OF_STEPS
prepare(\ILIAS\Setup\Environment $environment)
Class ilObjFileStakeholder.
getRemainingAmountOfSteps()
Interface Observer Contains several chained tasks and infos about them.
A migration is a potentially long lasting operation that can be broken into discrete steps...
AutoloadingIssuesInspection
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class ResourceIdentification.
ilResourceStorageMigrationHelper $helper
getPreconditions(\ILIAS\Setup\Environment $environment)
step(\ILIAS\Setup\Environment $environment)
getDefaultAmountOfStepsPerRun()
static getPreconditions()