TypeError in CidReqListener::generateCourseUrl() when finishing an exercise (Chamilo 2.0) #8990
Unanswered
Tonicopruebas
asked this question in
General
Replies: 2 comments
|
I confirm that the error appears at the end of an exercise in Chamilo 2. The problem occurs because origin can arrive as an array, while generateCourseUrl() expects a text or null. The temporary change consisting of removing the strict declaration of the type avoids the initial error, but can hide the problem and cause another failure later. The safest solution seems to be to normalize and validate origin when receiving the request, maintaining the function with the strict type. Could you confirm if this is a regression of Chamilo 2.0.3 and if there is an official fix or a recommended commit to apply as a backport? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
When a user finishes an exercise or attempts to review the results, an Internal Server Error (500) occurs during the background AJAX requests for 'content_bottom' and 'pre_footer'.
Checking the application logs reveals a strict Type Error in PHP 8. The listener expects a string or null for the $origin argument, but an array is being passed instead.
Error Log:
request.CRITICAL: Uncaught PHP Exception TypeError: "Chamilo\CoreBundle\EventListener\CidReqListener::generateCourseUrl(): Argument #4 ($origin) must be of type ?string, array given, called in src/CoreBundle/EventListener/CidReqListener.php on line 225" at CidReqListener.php line 374
Steps to reproduce:
Temporary Hotfix applied:
Changing line 374 in src/CoreBundle/EventListener/CidReqListener.php from:
private function generateCourseUrl(?Course $course, int $sessionId, int $groupId, ?string $origin): string
To:
private function generateCourseUrl(?Course $course, int $sessionId, int $groupId, $origin = null): string
This bypasses the strict string constraint and allows the array payload to process, fixing the 500 pop-up.
All reactions