-
Bug
-
Resolution: Fixed
-
Minor
-
2.5.6, 2.6.3, 2.7
-
MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
-
MOODLE_26_STABLE, MOODLE_27_STABLE
-
MDL-45765-master -
It seems there's a bug (Undefined variable) in the cron when updating calendar subscriptions and that one or all the URL to update are invalid (404 http error code or anything not 200).
To reproduce :
- As a teacher, go in a course calendar and click on the "Manage subscriptions" button
- Add a new calendar import using a "calendar URL". set "Update interval" to "Daily"
- Invalidate the URL you just set, one way or another. I think the easiest way for tests would be to change the value directly in the moodle database (mdl_event_subscriptions). As you are already there, also change the "lastupdated" value so that the update wil be run in the next cron
- Run the cron. Here's a example of what you should see :
...
Updating calendar subscriptions:
... started 13:18:59. Current memory use 33.2Mo.
Updating calendar subscription AME6501 in course 0
PHP Notice: Undefined variable: log in /app/apache2/htdocs/moodlebranche/calendar/lib.php on line 3136
...
NOTE : Be sure there's no other calendar subscription update cause the problem won't appear
I dug the code a bit and found what's wrong :
When a URL is invalid, the calendar_get_icalendar function in calendar/lib.php throws an exception. This exception is catch in calendar_cron function.
Problem is, when one or all the calendars to update have invalid URL then the "$log" variable is undefined on line "mtrace(trim(strip_tags($log)));"
Here's an easy way to fix the problem :
try {
|
$log = calendar_update_subscription_events($sub->id);
|
} catch (moodle_exception $ex) {
|
-
|
+ $log = 'Error when updating calendar subcription';
|
}
|
mtrace(trim(strip_tags($log)));
|
}
|