ILIAS  release_8 Revision v8.24
class.ilFileObjectMigrationDoneObjective.php
Go to the documentation of this file.
1<?php
2
20use ILIAS\Setup;
23
25{
26 public function getHash(): string
27 {
28 return hash(
29 "sha256",
30 get_class($this)
31 );
32 }
33
34 public function getLabel(): string
35 {
36 return "File Migration has been performed in ILIAS 7.";
37 }
38
39 public function isNotable(): bool
40 {
41 return true;
42 }
43
44 public function getPreconditions(Environment $environment): array
45 {
46 return [
48 ];
49 }
50
51 public function achieve(Environment $environment): Environment
52 {
56 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
57 $db_error = false;
58 try {
59 $res = $db->query("SELECT file_id FROM file_data
60 LEFT JOIN object_data ON file_data.file_id = object_data.obj_id
61 LEFT JOIN object_reference ON object_reference.obj_id = object_data.obj_id
62 WHERE (rid IS NULL OR rid = '') AND file_data.max_version >= 1 AND object_reference.deleted IS NULL");
63 } catch (Throwable $t) {
64 $db_error = true;
65 } finally {
66 if ($db_error || $res->numRows() > 0) {
67 throw new Setup\NotExecutableException(
68 "File-Object migration has not been performed in ILIAS 7, at least {$res->numRows()} File-Objects won't be accessible anymore. Best you can do is revert to your backup and perform an upgrade to the latest ILIAS 7 and perform all Migrations. After that you can upgrade to ILIAS 8. Find more information in Modules/File/classes/Setup/MISSING_MIGRATION.md"
69 );
70 }
71 }
72
73 return $environment;
74 }
75
76 public function isApplicable(Environment $environment): bool
77 {
81 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
82 $res = $db->query("SELECT COUNT(file_id) AS amount FROM file_data WHERE rid IS NULL OR rid =''");
83 $d = $db->fetchObject($res);
84
85 return (int) $d->amount > 0;
86 }
87}
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
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.
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: ByTrying.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...