diff --git a/components/ILIAS/BackgroundTasks/BackgroundTasks.php b/components/ILIAS/BackgroundTasks/BackgroundTasks.php index 499dcbc2228e..8f7e59d9219f 100644 --- a/components/ILIAS/BackgroundTasks/BackgroundTasks.php +++ b/components/ILIAS/BackgroundTasks/BackgroundTasks.php @@ -21,10 +21,18 @@ namespace ILIAS; use ILIAS\Component\Component; +use ILIAS\Component\Resource\PublicAsset; +use ILIAS\Component\Resource\ComponentJS; use ILIAS\Setup\Agent; use ILIAS\Refinery\Factory; use ILIAS\Language\ComponentTranslation\LanguageFileDirectory; use ILIAS\Language\ComponentTranslation\ComponentLanguageFileDirectory; +use ILIAS\BackgroundTasks\Registry\Registry; +use ILIAS\BackgroundTasks\Task; +use ILIAS\BackgroundTasks\Value; +use ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry; +use ILIAS\BackgroundTasks\Implementation\Values; +use ILIAS\BackgroundTasks\Implementation\Tasks; class BackgroundTasks implements Component { @@ -38,8 +46,27 @@ public function init( array | \ArrayAccess &$pull, array | \ArrayAccess &$internal, ): void { - $contribute[Agent::class] = static fn(): \ilBackgroundTasksSetupAgent => - new \ilBackgroundTasksSetupAgent( + $define[] = Registry::class; + + // components putting tasks or values into buckets contribute them, see Registry\Registry + $implement[Registry::class] = static fn(): Registry => + new BasicRegistry( + $seek[Task::class], + $seek[Value::class] + ); + + $contribute[Value::class] = static fn() => new Values\ScalarValues\ScalarValue(); + $contribute[Value::class] = static fn() => new Values\ScalarValues\BooleanValue(); + $contribute[Value::class] = static fn() => new Values\ScalarValues\FloatValue(); + $contribute[Value::class] = static fn() => new Values\ScalarValues\IntegerValue(); + $contribute[Value::class] = static fn() => new Values\ScalarValues\StringValue(); + $contribute[Value::class] = static fn() => new Values\AggregationValues\ListValue(); + $contribute[Value::class] = static fn() => new Values\ThunkValue(); + $contribute[Task::class] = static fn() => new Tasks\Aggregation\ConcatenationJob(); + $contribute[Task::class] = static fn() => new Tasks\NotFoundUserInteraction(); + + $contribute[Agent::class] = static fn(): Agent => + new \ILIAS\BackgroundTasks\Setup\Agent( $pull[Factory::class] ); $contribute[LanguageFileDirectory::class] = fn() => new ComponentLanguageFileDirectory( @@ -50,5 +77,10 @@ public function init( $this, 'background_tasks' ); + + $contribute[PublicAsset::class] = fn(): ComponentJS => new ComponentJS( + $this, + "background_task_refresh.js" + ); } } diff --git a/components/ILIAS/BackgroundTasks/ROADMAP.md b/components/ILIAS/BackgroundTasks/ROADMAP.md new file mode 100644 index 000000000000..291ac458d56f --- /dev/null +++ b/components/ILIAS/BackgroundTasks/ROADMAP.md @@ -0,0 +1,29 @@ +# Roadmap + +## Mid Term + +### Build all Tasks and Values from their Contributions + +Components contribute their tasks and values to the bootstrap, see `Registry\Registry`. The task +factory and the persistence clone these contributions. A task or value nobody contributed is still +built by the `Dependencies\Injector`, which resolves its constructor arguments from the legacy +container. This fallback is needed as long as not all components contribute their tasks and values, +and as long as plugins cannot contribute to the bootstrap at all. + +The goal is to build all tasks and values from their contributions and to remove the `Injector` +together with its `DependencyMap`. Before that, every component putting tasks or values into +buckets has to contribute them and pass their dependencies through the constructor, and plugins +need a way to contribute theirs. + +### Move the Initialisation out of ilInitialisation + +The task factory, the persistence, the task manager and the injector are still set up in +`ilInitialisation::initBackgroundTasks()` and `ilInitialisation::initInjector()` and reach the +rest of the system through the legacy container, while only the `Registry` comes from the bootstrap. +Scripts calling `ilInitialisation::initILIAS()` directly get an empty `Registry`. The goal is to +initialise BackgroundTasks completely through the component bootstrap, as described in +`components/ILIAS/Component/docs/component-bootstrap-migration.md`, and to bridge the services into +the legacy container through `AllModernComponents` as long as they are needed there. This includes +putting the settings read from `ilias.ini.php` (`concurrency`, `number_of_concurrent_tasks`) behind +a configuration interface and replacing the static `BasicPersistence::instance()` and the global +`$DIC` it uses. diff --git a/components/ILIAS/BackgroundTasks_/resources/background_task_refresh.js b/components/ILIAS/BackgroundTasks/resources/background_task_refresh.js similarity index 59% rename from components/ILIAS/BackgroundTasks_/resources/background_task_refresh.js rename to components/ILIAS/BackgroundTasks/resources/background_task_refresh.js index f7a41959b735..4ee279ef8bb4 100644 --- a/components/ILIAS/BackgroundTasks_/resources/background_task_refresh.js +++ b/components/ILIAS/BackgroundTasks/resources/background_task_refresh.js @@ -1,3 +1,18 @@ +/** + * This file is part of ILIAS, a powerful learning management system + * published by ILIAS open source e-Learning e.V. + * + * ILIAS is licensed with the GPL-3.0, + * see https://www.gnu.org/licenses/gpl-3.0.en.html + * You should have received a copy of said license along with the + * source code, too. + * + * If this is not the case or you just want to try ILIAS, you'll find + * us at: + * https://www.ilias.de + * https://github.com/ILIAS-eLearning + */ + il = il || {}; il.BGTask = il.BGTask || {}; (function ($, il) { diff --git a/components/ILIAS/BackgroundTasks/service.xml b/components/ILIAS/BackgroundTasks/service.xml index 7b1d010dddd7..611bb9016ad9 100644 --- a/components/ILIAS/BackgroundTasks/service.xml +++ b/components/ILIAS/BackgroundTasks/service.xml @@ -2,7 +2,7 @@ - + diff --git a/components/ILIAS/BackgroundTasks/src/BackgroundTaskServices.php b/components/ILIAS/BackgroundTasks/src/BackgroundTaskServices.php index 18f7e30b120b..9de0104d6c57 100755 --- a/components/ILIAS/BackgroundTasks/src/BackgroundTaskServices.php +++ b/components/ILIAS/BackgroundTasks/src/BackgroundTaskServices.php @@ -23,6 +23,7 @@ use ILIAS\BackgroundTasks\TaskManager; use ILIAS\DI\Container; use ILIAS\BackgroundTasks\Dependencies\Injector; +use ILIAS\BackgroundTasks\Registry\Registry; /** * Class BackgroundTaskServices @@ -54,4 +55,9 @@ public function injector(): Injector { return $this->container['bt.injector']; } + + public function registry(): Registry + { + return $this->container[Registry::class]; + } } diff --git a/components/ILIAS/BackgroundTasks/src/Implementation/Persistence/BasicPersistence.php b/components/ILIAS/BackgroundTasks/src/Implementation/Persistence/BasicPersistence.php index a8441b33dc37..2f1251a7be0a 100755 --- a/components/ILIAS/BackgroundTasks/src/Implementation/Persistence/BasicPersistence.php +++ b/components/ILIAS/BackgroundTasks/src/Implementation/Persistence/BasicPersistence.php @@ -449,6 +449,7 @@ private function loadTask(int $taskContainerId, Bucket $bucket, BucketContainer private function loadValue($valueContainerId, Bucket $bucket, BucketContainer $bucketContainer): Value { global $DIC; + $registry = $DIC->backgroundTasks()->registry(); $factory = $DIC->backgroundTasks()->injector(); /** @var ValueContainer $valueContainer */ @@ -461,7 +462,9 @@ private function loadValue($valueContainerId, Bucket $bucket, BucketContainer $b /** @noinspection PhpIncludeInspection */ /** @var Value $value */ - $value = $factory->createInstance($valueContainer->getClassName()); + $value = $registry->isRegistered($valueContainer->getClassName()) + ? $registry->newValue($valueContainer->getClassName()) + : $factory->createInstance($valueContainer->getClassName()); $value->unserialize($valueContainer->getSerialized()); if ($valueContainer->getHasParenttask() !== 0) { diff --git a/components/ILIAS/BackgroundTasks/src/Implementation/Registry/BasicRegistry.php b/components/ILIAS/BackgroundTasks/src/Implementation/Registry/BasicRegistry.php new file mode 100644 index 000000000000..61702cb48d45 --- /dev/null +++ b/components/ILIAS/BackgroundTasks/src/Implementation/Registry/BasicRegistry.php @@ -0,0 +1,84 @@ + + */ + private array $tasks = []; + + /** + * @var array + */ + private array $values = []; + + /** + * @param Task[] $tasks + * @param Value[] $values + */ + public function __construct(array $tasks, array $values) + { + foreach ($tasks as $task) { + $this->tasks[$this->unique($task)] = $task; + } + foreach ($values as $value) { + $this->values[$this->unique($value)] = $value; + } + } + + public function isRegistered(string $class_name): bool + { + $class_name = ltrim($class_name, '\\'); + return isset($this->tasks[$class_name]) || isset($this->values[$class_name]); + } + + public function newTask(string $class_name): Task + { + $class_name = ltrim($class_name, '\\'); + if (!isset($this->tasks[$class_name])) { + throw new \OutOfBoundsException("No task $class_name is registered."); + } + return clone $this->tasks[$class_name]; + } + + public function newValue(string $class_name): Value + { + $class_name = ltrim($class_name, '\\'); + if (!isset($this->values[$class_name])) { + throw new \OutOfBoundsException("No value $class_name is registered."); + } + return clone $this->values[$class_name]; + } + + private function unique(Task|Value $prototype): string + { + $class_name = $prototype::class; + if (isset($this->tasks[$class_name]) || isset($this->values[$class_name])) { + throw new \LogicException("$class_name is contributed more than once."); + } + return $class_name; + } +} diff --git a/components/ILIAS/BackgroundTasks/src/Implementation/Tasks/BasicTaskFactory.php b/components/ILIAS/BackgroundTasks/src/Implementation/Tasks/BasicTaskFactory.php index 17fac97198cd..5473f7494c48 100755 --- a/components/ILIAS/BackgroundTasks/src/Implementation/Tasks/BasicTaskFactory.php +++ b/components/ILIAS/BackgroundTasks/src/Implementation/Tasks/BasicTaskFactory.php @@ -23,13 +23,16 @@ use ILIAS\BackgroundTasks\Task; use ILIAS\BackgroundTasks\Task\TaskFactory; use ILIAS\BackgroundTasks\Value; +use ILIAS\BackgroundTasks\Registry\Registry; class BasicTaskFactory implements TaskFactory { use BasicScalarValueFactory; - public function __construct(protected Injector $injector) - { + public function __construct( + protected Injector $injector, + protected Registry $registry + ) { } /** @@ -37,11 +40,15 @@ public function __construct(protected Injector $injector) */ public function createTask(string $class_name, ?array $input = null): Task { - if (!class_exists($class_name)) { + if ($this->registry->isRegistered($class_name)) { + $task = $this->registry->newTask($class_name); + } elseif (class_exists($class_name)) { + // not contributed (yet), e.g. tasks of plugins, see ROADMAP.md + /** @var Task $task */ + $task = $this->injector->createInstance($class_name); + } else { return new NotFoundUserInteraction(); } - /** @var Task $task */ - $task = $this->injector->createInstance($class_name); if ($input) { $wrappedInput = array_map(function ($i): Value { if ($i instanceof Task) { diff --git a/components/ILIAS/BackgroundTasks_/classes/class.ilBTControllerGUI.php b/components/ILIAS/BackgroundTasks/src/Implementation/UI/ControllerGUI.php similarity index 97% rename from components/ILIAS/BackgroundTasks_/classes/class.ilBTControllerGUI.php rename to components/ILIAS/BackgroundTasks/src/Implementation/UI/ControllerGUI.php index f6e9d13d048c..e4b70def358b 100755 --- a/components/ILIAS/BackgroundTasks_/classes/class.ilBTControllerGUI.php +++ b/components/ILIAS/BackgroundTasks/src/Implementation/UI/ControllerGUI.php @@ -16,6 +16,8 @@ * *********************************************************************/ +namespace ILIAS\BackgroundTasks\Implementation\UI; + use ILIAS\HTTP\StatusCode; use ILIAS\Filesystem\Stream\Streams; use ILIAS\Data\URI; @@ -25,14 +27,15 @@ use ILIAS\HTTP\Response\ResponseHeader; use ILIAS\BackgroundTasks\Implementation\Tasks\UserInteraction\UserInteractionOption; use ILIAS\components\OrgUnit\ARHelper\DIC; +use ilCtrlBaseClassInterface; +use ilCtrlSecurityInterface; +use ilUtil; /** - * Class ilBTControllerGUI - * * @author Oskar Truffer * @author Fabian Schmid */ -class ilBTControllerGUI implements ilCtrlBaseClassInterface, ilCtrlSecurityInterface +class ControllerGUI implements ilCtrlBaseClassInterface, ilCtrlSecurityInterface { use DIC; public const FROM_URL = 'from_url'; @@ -130,7 +133,7 @@ protected function getAsyncReplacementItem(): void $this->enforceBucketBelongsToCurrentUser($bucket); - $item_source = new ilBTPopOverGUI($this->dic()); + $item_source = new PopOverGUI($this->dic()); $this->dic()->language()->loadLanguageModule('background_tasks'); $item = $item_source->getItemForObserver($bucket); diff --git a/components/ILIAS/BackgroundTasks_/classes/class.ilBTPopOverGUI.php b/components/ILIAS/BackgroundTasks/src/Implementation/UI/PopOverGUI.php similarity index 83% rename from components/ILIAS/BackgroundTasks_/classes/class.ilBTPopOverGUI.php rename to components/ILIAS/BackgroundTasks/src/Implementation/UI/PopOverGUI.php index 8577b6f034b3..0fe443677731 100755 --- a/components/ILIAS/BackgroundTasks_/classes/class.ilBTPopOverGUI.php +++ b/components/ILIAS/BackgroundTasks/src/Implementation/UI/PopOverGUI.php @@ -16,13 +16,14 @@ * *********************************************************************/ +namespace ILIAS\BackgroundTasks\Implementation\UI; + use ILIAS\DI\Container; use ILIAS\UI\Component\Item\Notification; use ILIAS\BackgroundTasks\Task\UserInteraction\Option; use ILIAS\BackgroundTasks\Bucket; use ILIAS\BackgroundTasks\Implementation\Bucket\State; use ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask; -use ILIAS\BackgroundTasks\Implementation\UI\StateTranslator; use ILIAS\BackgroundTasks\Task\UserInteraction; use ILIAS\UI\Component\Button\Button; use ILIAS\UI\Component\Button\Shy; @@ -30,12 +31,10 @@ use ILIAS\BackgroundTasks\Task\Job; /** - * Class ilBTPopOverGUI - * * @author Oskar Truffer * @author Fabian Schmid */ -class ilBTPopOverGUI +class PopOverGUI { use StateTranslator; @@ -168,18 +167,18 @@ public function getUserInteractionContent(Bucket $observer, string $redirect_uri return array_map( function (Option $option) use ($ctrl, $factory, $observer, $persistence, $redirect_uri, $language): Shy { $ctrl->setParameterByClass( - ilBTControllerGUI::class, - ilBTControllerGUI::FROM_URL, - ilBTControllerGUI::hash("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}") + ControllerGUI::class, + ControllerGUI::FROM_URL, + ControllerGUI::hash("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}") ); $ctrl->setParameterByClass( - ilBTControllerGUI::class, - ilBTControllerGUI::SELECTED_OPTION, + ControllerGUI::class, + ControllerGUI::SELECTED_OPTION, $option->getValue() ); $ctrl->setParameterByClass( - ilBTControllerGUI::class, - ilBTControllerGUI::OBSERVER_ID, + ControllerGUI::class, + ControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer) ); $this->addFromUrlToNextRequest($redirect_uri); @@ -187,7 +186,7 @@ function (Option $option) use ($ctrl, $factory, $observer, $persistence, $redire return $factory->button() ->shy( $language->txt($option->getLangVar()), - $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_USER_INTERACTION) + $ctrl->getLinkTargetByClass([ControllerGUI::class], ControllerGUI::CMD_USER_INTERACTION) ); }, $options @@ -227,20 +226,20 @@ private function getCloseButtonAction(Option $option, string $redirect_uri, Buck { $ctrl = $this->dic->ctrl(); $persistence = $this->dic->backgroundTasks()->persistence(); - $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer)); + $ctrl->setParameterByClass(ControllerGUI::class, ControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer)); $this->addFromUrlToNextRequest($redirect_uri); - $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::IS_ASYNC, "true"); + $ctrl->setParameterByClass(ControllerGUI::class, ControllerGUI::IS_ASYNC, "true"); switch ($option->getValue()) { case AbstractTask::MAIN_ABORT: - $action = $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_ABORT); + $action = $ctrl->getLinkTargetByClass([ControllerGUI::class], ControllerGUI::CMD_ABORT); break; case AbstractTask::MAIN_REMOVE: - $action = $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_REMOVE); + $action = $ctrl->getLinkTargetByClass([ControllerGUI::class], ControllerGUI::CMD_REMOVE); break; default: - $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::SELECTED_OPTION, $option->getValue()); - $action = $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_USER_INTERACTION); + $ctrl->setParameterByClass(ControllerGUI::class, ControllerGUI::SELECTED_OPTION, $option->getValue()); + $action = $ctrl->getLinkTargetByClass([ControllerGUI::class], ControllerGUI::CMD_USER_INTERACTION); break; } @@ -252,15 +251,15 @@ private function getRefreshUrl(Bucket $observer): string { $ctrl = $this->dic->ctrl(); $persistence = $this->dic->backgroundTasks()->persistence(); - $ctrl->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer)); + $ctrl->setParameterByClass(ControllerGUI::class, ControllerGUI::OBSERVER_ID, $persistence->getBucketContainerId($observer)); - return $ctrl->getLinkTargetByClass([ilBTControllerGUI::class], ilBTControllerGUI::CMD_GET_REPLACEMENT_ITEM); + return $ctrl->getLinkTargetByClass([ControllerGUI::class], ControllerGUI::CMD_GET_REPLACEMENT_ITEM); } private function addFromUrlToNextRequest(string $redirect_uri): void { - $this->dic->ctrl()->setParameterByClass(ilBTControllerGUI::class, ilBTControllerGUI::FROM_URL, ilBTControllerGUI::hash($redirect_uri)); + $this->dic->ctrl()->setParameterByClass(ControllerGUI::class, ControllerGUI::FROM_URL, ControllerGUI::hash($redirect_uri)); } diff --git a/components/ILIAS/BackgroundTasks_/classes/StateTranslator.php b/components/ILIAS/BackgroundTasks/src/Implementation/UI/StateTranslator.php similarity index 100% rename from components/ILIAS/BackgroundTasks_/classes/StateTranslator.php rename to components/ILIAS/BackgroundTasks/src/Implementation/UI/StateTranslator.php diff --git a/components/ILIAS/BackgroundTasks_/classes/Provider/BTNotificationProvider.php b/components/ILIAS/BackgroundTasks/src/Provider/BTNotificationProvider.php similarity index 95% rename from components/ILIAS/BackgroundTasks_/classes/Provider/BTNotificationProvider.php rename to components/ILIAS/BackgroundTasks/src/Provider/BTNotificationProvider.php index 75f9124674a1..bd50973a09ba 100755 --- a/components/ILIAS/BackgroundTasks_/classes/Provider/BTNotificationProvider.php +++ b/components/ILIAS/BackgroundTasks/src/Provider/BTNotificationProvider.php @@ -18,7 +18,7 @@ namespace ILIAS\BackgroundTasks\Provider; -use ilBTPopOverGUI; +use ILIAS\BackgroundTasks\Implementation\UI\PopOverGUI; use ILIAS\GlobalScreen\Identification\IdentificationInterface; use ILIAS\GlobalScreen\Scope\Notification\Provider\AbstractNotificationProvider; use ILIAS\GlobalScreen\Scope\Notification\Provider\NotificationProvider; @@ -47,7 +47,7 @@ public function getNotifications(): array $factory = $this->globalScreen()->notifications()->factory(); - $item_source = new ilBTPopOverGUI($this->dic); + $item_source = new PopOverGUI($this->dic); $group = $factory->standardGroup($id('bg_task_bucket_group')) ->withTitle($this->txt('background_tasks')) ->addNotification( diff --git a/components/ILIAS/BackgroundTasks/src/Registry/Registry.php b/components/ILIAS/BackgroundTasks/src/Registry/Registry.php new file mode 100644 index 000000000000..7d69422c1752 --- /dev/null +++ b/components/ILIAS/BackgroundTasks/src/Registry/Registry.php @@ -0,0 +1,55 @@ +refinery->custom()->transformation(fn($data): \ilBackgroundTasksSetupConfig => new \ilBackgroundTasksSetupConfig( - $data["type"] ?? \ilBackgroundTasksSetupConfig::TYPE_SYNCHRONOUS, + return $this->refinery->custom()->transformation(fn($data): SetupConfig => new SetupConfig( + $data["type"] ?? SetupConfig::TYPE_SYNCHRONOUS, $data["max_number_of_concurrent_tasks"] ?? 1 )); } - /** - * @inheritdoc - */ public function getInstallObjective(?Config $config = null): Objective { return $this->getUpdateObjective($config); } - /** - * @inheritdoc - */ public function getUpdateObjective(?Config $config = null): Objective { - if (!$config instanceof ilBackgroundTasksSetupConfig) { + if (!$config instanceof SetupConfig) { return new NullObjective(); } return new ObjectiveCollection( 'BackgroundTasks', true, - new ilBackgroundTasksConfigStoredObjective($config), + new ConfigStoredObjective($config), new ilDatabaseUpdateStepsExecutedObjective(new ilBackgroundTasksDBHotfixes10()) ); } - /** - * @inheritdoc - */ public function getBuildObjective(): Objective { return new NullObjective(); } - /** - * @inheritdoc - */ public function getStatusObjective(Storage $storage): Objective { return new ObjectiveCollection( 'Component BackgroundTasks', true, - new ilBackgroundTasksMetricsCollectedObjective($storage), + new MetricsCollectedObjective($storage), new ilDatabaseUpdateStepsMetricsCollectedObjective($storage, new ilBackgroundTasksDBHotfixes10()) ); } @@ -111,9 +96,6 @@ public function getNamedObjectives(?Config $config = null): array ]; } - /** - * @inheritDoc - */ public function getMigrations(): array { return []; diff --git a/components/ILIAS/BackgroundTasks_/classes/Setup/BackgoundWorkerObjective.php b/components/ILIAS/BackgroundTasks/src/Setup/BackgoundWorkerObjective.php similarity index 95% rename from components/ILIAS/BackgroundTasks_/classes/Setup/BackgoundWorkerObjective.php rename to components/ILIAS/BackgroundTasks/src/Setup/BackgoundWorkerObjective.php index 7fb67bc56d18..dfeaa47fbc68 100644 --- a/components/ILIAS/BackgroundTasks_/classes/Setup/BackgoundWorkerObjective.php +++ b/components/ILIAS/BackgroundTasks/src/Setup/BackgoundWorkerObjective.php @@ -28,16 +28,13 @@ use ilCurlConnection; use RuntimeException; use ILIAS\DI\Container; -use ILIAS\Setup\Objective; use ILIAS\Setup\Environment; -use ilCurlConnectionException; use ILIAS\Setup\CLI\IOWrapper; use ilIniFilesPopulatedObjective; use ilDatabaseInitializedObjective; use ilSettingsFactoryExistsObjective; use ILIAS\Setup\Objective\ClientIdReadObjective; use ILIAS\Setup\Objective\AdminConfirmedObjective; -use ilBackgroundTasksSetupConfig; class BackgoundWorkerObjective extends AdminConfirmedObjective { @@ -68,9 +65,6 @@ public function isNotable(): bool return true; } - /** - * @return Objective[] - */ public function getPreconditions(Environment $environment): array { return [ @@ -81,9 +75,6 @@ public function getPreconditions(Environment $environment): array ]; } - /** - * @inheritDoc - */ public function isApplicable(Environment $environment): bool { $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI); @@ -92,7 +83,7 @@ public function isApplicable(Environment $environment): bool return false; } - return $ini->readVariable('background_tasks', 'concurrency') === ilBackgroundTasksSetupConfig::TYPE_ASYNCHRONOUS; + return $ini->readVariable('background_tasks', 'concurrency') === SetupConfig::TYPE_ASYNCHRONOUS; } public function achieve(Environment $environment): Environment @@ -194,9 +185,6 @@ private function error(string $text): void $this->io->error($text); } - /** - * @throws ilCurlConnectionException - */ private function getCurlConnection(ilSetting $settings, string $url): ilCurlConnection { $curl = new ilCurlConnection( diff --git a/components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksConfigStoredObjective.php b/components/ILIAS/BackgroundTasks/src/Setup/ConfigStoredObjective.php similarity index 86% rename from components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksConfigStoredObjective.php rename to components/ILIAS/BackgroundTasks/src/Setup/ConfigStoredObjective.php index 7bb8908b32a1..627921ddd046 100755 --- a/components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksConfigStoredObjective.php +++ b/components/ILIAS/BackgroundTasks/src/Setup/ConfigStoredObjective.php @@ -16,13 +16,16 @@ * *********************************************************************/ +namespace ILIAS\BackgroundTasks\Setup; + use ILIAS\Setup\Objective; use ILIAS\Setup\Environment; use ILIAS\Setup\UnachievableException; +use ilIniFilesLoadedObjective; -class ilBackgroundTasksConfigStoredObjective implements Objective +class ConfigStoredObjective implements Objective { - public function __construct(protected ilBackgroundTasksSetupConfig $config) + public function __construct(protected SetupConfig $config) { } @@ -33,7 +36,7 @@ public function getHash(): string public function getLabel(): string { - return "Fill ini with settings for components/ILIAS/BackgroundTasks_"; + return "Fill ini with settings for components/ILIAS/BackgroundTasks"; } public function isNotable(): bool @@ -41,9 +44,6 @@ public function isNotable(): bool return false; } - /** - * @return \ilIniFilesLoadedObjective[] - */ public function getPreconditions(Environment $environment): array { return [ @@ -59,9 +59,8 @@ public function achieve(Environment $environment): Environment $ini->addGroup("background_tasks"); } - if ($this->config->getType() === \ilBackgroundTasksSetupConfig::TYPE_ASYNCHRONOUS) { + if ($this->config->getType() === SetupConfig::TYPE_ASYNCHRONOUS) { $io = $environment->getResource(Environment::RESOURCE_ADMIN_INTERACTION); - /** @var Setup\CLI\IOWrapper $io */ $io->inform('Asynchronous background tasks need SOAP administration to be enabled. Make sure to enable it in your configuarion.'); } @@ -75,9 +74,6 @@ public function achieve(Environment $environment): Environment return $environment; } - /** - * @inheritDoc - */ public function isApplicable(Environment $environment): bool { $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI); diff --git a/components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksMetricsCollectedObjective.php b/components/ILIAS/BackgroundTasks/src/Setup/MetricsCollectedObjective.php similarity index 91% rename from components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksMetricsCollectedObjective.php rename to components/ILIAS/BackgroundTasks/src/Setup/MetricsCollectedObjective.php index 0236691d7251..c03c5a82fd97 100755 --- a/components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksMetricsCollectedObjective.php +++ b/components/ILIAS/BackgroundTasks/src/Setup/MetricsCollectedObjective.php @@ -16,15 +16,15 @@ * *********************************************************************/ +namespace ILIAS\BackgroundTasks\Setup; + use ILIAS\Setup\Metrics\CollectedObjective; use ILIAS\Setup\Environment; use ILIAS\Setup\Metrics\Storage; +use ilIniFilesLoadedObjective; -class ilBackgroundTasksMetricsCollectedObjective extends CollectedObjective +class MetricsCollectedObjective extends CollectedObjective { - /** - * @return \ilIniFilesLoadedObjective[] - */ public function getTentativePreconditions(Environment $environment): array { return [ diff --git a/components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksSetupConfig.php b/components/ILIAS/BackgroundTasks/src/Setup/SetupConfig.php similarity index 95% rename from components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksSetupConfig.php rename to components/ILIAS/BackgroundTasks/src/Setup/SetupConfig.php index 4f2c7003399c..068042a8a526 100755 --- a/components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksSetupConfig.php +++ b/components/ILIAS/BackgroundTasks/src/Setup/SetupConfig.php @@ -16,9 +16,11 @@ * *********************************************************************/ +namespace ILIAS\BackgroundTasks\Setup; + use ILIAS\Setup\Config; -class ilBackgroundTasksSetupConfig implements Config +class SetupConfig implements Config { public const TYPE_SYNCHRONOUS = "sync"; public const TYPE_ASYNCHRONOUS = "async"; diff --git a/components/ILIAS/BackgroundTasks/src/Task.php b/components/ILIAS/BackgroundTasks/src/Task.php index 25a85583bf0b..0bfbe5a853af 100755 --- a/components/ILIAS/BackgroundTasks/src/Task.php +++ b/components/ILIAS/BackgroundTasks/src/Task.php @@ -31,6 +31,12 @@ * - UserInteraction: A Task in the Bucket, which will need some User-Interaction before * running the task. A User-Interaction is provided as Button in the UserInterface such as * [ Cancel ] or [ Download ] + * + * Components contribute their tasks and values to the bootstrap, see + * {@see \ILIAS\BackgroundTasks\Registry\Registry}. A task or value nobody + * contributed is still built by the {@see \ILIAS\BackgroundTasks\Dependencies\Injector}, + * which only resolves a few services of the legacy container. A task or value + * must therefore be contributed as soon as its constructor takes anything else. */ interface Task { diff --git a/components/ILIAS/BackgroundTasks/tests/Implementation/Tasks/BasicTaskFactoryTest.php b/components/ILIAS/BackgroundTasks/tests/Implementation/Tasks/BasicTaskFactoryTest.php index c1b3828dc002..d04aad3a8be5 100755 --- a/components/ILIAS/BackgroundTasks/tests/Implementation/Tasks/BasicTaskFactoryTest.php +++ b/components/ILIAS/BackgroundTasks/tests/Implementation/Tasks/BasicTaskFactoryTest.php @@ -31,6 +31,7 @@ use ILIAS\DI\Container; use ILIAS\BackgroundTasks\Dependencies\DependencyMap\BaseDependencyMap; use ILIAS\BackgroundTasks\Dependencies\Injector; +use ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry; use PHPUnit\Framework\TestCase; class BasicTaskFactoryTest extends TestCase @@ -39,7 +40,7 @@ public function testBasicFactory(): void { $dic = new Container(); $injector = new Injector($dic, new BaseDependencyMap()); - $taskFactory = new BasicTaskFactory($injector); + $taskFactory = new BasicTaskFactory($injector, new BasicRegistry([], [])); $plusJob = $taskFactory->createTask(PlusJob::class, [1, 2]); $this->assertInstanceOf(\ILIAS\BackgroundTasks\Implementation\Tasks\PlusJob::class, $plusJob); $plusJobInput = $plusJob->getInput(); @@ -56,4 +57,21 @@ public function testBasicFactory(): void $plusJobInput = $plusJob->getInput(); $this->assertTrue($plusJobInput[0]->equals($one)); } + + public function testRegisteredTasksAreClonedFromTheirPrototype(): void + { + $prototype = new PlusJob(); + $injector = new Injector(new Container(), new BaseDependencyMap()); + $taskFactory = new BasicTaskFactory($injector, new BasicRegistry([$prototype], [])); + + $first = $taskFactory->createTask(PlusJob::class, [1, 2]); + $second = $taskFactory->createTask(PlusJob::class, [3, 4]); + + $this->assertNotSame($prototype, $first); + $this->assertNotSame($first, $second); + $this->assertSame([], $prototype->getInput()); + $three = new IntegerValue(); + $three->setValue(3); + $this->assertTrue($second->getInput()[0]->equals($three)); + } } diff --git a/components/ILIAS/BackgroundTasks_/BackgroundTasks_.php b/components/ILIAS/BackgroundTasks_/BackgroundTasks_.php deleted file mode 100644 index 150aa951659a..000000000000 --- a/components/ILIAS/BackgroundTasks_/BackgroundTasks_.php +++ /dev/null @@ -1,42 +0,0 @@ - - new ComponentJS($this, "background_task_refresh.js"); - } -} diff --git a/components/ILIAS/BackgroundTasks_/PRIVACY.md b/components/ILIAS/BackgroundTasks_/PRIVACY.md deleted file mode 100644 index f412506a8943..000000000000 --- a/components/ILIAS/BackgroundTasks_/PRIVACY.md +++ /dev/null @@ -1,8 +0,0 @@ -# BackgroundTasks_ Privacy -Disclaimer: This documentation does not warrant completeness or correctness. Please report any missing or wrong information using the [ILIAS issue tracker](https://mantis.ilias.de) or contribute a fix via [Pull Request](docs/development/contributing.md#pull-request-to-the-repositories). - -## General Information -- Due to the new structure from ILIAS 10 onward, components who formerly had parts of them located in "Services" or "Modules" as well as in "src" will be united in a shared folder on an ongoing basis. -- For the BackgroundTasks component this process is still pending which is why this additional directory named "BackgroundTasks_" exists. -- The code in this "BackgroundTasks_" directory is part of the overall BackgroundTasks component, the relevant privacy aspects of that component are described in the following privacy file: - - [BackgroundTasks Privacy](../BackgroundTasks/PRIVACY.md) diff --git a/components/ILIAS/BackgroundTasks_/ROADMAP.md b/components/ILIAS/BackgroundTasks_/ROADMAP.md deleted file mode 100755 index 71a54058070e..000000000000 --- a/components/ILIAS/BackgroundTasks_/ROADMAP.md +++ /dev/null @@ -1,3 +0,0 @@ -# Roadmap - -see Roadmap of the Service in [src/BackgroundTasks](../../src/BackgroundTasks/ROADMAP.md) diff --git a/components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksDB80.php b/components/ILIAS/BackgroundTasks_/classes/Setup/class.ilBackgroundTasksDB80.php deleted file mode 100755 index e69de29bb2d1..000000000000 diff --git a/components/ILIAS/Container/classes/BackgroundTasks/class.ilDownloadContainerFilesBackgroundTask.php b/components/ILIAS/Container/classes/BackgroundTasks/class.ilDownloadContainerFilesBackgroundTask.php index 0196147d9084..baa5ad27e2c6 100755 --- a/components/ILIAS/Container/classes/BackgroundTasks/class.ilDownloadContainerFilesBackgroundTask.php +++ b/components/ILIAS/Container/classes/BackgroundTasks/class.ilDownloadContainerFilesBackgroundTask.php @@ -19,6 +19,13 @@ use ILIAS\BackgroundTasks\Implementation\Bucket\BasicBucket; use ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\StringValue; use ILIAS\BackgroundTasks\Task\TaskFactory; +use ILIAS\FileServices\Download\CheckSumOfFileSizesJob; +use ILIAS\FileServices\Download\CollectFilesJob; +use ILIAS\FileServices\Download\CopyDefinition; +use ILIAS\FileServices\Download\CopyFilesToTempDirectoryJob; +use ILIAS\FileServices\Download\DownloadZipInteraction; +use ILIAS\FileServices\Download\SumOfFileSizesTooLargeInteraction; +use ILIAS\FileServices\Download\ZipJob; /** * Class ilDownloadContainerFilesBackgroundTask @@ -82,36 +89,30 @@ public function run(): bool $bucket->setUserId($this->user_id); $this->logger->debug('Created bucket and set the following user id: ' . $this->user_id); - // Copy Definition - $definition = new ilCopyDefinition(); + $definition = new CopyDefinition(); $normalized_name = ilFileUtils::getASCIIFilename($this->getBucketTitle()); $definition->setTempDir($normalized_name); $definition->setObjectRefIds($this->object_ref_ids); $this->logger->debug('Created copy definition and added the following tempdir: ' . $normalized_name); - // Collect all files by the definition and prevent duplicates - $collect_job = $this->task_factory->createTask(ilCollectFilesJob::class, [$definition, $this->initiated_by_folder_action]); + $collect_job = $this->task_factory->createTask(CollectFilesJob::class, [$definition, $this->initiated_by_folder_action]); $this->logger->debug('Collected files based on the following object ids: '); $this->logger->dump($this->object_ref_ids); - // Check the FileSize - $file_size_job = $this->task_factory->createTask(ilCheckSumOfFileSizesJob::class, [$collect_job]); + $file_size_job = $this->task_factory->createTask(CheckSumOfFileSizesJob::class, [$collect_job]); - // Show problems with file-limit - $file_size_interaction = $this->task_factory->createTask(ilSumOfFileSizesTooLargeInteraction::class, [$file_size_job]); + $file_size_interaction = $this->task_factory->createTask(SumOfFileSizesTooLargeInteraction::class, [$file_size_job]); $this->logger->debug('Determined the sum of all file sizes'); - // move files from source dir to target directory - $copy_job = $this->task_factory->createTask(ilCopyFilesToTempDirectoryJob::class, [$file_size_interaction]); + $copy_job = $this->task_factory->createTask(CopyFilesToTempDirectoryJob::class, [$file_size_interaction]); - // Zip it - $zip_job = $this->task_factory->createTask(ilZipJob::class, [$copy_job]); + $zip_job = $this->task_factory->createTask(ZipJob::class, [$copy_job]); $this->logger->debug('Moved files from source- to target-directory'); // Download $download_name = new StringValue(); $download_name->setValue($normalized_name . '.zip'); - $download_interaction = $this->task_factory->createTask(ilDownloadZipInteraction::class, [$zip_job, $download_name]); + $download_interaction = $this->task_factory->createTask(DownloadZipInteraction::class, [$zip_job, $download_name]); $this->logger->debug('Created a download interaction with the following download name: ' . $download_name->getValue()); // last task to bucket diff --git a/components/ILIAS/File/File.php b/components/ILIAS/File/File.php index e04c9d967608..22a4bb58fc58 100644 --- a/components/ILIAS/File/File.php +++ b/components/ILIAS/File/File.php @@ -39,6 +39,9 @@ use ILIAS\File\Activities\ListFiles; use ILIAS\File\Activities\ReplaceFileContent; use ILIAS\File\Activities\RepositoryProvider; +use ILIAS\FileServices\Download\DownloadLimit; +use ILIAS\components\File\Settings\General; +use ILIAS\Database\Connection; use ILIAS\FileDelivery\Activities\FilePayloadFactory; use ILIAS\ResourceStorage\Activities\DeliverResource; use ILIAS\ResourceStorage\Activities\ServiceProvider as StorageProvider; @@ -61,6 +64,11 @@ public function init( array | \ArrayAccess &$pull, array | \ArrayAccess &$internal, ): void { + $implement[DownloadLimit::class] = static fn() => + new General( + $pull[Connection::class] + ); + $contribute[Agent::class] = static fn() => new \ilFileObjectAgent( $pull[Factory::class] diff --git a/components/ILIAS/File/classes/Settings/General.php b/components/ILIAS/File/classes/Settings/General.php index db8d04aac866..e7ec88aadd99 100755 --- a/components/ILIAS/File/classes/Settings/General.php +++ b/components/ILIAS/File/classes/Settings/General.php @@ -18,10 +18,12 @@ namespace ILIAS\components\File\Settings; +use ILIAS\FileServices\Download\DownloadLimit; + /** * @author Fabian Schmid */ -class General +class General implements DownloadLimit { public const MODULE_NAME = 'file_access'; public const F_BG_LIMIT = 'bg_limit'; diff --git a/components/ILIAS/FileServices/FileServices.php b/components/ILIAS/FileServices/FileServices.php index 5bf12a54f30d..8c2ce122b25c 100644 --- a/components/ILIAS/FileServices/FileServices.php +++ b/components/ILIAS/FileServices/FileServices.php @@ -33,6 +33,15 @@ use ILIAS\FileServices\Policy\UploadRestrictionBypassLegacyProxy; use ILIAS\Language\ComponentTranslation\LanguageFileDirectory; use ILIAS\Language\ComponentTranslation\ComponentLanguageFileDirectory; +use ILIAS\BackgroundTasks\Task; +use ILIAS\BackgroundTasks\Value; +use ILIAS\Filesystem\FileSystems\FilesystemTemp; +use ILIAS\Filesystem\Util\Archive\Archives; +use ILIAS\Language\Language; +use ILIAS\Logging\Logger\LoggerFactoryInterface; +use ILIAS\FileServices\Download; +use ILIAS\FileServices\Legacy\RepositoryTreeProxy; +use ILIAS\AccessControl\PublicInterface\Access; class FileServices implements Component { @@ -47,6 +56,7 @@ public function init( array|\ArrayAccess &$internal, ): void { $define[] = UploadRestrictionBypass::class; + $define[] = Download\DownloadLimit::class; $implement[UploadRestrictionBypass::class] = static fn() => new UploadRestrictionBypassLegacyProxy(); $implement[PhpUploadLimit::class] = static fn() => new FileServicesLegacyInitialisationAdapter( @@ -64,5 +74,74 @@ public function init( $this, 'fils' ); + + $contribute[Value::class] = static fn() => new Download\CopyDefinition(); + $contribute[Task::class] = static fn() => + new Download\CollectFilesJob( + $use[LoggerFactoryInterface::class]->getLazy('cal'), + $use[Access::class], + $internal[RepositoryTreeProxy::class] + ); + $contribute[Task::class] = static fn() => + new Download\CheckSumOfFileSizesJob( + $use[LoggerFactoryInterface::class]->getLazy('cal'), + $use[Access::class], + $internal[RepositoryTreeProxy::class], + $use[Download\DownloadLimit::class] + ); + $contribute[Task::class] = static fn() => + new Download\CopyFilesToTempDirectoryJob( + $use[LoggerFactoryInterface::class]->getLazy('cal') + ); + $contribute[Task::class] = static fn() => + new Download\ZipJob( + $use[LoggerFactoryInterface::class]->getLazy('cal'), + new Archives() + ); + $contribute[Task::class] = static fn() => + new Download\DownloadZipInteraction( + $use[LoggerFactoryInterface::class]->getLazy('cal'), + $use[FilesystemTemp::class] + ); + $contribute[Task::class] = static fn() => + new Download\SumOfFileSizesTooLargeInteraction( + $use[Language::class] + ); + + // names of buckets created before ILIAS 12, remove with ILIAS 13 + $contribute[Value::class] = static fn() => new \ilCopyDefinition(); + $contribute[Task::class] = static fn() => + new \ilCollectFilesJob( + $use[LoggerFactoryInterface::class]->getLazy('cal'), + $use[Access::class], + $internal[RepositoryTreeProxy::class] + ); + $contribute[Task::class] = static fn() => + new \ilCheckSumOfFileSizesJob( + $use[LoggerFactoryInterface::class]->getLazy('cal'), + $use[Access::class], + $internal[RepositoryTreeProxy::class], + $use[Download\DownloadLimit::class] + ); + $contribute[Task::class] = static fn() => + new \ilCopyFilesToTempDirectoryJob( + $use[LoggerFactoryInterface::class]->getLazy('cal') + ); + $contribute[Task::class] = static fn() => + new \ilZipJob( + $use[LoggerFactoryInterface::class]->getLazy('cal'), + new Archives() + ); + $contribute[Task::class] = static fn() => + new \ilDownloadZipInteraction( + $use[LoggerFactoryInterface::class]->getLazy('cal'), + $use[FilesystemTemp::class] + ); + $contribute[Task::class] = static fn() => + new \ilSumOfFileSizesTooLargeInteraction( + $use[Language::class] + ); + + $internal[RepositoryTreeProxy::class] = static fn() => new RepositoryTreeProxy(); } } diff --git a/components/ILIAS/FileServices/classes/Download/class.ilCheckSumOfFileSizesJob.php b/components/ILIAS/FileServices/classes/Download/class.ilCheckSumOfFileSizesJob.php new file mode 100644 index 000000000000..a30758dc3a33 --- /dev/null +++ b/components/ILIAS/FileServices/classes/Download/class.ilCheckSumOfFileSizesJob.php @@ -0,0 +1,29 @@ + - * - */ -class ilCheckSumOfFileSizesJob extends AbstractJob +class CheckSumOfFileSizesJob extends AbstractJob { - private readonly ?ilLogger $logger; - protected \ilSetting $settings; - - - /** - * Construct - */ - public function __construct() - { - global $DIC; - $this->logger = $DIC->logger()->cal(); - $this->settings = new ilSetting("fold"); + public function __construct( + private readonly LoggerInterface $logger, + private readonly Access $access, + private readonly RepositoryTreeProxy $tree, + private readonly DownloadLimit $download_limit + ) { } @@ -54,7 +46,7 @@ public function getInputTypes(): array { return [ - new SingleType(ilCopyDefinition::class), + new SingleType(CopyDefinition::class), ]; } @@ -64,7 +56,7 @@ public function getInputTypes(): array */ public function getOutputType(): Type { - return new SingleType(ilCopyDefinition::class); + return new SingleType(CopyDefinition::class); } @@ -88,11 +80,8 @@ public function run(array $input, Observer $observer): Value $definition = $input[0]; $object_ref_ids = $definition->getObjectRefIds(); - global $DIC; - // get global limit (max sum of individual file-sizes) from file settings - $general = new General($DIC->database()); - $size_limit = $general->getDownloadLimitinMB(); + $size_limit = $this->download_limit->getDownloadLimitinMB(); $size_limit_bytes = $size_limit * 1024 * 1024; $this->logger->debug('Global limit (max sum of all file-sizes) in file-settings: ' . $size_limit_bytes . ' bytes'); // get sum of individual file-sizes @@ -119,20 +108,16 @@ public function run(array $input, Observer $observer): Value */ protected function calculateRecursive(array $a_ref_ids, int &$a_file_size): void { - global $DIC; - $tree = $DIC['tree']; - // parse folders foreach ($a_ref_ids as $ref_id) { if (!$this->validateAccess($ref_id)) { continue; } - // we are only interested in folders and files - switch (ilObject::_lookupType($ref_id, true)) { + switch (\ilObject::_lookupType($ref_id, true)) { case "fold": // get child objects - $subtree = $tree->getChildsByTypeFilter($ref_id, ["fold", "file"]); + $subtree = $this->tree->getChildsByTypeFilter($ref_id, ["fold", "file"]); if (count($subtree) > 0) { $child_ref_ids = []; foreach ($subtree as $child) { @@ -143,7 +128,7 @@ protected function calculateRecursive(array $a_ref_ids, int &$a_file_size): void break; case "file": - $a_file_size += ilObjFileAccess::_lookupFileSize($ref_id); + $a_file_size += \ilObjFileAccess::_lookupFileSize($ref_id); break; } } @@ -157,13 +142,10 @@ protected function calculateRecursive(array $a_ref_ids, int &$a_file_size): void */ protected function validateAccess(int $ref_id): bool { - global $DIC; - $ilAccess = $DIC['ilAccess']; - - if (!$ilAccess->checkAccess("read", "", $ref_id)) { + if (!$this->access->checkAccess("read", "", $ref_id)) { return false; } - return !ilObject::_isInTrash($ref_id); + return !\ilObject::_isInTrash($ref_id); } diff --git a/components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilCollectFilesJob.php b/components/ILIAS/FileServices/src/Download/CollectFilesJob.php similarity index 81% rename from components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilCollectFilesJob.php rename to components/ILIAS/FileServices/src/Download/CollectFilesJob.php index ab4901c8a11e..1699f9f1445a 100755 --- a/components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilCollectFilesJob.php +++ b/components/ILIAS/FileServices/src/Download/CollectFilesJob.php @@ -16,38 +16,32 @@ * *********************************************************************/ +namespace ILIAS\FileServices\Download; + use ILIAS\BackgroundTasks\Observer; use ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob; use ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\BooleanValue; use ILIAS\BackgroundTasks\Types\SingleType; use ILIAS\BackgroundTasks\Types\Type; use ILIAS\BackgroundTasks\Value; +use ILIAS\AccessControl\PublicInterface\Access; +use ILIAS\FileServices\Legacy\RepositoryTreeProxy; +use ILIAS\Logging\Logger\LoggerInterface; -/** - * Description of class class - * - * @author Lukas Zehnder - * - */ -class ilCollectFilesJob extends AbstractJob +class CollectFilesJob extends AbstractJob { - use ilObjFileSecureString; + use \ilObjFileSecureString; - private ?ilLogger $logger; /** - * Holds the target mapped to the number of duplicates. - * @see ilCollectFilesJob::getFileDirs() * @var array */ - private static array $targets = []; + private static array $duplicate_count_by_target = []; - /** - * Construct - */ - public function __construct() - { - global $DIC; - $this->logger = $DIC->logger()->cal(); + public function __construct( + private readonly LoggerInterface $logger, + private readonly Access $access, + private readonly RepositoryTreeProxy $tree + ) { } @@ -58,7 +52,7 @@ public function getInputTypes(): array { return [ - new SingleType(ilCopyDefinition::class), + new SingleType(CopyDefinition::class), new SingleType(BooleanValue::class), ]; } @@ -69,7 +63,7 @@ public function getInputTypes(): array */ public function getOutputType(): Type { - return new SingleType(ilCopyDefinition::class); + return new SingleType(CopyDefinition::class); } @@ -96,8 +90,8 @@ public function run(array $input, Observer $observer): Value $files = []; foreach ($object_ref_ids as $object_ref_id) { - $object = ilObjectFactory::getInstanceByRefId($object_ref_id); - if (!$object instanceof ilObject) { + $object = \ilObjectFactory::getInstanceByRefId($object_ref_id); + if (!$object instanceof \ilObject) { continue; } @@ -158,12 +152,8 @@ public function run(array $input, Observer $observer): Value */ private function getFileDirs($a_ref_id, string $a_file_name, string $a_temp_dir): false|array { - global $DIC; - - $user = $DIC->user(); - $ilAccess = $DIC->access(); - if ($ilAccess->checkAccessOfUser($user->getId(), "read", "", $a_ref_id)) { - $file = new ilObjFile($a_ref_id); + if ($this->access->checkAccess("read", "", $a_ref_id)) { + $file = new \ilObjFile($a_ref_id); $source_dir = $file->getFile(); if (@!is_file($source_dir)) { @@ -175,7 +165,7 @@ private function getFileDirs($a_ref_id, string $a_file_name, string $a_temp_dir) // invalid on Windows and prevent the archive from being extracted. They are // sanitized the same way as the folder names in recurseFolder(). $filname_with_suffix = $this->ensureSuffix( - ilFileUtils::getASCIIFilename($a_file_name), + \ilFileUtils::getASCIIFilename($a_file_name), $file->getFileExtension() ); @@ -184,16 +174,16 @@ private function getFileDirs($a_ref_id, string $a_file_name, string $a_temp_dir) // #25025: allow duplicate filenames by appending an incrementing // number per duplicate in brackets to the name. // Example: test.txt, test (1).txt, test (2).txt, ... - if (isset(self::$targets[$target_dir])) { + if (isset(self::$duplicate_count_by_target[$target_dir])) { $target_info = pathinfo($target_dir); $filename = $target_info["filename"]; $extension = isset($target_info["extension"]) ? "." . $target_info["extension"] : ""; // pathinfo() returns the name without its directory, therefore the separator // has to be added again, just like above $target_dir = $a_temp_dir . '/' . $filename - . " (" . ++self::$targets[$target_dir] . ")" . $extension; + . " (" . ++self::$duplicate_count_by_target[$target_dir] . ")" . $extension; } else { - self::$targets[$target_dir] = 0; + self::$duplicate_count_by_target[$target_dir] = 0; } return [ @@ -215,11 +205,7 @@ private function getFileDirs($a_ref_id, string $a_file_name, string $a_temp_dir) */ private function recurseFolder($a_ref_id, string $a_folder_name, string $a_temp_dir, int|float $a_num_recursions, $a_initiated_by_folder_action): array { - global $DIC; - $num_recursions = $a_num_recursions + 1; - $tree = $DIC->repositoryTree(); - $ilAccess = $DIC->access(); $files = []; // Avoid the duplication of the uppermost folder when the download is initiated via a folder's action drop-down @@ -227,16 +213,16 @@ private function recurseFolder($a_ref_id, string $a_folder_name, string $a_temp_ if ($num_recursions <= 1 && $a_initiated_by_folder_action) { $temp_dir = $a_temp_dir; } else { - $temp_dir = $a_temp_dir . '/' . ilFileUtils::getASCIIFilename($a_folder_name); + $temp_dir = $a_temp_dir . '/' . \ilFileUtils::getASCIIFilename($a_folder_name); } - $subtree = $tree->getChildsByTypeFilter($a_ref_id, ["fold", "file"]); + $subtree = $this->tree->getChildsByTypeFilter($a_ref_id, ["fold", "file"]); foreach ($subtree as $child) { - if (!$ilAccess->checkAccess("read", "", $child["ref_id"])) { + if (!$this->access->checkAccess("read", "", $child["ref_id"])) { continue; } - if (ilObject::_isInTrash($child["ref_id"])) { + if (\ilObject::_isInTrash($child["ref_id"])) { continue; } if ($child["type"] == "fold") { diff --git a/components/ILIAS/BackgroundTasks_/classes/class.ilCopyDefinition.php b/components/ILIAS/FileServices/src/Download/CopyDefinition.php similarity index 97% rename from components/ILIAS/BackgroundTasks_/classes/class.ilCopyDefinition.php rename to components/ILIAS/FileServices/src/Download/CopyDefinition.php index 832ec09e79d5..6fd9a8ecfc33 100755 --- a/components/ILIAS/BackgroundTasks_/classes/class.ilCopyDefinition.php +++ b/components/ILIAS/FileServices/src/Download/CopyDefinition.php @@ -16,15 +16,13 @@ * *********************************************************************/ +namespace ILIAS\FileServices\Download; + use ILIAS\BackgroundTasks\Implementation\Values\AbstractValue; use ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\BooleanValue; use ILIAS\BackgroundTasks\Value; -/** - * Description of class class - * @author Stefan Meyer - */ -class ilCopyDefinition extends AbstractValue +class CopyDefinition extends AbstractValue { public const COPY_SOURCE_DIR = 'source'; public const COPY_TARGET_DIR = 'target'; diff --git a/components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilCopyFilesToTempDirectoryJob.php b/components/ILIAS/FileServices/src/Download/CopyFilesToTempDirectoryJob.php similarity index 84% rename from components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilCopyFilesToTempDirectoryJob.php rename to components/ILIAS/FileServices/src/Download/CopyFilesToTempDirectoryJob.php index d2b22fca2c0e..2f86570c81e0 100755 --- a/components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilCopyFilesToTempDirectoryJob.php +++ b/components/ILIAS/FileServices/src/Download/CopyFilesToTempDirectoryJob.php @@ -16,32 +16,23 @@ * *********************************************************************/ +namespace ILIAS\FileServices\Download; + use ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob; use ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\StringValue; use ILIAS\BackgroundTasks\Observer; use ILIAS\BackgroundTasks\Types\SingleType; use ILIAS\BackgroundTasks\Types\Type; use ILIAS\BackgroundTasks\Value; +use ILIAS\Logging\Logger\LoggerInterface; -/** - * Description of class class - * - * @author Stefan Meyer - * - */ -class ilCopyFilesToTempDirectoryJob extends AbstractJob +class CopyFilesToTempDirectoryJob extends AbstractJob { - private ?ilLogger $logger; protected string $target_directory = ''; - - /** - * Constructor - */ - public function __construct() - { - global $DIC; - $this->logger = $DIC->logger()->cal(); + public function __construct( + private readonly LoggerInterface $logger + ) { } @@ -52,7 +43,7 @@ public function getInputTypes(): array { return [ - new SingleType(ilCopyDefinition::class), + new SingleType(CopyDefinition::class), ]; } @@ -111,8 +102,8 @@ public function run(array $input, Observer $observer): Value */ protected function createUniqueTempDirectory(): string { - $tmpdir = ilFileUtils::ilTempnam(); - ilFileUtils::makeDirParents($tmpdir); + $tmpdir = \ilFileUtils::ilTempnam(); + \ilFileUtils::makeDirParents($tmpdir); $this->logger->info('New temp directory: ' . $tmpdir); return $tmpdir; @@ -122,27 +113,24 @@ protected function createUniqueTempDirectory(): string protected function createTargetDirectory(string $a_tmpdir): string { $final_dir = $a_tmpdir . "/" . $this->target_directory; - ilFileUtils::makeDirParents($final_dir); + \ilFileUtils::makeDirParents($final_dir); $this->logger->info('New final directory: ' . $final_dir); return $final_dir; } - /** - * Copy files - */ - protected function copyFiles(string $tmpdir, ilCopyDefinition $definition): void + protected function copyFiles(string $tmpdir, CopyDefinition $definition): void { foreach ($definition->getCopyDefinitions() as $copy_task) { - $source_dir_or_file = $copy_task[ilCopyDefinition::COPY_SOURCE_DIR]; - $target_dir_or_file = $copy_task[ilCopyDefinition::COPY_TARGET_DIR]; + $source_dir_or_file = $copy_task[CopyDefinition::COPY_SOURCE_DIR]; + $target_dir_or_file = $copy_task[CopyDefinition::COPY_TARGET_DIR]; $absolute_path_of_target_dir_or_file = $tmpdir . '/' . $target_dir_or_file; $absolute_directory_of_target_dir_or_file = $tmpdir . '/' . dirname($target_dir_or_file); $this->logger->debug('Creating directory: ' . $tmpdir . '/' . dirname($target_dir_or_file)); - ilFileUtils::makeDirParents( + \ilFileUtils::makeDirParents( $absolute_directory_of_target_dir_or_file ); diff --git a/components/ILIAS/FileServices/src/Download/DownloadLimit.php b/components/ILIAS/FileServices/src/Download/DownloadLimit.php new file mode 100644 index 000000000000..255a0409ab17 --- /dev/null +++ b/components/ILIAS/FileServices/src/Download/DownloadLimit.php @@ -0,0 +1,29 @@ + - * - */ -class ilDownloadZipInteraction extends AbstractUserInteraction +class DownloadZipInteraction extends AbstractUserInteraction { public const OPTION_DOWNLOAD = 'download'; public const OPTION_CANCEL = 'cancel'; - private ?ilLogger $logger; - - public function __construct() - { - global $DIC; - $this->logger = $DIC->logger()->cal(); + public function __construct( + private readonly LoggerInterface $logger, + private readonly FilesystemTemp $temp_filesystem + ) { } @@ -94,7 +90,6 @@ public function getOptions(array $input): array */ public function interaction(array $input, Option $user_selected_option, Bucket $bucket): Value { - global $DIC; $zip_name = $input[1]; $download_name = $input[0]; @@ -104,11 +99,11 @@ public function interaction(array $input, Option $user_selected_option, Bucket $ if ($user_selected_option->getValue() !== self::OPTION_DOWNLOAD) { $this->logger->info('Download canceled'); // delete zip file - $filesystem = $DIC->filesystem()->temp(); + $filesystem = $this->temp_filesystem; try { $path = LegacyPathHelper::createRelativePath($zip_name->getValue()); - } catch (InvalidArgumentException) { + } catch (\InvalidArgumentException) { $path = null; } if (!is_null($path) && $filesystem->has($path)) { @@ -120,7 +115,7 @@ public function interaction(array $input, Option $user_selected_option, Bucket $ $this->logger->info("Delivering File."); - ilFileDelivery::deliverFileAttached($download_name->getValue(), $zip_name->getValue()); + \ilFileDelivery::deliverFileAttached($download_name->getValue(), $zip_name->getValue()); return new ThunkValue(); } diff --git a/components/ILIAS/BackgroundTasks_/classes/UserInteractions/class.ilSumOfFileSizesTooLargeInteraction.php b/components/ILIAS/FileServices/src/Download/SumOfFileSizesTooLargeInteraction.php similarity index 84% rename from components/ILIAS/BackgroundTasks_/classes/UserInteractions/class.ilSumOfFileSizesTooLargeInteraction.php rename to components/ILIAS/FileServices/src/Download/SumOfFileSizesTooLargeInteraction.php index 5ceb63d8a038..33c692e9cb8c 100755 --- a/components/ILIAS/BackgroundTasks_/classes/UserInteractions/class.ilSumOfFileSizesTooLargeInteraction.php +++ b/components/ILIAS/FileServices/src/Download/SumOfFileSizesTooLargeInteraction.php @@ -16,6 +16,8 @@ * *********************************************************************/ +namespace ILIAS\FileServices\Download; + use ILIAS\BackgroundTasks\Bucket; use ILIAS\BackgroundTasks\Implementation\Tasks\AbstractUserInteraction; use ILIAS\BackgroundTasks\Implementation\Tasks\UserInteraction\UserInteractionOption; @@ -23,26 +25,18 @@ use ILIAS\BackgroundTasks\Types\SingleType; use ILIAS\BackgroundTasks\Types\Type; use ILIAS\BackgroundTasks\Value; +use ILIAS\Language\Language; -/** - * Class ilSumOfFileSizesTooLargeInteraction - * @author Lukas Zehnder - * @author Fabian Schmid - */ -class ilSumOfFileSizesTooLargeInteraction extends AbstractUserInteraction +class SumOfFileSizesTooLargeInteraction extends AbstractUserInteraction { /** * @var string */ private const OPTION_OK = 'ok'; - protected ilLanguage $lng; - - public function __construct() - { - global $DIC; - $this->lng = $DIC->language(); - $this->lng->loadLanguageModule('background_tasks'); + public function __construct( + protected readonly Language $lng + ) { } /** @@ -51,13 +45,13 @@ public function __construct() public function getInputTypes(): array { return [ - new SingleType(ilCopyDefinition::class), + new SingleType(CopyDefinition::class), ]; } public function getOutputType(): Type { - return new SingleType(ilCopyDefinition::class); + return new SingleType(CopyDefinition::class); } #[\Override] @@ -87,6 +81,7 @@ public function getOptions(array $input): array #[\Override] public function getMessage(array $input): string { + $this->lng->loadLanguageModule('background_tasks'); return $this->lng->txt('ui_msg_files_violate_maxsize'); } diff --git a/components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilZipJob.php b/components/ILIAS/FileServices/src/Download/ZipJob.php similarity index 83% rename from components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilZipJob.php rename to components/ILIAS/FileServices/src/Download/ZipJob.php index 6d78dc33efd1..905ed2b0e205 100755 --- a/components/ILIAS/BackgroundTasks_/classes/Jobs/class.ilZipJob.php +++ b/components/ILIAS/FileServices/src/Download/ZipJob.php @@ -16,6 +16,8 @@ * *********************************************************************/ +namespace ILIAS\FileServices\Download; + use ILIAS\Filesystem\Util\Archive\Archives; use ILIAS\BackgroundTasks\Observer; use ILIAS\BackgroundTasks\Implementation\Tasks\AbstractJob; @@ -23,26 +25,14 @@ use ILIAS\BackgroundTasks\Types\SingleType; use ILIAS\BackgroundTasks\Types\Type; use ILIAS\BackgroundTasks\Value; +use ILIAS\Logging\Logger\LoggerInterface; -/** - * Description of class class - * - * @author Stefan Meyer - * - */ -class ilZipJob extends AbstractJob +class ZipJob extends AbstractJob { - private ?ilLogger $logger; - private Archives $archives; - - /** - * Construct - */ - public function __construct() - { - global $DIC; - $this->logger = $DIC->logger()->cal(); - $this->archives = $DIC->archives(); + public function __construct( + private readonly LoggerInterface $logger, + private readonly Archives $archives + ) { } @@ -94,8 +84,7 @@ public function run(array $input, Observer $observer): Value $zip_stream = $zip->get(); stream_copy_to_stream($zip_stream->detach(), fopen($zip_name, 'wb')); // we currently have to write to disk - // delete temp directory - ilFileUtils::delDir($tmpdir); + \ilFileUtils::delDir($tmpdir); $zip_file_name = new StringValue(); $zip_file_name->setValue($zip_name); diff --git a/components/ILIAS/FileServices/src/Legacy/RepositoryTreeProxy.php b/components/ILIAS/FileServices/src/Legacy/RepositoryTreeProxy.php new file mode 100644 index 000000000000..d6135d640a85 --- /dev/null +++ b/components/ILIAS/FileServices/src/Legacy/RepositoryTreeProxy.php @@ -0,0 +1,44 @@ +> + */ + public function getChildsByTypeFilter(int $ref_id, array $types): array + { + return $this->tree()->getChildsByTypeFilter($ref_id, $types); + } + + private function tree(): \ilTree + { + global $DIC; + return $DIC->repositoryTree(); + } +} diff --git a/components/ILIAS/Folder/classes/class.ilObjFolderGUI.php b/components/ILIAS/Folder/classes/class.ilObjFolderGUI.php index ccae1487dd52..f070af859284 100755 --- a/components/ILIAS/Folder/classes/class.ilObjFolderGUI.php +++ b/components/ILIAS/Folder/classes/class.ilObjFolderGUI.php @@ -31,7 +31,7 @@ * @ilCtrl_Calls ilObjFolderGUI: ilInfoScreenGUI, ilContainerPageGUI, ilColumnGUI * @ilCtrl_Calls ilObjFolderGUI: ilObjectCopyGUI, ilObjectContentStyleSettingsGUI * @ilCtrl_Calls ilObjFolderGUI: ilExportGUI, ilCommonActionDispatcherGUI, ilDidacticTemplateGUI - * @ilCtrl_Calls ilObjFolderGUI: ilBackgroundTaskHub, ILIAS\ILIASObject\Properties\Translations\TranslationGUI, ilRepositoryTrashGUI + * @ilCtrl_Calls ilObjFolderGUI: ILIAS\ILIASObject\Properties\Translations\TranslationGUI, ilRepositoryTrashGUI */ class ilObjFolderGUI extends ilContainerGUI { diff --git a/components/ILIAS/Init/Init.php b/components/ILIAS/Init/Init.php index a59c26a87541..088aea09be09 100644 --- a/components/ILIAS/Init/Init.php +++ b/components/ILIAS/Init/Init.php @@ -187,6 +187,7 @@ public function init( $pull[\ILIAS\Language\Activities\AddLanguageEntry::class], $pull[\ILIAS\Language\Activities\SetLanguageDetectionEnabled::class], $pull[\ILIAS\Language\Activities\SetLanguageTranslationEnabled::class], + $use[\ILIAS\BackgroundTasks\Registry\Registry::class] ); $contribute[LanguageFileDirectory::class] = fn() => new ComponentLanguageFileDirectory( $this, diff --git a/components/ILIAS/Init/classes/class.ilInitialisation.php b/components/ILIAS/Init/classes/class.ilInitialisation.php index 73fbb819f093..a6c67d3d6704 100755 --- a/components/ILIAS/Init/classes/class.ilInitialisation.php +++ b/components/ILIAS/Init/classes/class.ilInitialisation.php @@ -1706,8 +1706,18 @@ private static function initBackgroundTasks(\ILIAS\DI\Container $c): void $n_of_tasks = $n_of_tasks ?: 5; $sync = $sync ?: 'sync'; // The default value is sync. + // populated by AllModernComponents, empty for scripts calling initILIAS() directly + if (!isset($c[\ILIAS\BackgroundTasks\Registry\Registry::class])) { + $c[\ILIAS\BackgroundTasks\Registry\Registry::class] = function ($c) { + return new \ILIAS\BackgroundTasks\Implementation\Registry\BasicRegistry([], []); + }; + } + $c["bt.task_factory"] = function ($c) { - return new \ILIAS\BackgroundTasks\Implementation\Tasks\BasicTaskFactory($c["di.injector"]); + return new \ILIAS\BackgroundTasks\Implementation\Tasks\BasicTaskFactory( + $c["di.injector"], + $c[\ILIAS\BackgroundTasks\Registry\Registry::class] + ); }; $c["bt.persistence"] = function ($c) { diff --git a/components/ILIAS/Init/src/AllModernComponents.php b/components/ILIAS/Init/src/AllModernComponents.php index 158758f0764f..820d0a32ea5f 100644 --- a/components/ILIAS/Init/src/AllModernComponents.php +++ b/components/ILIAS/Init/src/AllModernComponents.php @@ -21,6 +21,7 @@ namespace ILIAS\Init; use ILIAS\KeyValueStorage\Services as KeyValueStorage; +use ILIAS\BackgroundTasks\Registry\Registry as BackgroundTasksRegistry; use ILIAS\WebDAV\Environment; use ILIAS\HTTP\GlobalHttpState; use ILIAS\FileDelivery\FileDeliveryServices; @@ -157,6 +158,7 @@ public function __construct( protected \ILIAS\Language\Activities\AddLanguageEntry $add_language_entry, protected \ILIAS\Language\Activities\SetLanguageDetectionEnabled $set_language_detection_enabled, protected \ILIAS\Language\Activities\SetLanguageTranslationEnabled $set_language_translation_enabled, + protected BackgroundTasksRegistry $background_tasks_registry ) { } @@ -279,6 +281,7 @@ protected function populateComponentsInLegacyEnvironment(\ILIAS\DI\Container $DI $DIC[\ILIAS\Language\Activities\AddLanguageEntry::class] = fn(): \ILIAS\Language\Activities\AddLanguageEntry => $this->add_language_entry; $DIC[\ILIAS\Language\Activities\SetLanguageDetectionEnabled::class] = fn(): \ILIAS\Language\Activities\SetLanguageDetectionEnabled => $this->set_language_detection_enabled; $DIC[\ILIAS\Language\Activities\SetLanguageTranslationEnabled::class] = fn(): \ILIAS\Language\Activities\SetLanguageTranslationEnabled => $this->set_language_translation_enabled; + $DIC[BackgroundTasksRegistry::class] = fn(): BackgroundTasksRegistry => $this->background_tasks_registry; } public function getName(): string diff --git a/components/ILIAS/ResourceStorage/IRSS_STORAGE_AUDIT.md b/components/ILIAS/ResourceStorage/IRSS_STORAGE_AUDIT.md index f4d8c4aab330..1de6a06ffe61 100644 --- a/components/ILIAS/ResourceStorage/IRSS_STORAGE_AUDIT.md +++ b/components/ILIAS/ResourceStorage/IRSS_STORAGE_AUDIT.md @@ -122,7 +122,7 @@ followed by a domain-grouped read of every component with a file-storage signal. | soap | protocol/adapter layer (+ third-party nuSOAP) | | Repository | *provides* the Repository-level IRSS facade (`IRSSWrapper`) | | Group, Excel, Form, RTE | export/temp staging, framework upload plumbing, editor config | -| BackgroundTasks_, Database, Logging, Html, Xml, Init, GlobalScreen, Search, Refinery, UI, UICore, UIComponent | infra/temp/cache/asset/read-only | +| BackgroundTasks, Database, Logging, Html, Xml, Init, GlobalScreen, Search, Refinery, UI, UICore, UIComponent | infra/temp/cache/asset/read-only | | Migration | DB-update helper, never touches fs | ### INFRA (the storage stack itself) diff --git a/components/ILIAS/WorkspaceFolder/BackgroundTask/classes/class.ilDownloadWorkspaceFolderBackgroundTask.php b/components/ILIAS/WorkspaceFolder/BackgroundTask/classes/class.ilDownloadWorkspaceFolderBackgroundTask.php index 234b9300c18a..8a1299c540b7 100755 --- a/components/ILIAS/WorkspaceFolder/BackgroundTask/classes/class.ilDownloadWorkspaceFolderBackgroundTask.php +++ b/components/ILIAS/WorkspaceFolder/BackgroundTask/classes/class.ilDownloadWorkspaceFolderBackgroundTask.php @@ -18,6 +18,8 @@ use ILIAS\BackgroundTasks\Implementation\Bucket\BasicBucket; use ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\StringValue; +use ILIAS\FileServices\Download\DownloadZipInteraction; +use ILIAS\FileServices\Download\ZipJob; /** * Background task for downloads @@ -102,14 +104,13 @@ public function run(): bool // move files from source dir to target directory $copy_job = $this->task_factory->createTask(ilCopyWorkspaceFilesToTempDirectoryJob::class, [$file_size_interaction]); - // Zip it - $zip_job = $this->task_factory->createTask(ilZipJob::class, [$copy_job]); + $zip_job = $this->task_factory->createTask(ZipJob::class, [$copy_job]); $this->logger->debug('Moved files from source- to target-directory'); // Download $download_name = new StringValue(); $download_name->setValue($normalized_name . '.zip'); - $download_interaction = $this->task_factory->createTask(ilDownloadZipInteraction::class, [$zip_job, $download_name]); + $download_interaction = $this->task_factory->createTask(DownloadZipInteraction::class, [$zip_job, $download_name]); $this->logger->debug('Created a download interaction with the following download name: ' . $download_name->getValue()); // last task to bucket diff --git a/components/ILIAS/soap/include/inc.soap_functions.php b/components/ILIAS/soap/include/inc.soap_functions.php index 1eb6de6cba15..c1995cfe6aef 100755 --- a/components/ILIAS/soap/include/inc.soap_functions.php +++ b/components/ILIAS/soap/include/inc.soap_functions.php @@ -676,7 +676,7 @@ public static function copyObject(string $sid, string $copy_settings_xml) */ public static function startBackgroundTaskWorker(string $sid) { - $soa = new ilSoapBackgroundTasksAdministration(); + $soa = new \ILIAS\BackgroundTasks\SOAP\Administration(); return $soa->runAsync($sid); } diff --git a/docs/development/maintenance.md b/docs/development/maintenance.md index 0d54725f5c55..74014fe2594e 100755 --- a/docs/development/maintenance.md +++ b/docs/development/maintenance.md @@ -420,22 +420,6 @@ Components are listed alphabetically by their folder name in `components/ILIAS/` [//]: # (END BackgroundTasks) -[//]: # (BEGIN BackgroundTasks_) - -#### [BackgroundTasks_](https://github.com/ILIAS-eLearning/ILIAS/tree/trunk/components/ILIAS/BackgroundTasks_) - -*Belongs to:* [Background Tasks](https://docu.ilias.de/go/wiki/wpage_4383_1357) - -* Authority to Sign off on Conceptual Changes: [thojou](https://docu.ilias.de/go/usr/103745), [mjansen](https://docu.ilias.de/go/usr/8784) -* Authority to Sign off on Code Changes: [thojou](https://docu.ilias.de/go/usr/103745), [mjansen](https://docu.ilias.de/go/usr/8784) -* Authority to Curate Test Cases: MISSING -* Authority to (De-)Assign Authorities: [thojou (Databay AG)](https://docu.ilias.de/go/usr/103745) -* Assignee for Issues: [thojou](https://docu.ilias.de/go/usr/103745) -* Assignee for Security Reports: [thojou](https://docu.ilias.de/go/usr/103745) - -[//]: # (END BackgroundTasks_) - - [//]: # (BEGIN Badge) #### [Badge](https://github.com/ILIAS-eLearning/ILIAS/tree/trunk/components/ILIAS/Badge)