ILIAS icon indicating copy to clipboard operation
ILIAS copied to clipboard

[BUGXFIX/Refactor] Refactor booking event listener to disable a lot of initialisation without use(?) (Undefined Constant in non web context)

Open PurHur opened this issue 1 year ago • 3 comments

Hello,

there is a somewhat bigger conceptional issue in the whole ILIAS code base. A lot of places are initialising GUI classes in non WEB context e.g. ilContext::init(ilContext::CONTEXT_CRON);

This now always results in errors when the stuff is reached in a CLI or Cron:

Error thrown with message "Undefined constant "ILIAS\Repository\Form\ILIAS_HTTP_PATH""

Stacktrace:
#10 Error in /var/www/ilias/Services/Repository/Service/Form/class.FormAdapterGUI.php:95
#9 ILIAS\Repository\Form\FormAdapterGUI:getOnLoadCode in /var/www/ilias/Services/Repository/Service/Form/class.FormAdapterGUI.php:111
#8 ILIAS\Repository\Form\FormAdapterGUI:initJavascript in /var/www/ilias/Services/Repository/Service/trait.GlobalDICGUIServices.php:50
#7 ILIAS\BookingManager\InternalGUIService:initGUIServices in /var/www/ilias/Modules/BookingManager/Service/class.InternalGUIService.php:43
#6 ILIAS\BookingManager\InternalGUIService:__construct in /var/www/ilias/Modules/BookingManager/Service/class.InternalService.php:49
#5 ILIAS\BookingManager\InternalService:__construct in /var/www/ilias/Modules/BookingManager/Service/class.Service.php:42
#4 ILIAS\BookingManager\Service:internal in /var/www/ilias/Modules/BookingManager/classes/class.ilBookingManagerAppEventListener.php:37
#3 ilBookingManagerAppEventListener:handleEvent in /var/www/ilias/Services/EventHandling/classes/class.ilAppEventHandler.php:143
#2 ilAppEventHandler:raise in /var/www/ilias/Services/User/classes/class.ilObjUser.php:549
#1 ilObjUser:update in /var/www/ilias/DefaultConfig.php:35
#0 changeRootPasword in /var/www/ilias/DefaultConfig.php:17

You cant call the update of an user anymore without setting constants on your own after the core ilias initialisation. There is even a deprecated "fix" in ilCronManagerImpl but the errors are getting more and more.

This is an bigger issue i cant fix so i propose another solution here for my usecase.

I read the code that calls the stuff and found this line of code that initialises a lot of stuff which is only used on delete Events of an user, but was called everytime. So i decided to move that line. Is that something we can do here? I dont think the code has to be called at all.

Greetings Purhur

Mantis Issue: https://mantis.ilias.de/view.php?id=42242

PurHur avatar Oct 07 '24 07:10 PurHur

The issue also occurs in the context of "SCORM" (AJAX requests).

Issue: https://mantis.ilias.de/view.php?id=42276

mjansenDatabay avatar Oct 14 '24 13:10 mjansenDatabay

@alex40724 - spricht etwas gegen die Annahme dieses PR?

nbromberger avatar Oct 15 '24 12:10 nbromberger

Funktioniert der Fix? Wir haben massive Probleme, dass keine Zertifikate sauber ausgestellt werden. Wenn ja, wäre eine Übernahme bitte wichtig. Vielen Dank!

Dennis1993 avatar Oct 18 '24 18:10 Dennis1993

@PurHur If you run into these issues, please write a bug report. Personally I am migrating to a more lazy pattern since some time.

alex40724 avatar Nov 05 '24 16:11 alex40724

Thank you for merging. But i dont think that it has something todo with your code personally. Its splattered all over the whole codebase from different devs \o/ The fix just hides the problem one more time :3

PurHur avatar Nov 05 '24 16:11 PurHur