From b1468940731a0c970c1849f4304b4e1ffd6d098d Mon Sep 17 00:00:00 2001 From: Luka Stocker Date: Wed, 20 Nov 2024 12:27:26 +0100 Subject: [PATCH] ORGU: 42725, include a setup objective process to remove assigned meta data sets from OrgUnit types if the meta data sets are already deleted but are still assigned to OrgUnit types. https://mantis.ilias.de/view.php?id=42725 Please note that you have to run 'php cli/setup.php achieve orgunit.removeDeletedMDSetsFromOrgUnitTypes'. --- .../Init/classes/class.ilInitialisation.php | 2 +- .../Setup/class.ilOrgUnitSetupAgent.php | 4 ++ .../ilOrgUnitRemoveDeletedMDSetsObjective.php | 68 +++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 components/ILIAS/OrgUnit/classes/Setup/ilOrgUnitRemoveDeletedMDSetsObjective.php diff --git a/components/ILIAS/Init/classes/class.ilInitialisation.php b/components/ILIAS/Init/classes/class.ilInitialisation.php index dfdc9eed2df4..8b994604db7e 100755 --- a/components/ILIAS/Init/classes/class.ilInitialisation.php +++ b/components/ILIAS/Init/classes/class.ilInitialisation.php @@ -1158,7 +1158,7 @@ protected static function abortAndDie(string $a_message): void { if (isset($GLOBALS['ilLog'])) { $GLOBALS['ilLog']->write("Fatal Error: ilInitialisation - " . $a_message); - $GLOBALS['ilLog']->logStack(); + //$GLOBALS['ilLog']->logStack(); } die($a_message); } diff --git a/components/ILIAS/OrgUnit/classes/Setup/class.ilOrgUnitSetupAgent.php b/components/ILIAS/OrgUnit/classes/Setup/class.ilOrgUnitSetupAgent.php index d1409cc2f9bd..73af17fea34f 100644 --- a/components/ILIAS/OrgUnit/classes/Setup/class.ilOrgUnitSetupAgent.php +++ b/components/ILIAS/OrgUnit/classes/Setup/class.ilOrgUnitSetupAgent.php @@ -72,6 +72,10 @@ public function getNamedObjectives(?Setup\Config $config = null): array 'removeDeletedUsersFromOrgUnits' => new Setup\ObjectiveConstructor( 'clean assignments of deleted users', static fn(): Setup\Objective => new ilOrgUnitRemoveDeletedUsersObjective() + ), + 'removeDeletedMDSetsFromOrgUnitTypes' => new Setup\ObjectiveConstructor( + 'clean assignments of deleted meta data sets', + static fn(): Setup\Objective => new ilOrgUnitRemoveDeletedMDSetsObjective() ) ]; } diff --git a/components/ILIAS/OrgUnit/classes/Setup/ilOrgUnitRemoveDeletedMDSetsObjective.php b/components/ILIAS/OrgUnit/classes/Setup/ilOrgUnitRemoveDeletedMDSetsObjective.php new file mode 100644 index 000000000000..8bfed0bc23b2 --- /dev/null +++ b/components/ILIAS/OrgUnit/classes/Setup/ilOrgUnitRemoveDeletedMDSetsObjective.php @@ -0,0 +1,68 @@ +getResource(Environment::RESOURCE_DATABASE); + $query = 'DELETE FROM orgu_types_adv_md_rec' . PHP_EOL + . 'WHERE rec_id NOT IN (' . PHP_EOL + . 'SELECT record_id FROM adv_md_record' . PHP_EOL + . ')'; + $db->manipulate($query); + return $environment; + } + + public function isApplicable(Environment $environment): bool + { + return true; + } +}