Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansenDatabay committed Dec 17, 2024
2 parents 68452c9 + 607085c commit 66f080f
Show file tree
Hide file tree
Showing 39 changed files with 789 additions and 1,912 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use ILIAS\BackgroundTasks\Implementation\Tasks\UserInteraction\UserInteractionRequiredException;
use ILIAS\BackgroundTasks\Implementation\Tasks\UserInteraction\UserInteractionSkippedException;
use ILIAS\BackgroundTasks\Task\UserInteraction;
use ILIAS\Export\ImportStatus\Exception\ilException;

class AsyncTaskManager extends BasicTaskManager
{
Expand All @@ -36,15 +37,23 @@ public function run(Bucket $bucket): void
{
global $DIC;

// check this before saving the bucket state to prevent an orphaned entry with 0%
if (!$DIC->settings()->get('soap_user_administration')) {
$DIC->logger()->bgtk()->warning("SOAP not enabled, fallback to sync version");
$sync_manager = new SyncTaskManager($this->persistence);
$sync_manager->run($bucket);
return;
}

$bucket->setState(State::SCHEDULED);
$bucket->setCurrentTask($bucket->getTask());
$DIC->backgroundTasks()->persistence()->saveBucketAndItsTasks($bucket);

$DIC->logger()->root()->info("[BT] Trying to call webserver");
$DIC->logger()->bgtk()->info("Trying to call webserver");

// Call SOAP-Server
$soap_client = new \ilSoapClient();
$soap_client->setResponseTimeout(1);
$soap_client->setResponseTimeout(0);
$soap_client->enableWSDL(true);
$soap_client->init();
$session_id = session_id();
Expand All @@ -63,12 +72,13 @@ public function run(Bucket $bucket): void
$session_id . '::' . $client_id,
));
} catch (\Throwable $t) {
$DIC->logger()->root()->info("[BT] Calling Webserver failed, fallback to sync version");
$DIC->logger()->bgtk()->warning($t->getMessage());
$DIC->logger()->bgtk()->warning("Calling webserver failed, fallback to sync version");
$sync_manager = new SyncTaskManager($this->persistence);
$sync_manager->run($bucket);
} finally {
$DIC->logger()->root()->info("[BT] Calling webserver successful");
return;
}
$DIC->logger()->bgtk()->info("Calling webserver successful");
}

/**
Expand All @@ -81,13 +91,13 @@ public function runAsync()
$n_of_tasks = $ilIliasIniFile->readVariable("background_tasks", "number_of_concurrent_tasks");
$n_of_tasks = $n_of_tasks ? $n_of_tasks : 5;

$DIC->logger()->root()->info("[BackgroundTask] Starting background job.");
$DIC->logger()->bgtk()->info("Starting background job.");
$persistence = $DIC->backgroundTasks()->persistence();

// TODO search over all clients.
$MAX_PARALLEL_JOBS = $n_of_tasks;
if (count($persistence->getBucketIdsByState(State::RUNNING)) >= $MAX_PARALLEL_JOBS) {
$DIC->logger()->root()->info("[BT] Too many running jobs, worker going down.");
$DIC->logger()->bgtk()->info("Too many running jobs, worker going down.");

return;
}
Expand All @@ -114,14 +124,14 @@ public function runAsync()
$this->persistence->saveBucketAndItsTasks($bucket);
} catch (\Exception $e) {
$persistence->deleteBucket($bucket);
$DIC->logger()->root()->info("[BT] Exception while async computing: "
$DIC->logger()->bgtk()->info("Exception while async computing: "
. $e->getMessage());
$DIC->logger()->root()->info("[BT] Stack Trace: "
$DIC->logger()->bgtk()->info("Stack Trace: "
. $e->getTraceAsString());
}
}

$DIC->logger()->root()->info("[BT] One worker going down because there's nothing left to do.");
$DIC->logger()->bgtk()->info("One worker going down because there's nothing left to do.");

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function __construct(bool $use_nusoap = true)
*/
public function runAsync(string $sid)
{
ignore_user_abort(true);

$this->initAuth($sid);
$this->initIlias();

Expand Down
5 changes: 4 additions & 1 deletion components/ILIAS/Feeds/resources/feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
* News feed script.
* @author Alexander Killing <[email protected]>
*/

require_once '../vendor/composer/vendor/autoload.php';

ilContext::init(ilContext::CONTEXT_RSS);

ilInitialisation::initILIAS();
Expand Down Expand Up @@ -48,4 +51,4 @@
$writer->showFeed();
} elseif ($requested_blog_id > 0) {
ilObjBlog::deliverRSS($requested_blog_id);
}
}
20 changes: 18 additions & 2 deletions components/ILIAS/Feeds/resources/privfeed.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
<?php

/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
/**
* 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
*
*********************************************************************/

/**
* News feed script.
Expand All @@ -9,6 +23,8 @@
* @version $Id$
*/

require_once '../vendor/composer/vendor/autoload.php';

ilContext::init(ilContext::CONTEXT_RSS_AUTH);

ilInitialisation::initILIAS();
Expand Down Expand Up @@ -84,4 +100,4 @@
$blankFeedWriter->addItem($feed_item);
$blankFeedWriter->showFeed();
}
}
}
13 changes: 8 additions & 5 deletions components/ILIAS/File/classes/trait.ilObjFileMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ protected function doCreateMetaData(): void
global $DIC;

// add file size and format to LOM
$DIC->learningObjectMetadata()->manipulate($this->getId(), 0, $this->getType())
->prepareCreateOrUpdate($this->getPathToSize(), (string) $this->getFileSize())
// ->prepareCreateOrUpdate($this->getPathToFirstFormat(), $this->getFileType()) // TIDI thwors exception
->prepareCreateOrUpdate($this->getPathToVersion(), (string) $this->getVersion())
->execute();
$manipulator = $DIC->learningObjectMetadata()
->manipulate($this->getId(), 0, $this->getType())
->prepareCreateOrUpdate($this->getPathToSize(), (string) $this->getFileSize())
->prepareCreateOrUpdate($this->getPathToVersion(), (string) $this->getVersion());
if ($this->getFileType() !== '') {
$manipulator = $manipulator->prepareCreateOrUpdate($this->getPathToFirstFormat(), $this->getFileType());
}
$manipulator->execute();
}

protected function beforeMDUpdateListener(string $a_element): bool
Expand Down
9 changes: 5 additions & 4 deletions components/ILIAS/Form/classes/class.ilDateTimeInputGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ public function checkInput(): bool
public function getInput(): ?string
{
if ($this->valid && $this->getDate() !== null) {
return $this->getDate()->get(
IL_CAL_FKT_DATE,
$this->getDatetimeFormatForInput()
);
// getInput() should return a generic format
$post_format = $this->getShowTime()
? IL_CAL_DATETIME
: IL_CAL_DATE;
return $this->getDate()->get($post_format);
}
return null;
}
Expand Down
Loading

0 comments on commit 66f080f

Please sign in to comment.