Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/ILIAS/BackgroundTasks/BackgroundTasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public function init(
array | \ArrayAccess &$pull,
array | \ArrayAccess &$internal,
): void {
$contribute[Agent::class] = static fn(): \ilBackgroundTasksSetupAgent =>
new \ilBackgroundTasksSetupAgent(
$contribute[Agent::class] = static fn(): Agent =>
new \ILIAS\BackgroundTasks\Setup\Agent(
$pull[Factory::class]
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@
*
*********************************************************************/

/** @noRector */
require_once __DIR__ . "/../../../../vendor/composer/vendor/autoload.php";
namespace ILIAS\BackgroundTasks\SOAP;

use ILIAS\BackgroundTasks\Implementation\TaskManager\AsyncTaskManager;
use ilSoapAdministration;

class ilSoapBackgroundTasksAdministration extends ilSoapAdministration
class Administration extends ilSoapAdministration
{
public function __construct(bool $use_nusoap = true)
{
parent::__construct($use_nusoap);
}

/**
* @return bool|soap_fault|SoapFault|null
* @return bool|\soap_fault|\SoapFault|null
*/
public function runAsync(string $sid)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*
*********************************************************************/

use ILIAS\Setup\Agent;
namespace ILIAS\BackgroundTasks\Setup;

use ILIAS\Setup\Agent\HasNoNamedObjective;
use ILIAS\Refinery\Factory;
use ILIAS\Refinery\Transformation;
Expand All @@ -25,78 +26,62 @@
use ILIAS\Setup\Objective\NullObjective;
use ILIAS\Setup\Metrics\Storage;
use ILIAS\Setup\ObjectiveCollection;
use ILIAS\BackgroundTasks\Setup\BackgoundWorkerObjective;
use ILIAS\Setup\ObjectiveConstructor;
use ilBackgroundTasksDBHotfixes10;
use ilDatabaseUpdateStepsExecutedObjective;
use ilDatabaseUpdateStepsMetricsCollectedObjective;

class ilBackgroundTasksSetupAgent implements Agent
class Agent implements \ILIAS\Setup\Agent
{
use HasNoNamedObjective;

public function __construct(protected Factory $refinery)
{
}

/**
* @inheritdoc
*/
public function hasConfig(): bool
{
return true;
}

/**
* @inheritdoc
*/
public function getArrayToConfigTransformation(): Transformation
{
return $this->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())
);
}
Expand All @@ -111,9 +96,6 @@ public function getNamedObjectives(?Config $config = null): array
];
}

/**
* @inheritDoc
*/
public function getMigrations(): array
{
return [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -68,9 +65,6 @@ public function isNotable(): bool
return true;
}

/**
* @return Objective[]
*/
public function getPreconditions(Environment $environment): array
{
return [
Expand All @@ -81,9 +75,6 @@ public function getPreconditions(Environment $environment): array
];
}

/**
* @inheritDoc
*/
public function isApplicable(Environment $environment): bool
{
$ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand All @@ -41,9 +44,6 @@ public function isNotable(): bool
return false;
}

/**
* @return \ilIniFilesLoadedObjective[]
*/
public function getPreconditions(Environment $environment): array
{
return [
Expand All @@ -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.');
}

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/soap/include/inc.soap_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading