Verified Commit 2860a40e authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(registrations) Avoid crash if date format is invalid for some reason

issue #5850
Showing with 6 additions and 1 deletion
+6 -1
......@@ -25,7 +25,12 @@ class RegistrationLastChangeAttribute extends DisplayLDAPAttribute
$value = $this->getValue();
if (!empty($value)) {
list($ldapDate, $author) = explode('|', $value, 2);
$date = LdapGeneralizedTime::fromString($ldapDate);
try {
$date = LdapGeneralizedTime::fromString($ldapDate);
} catch (LdapGeneralizedTimeBadFormatException $e) {
msg_dialog::display(_('Error'), $e->getMessage(), ERROR_DIALOG);
$date = new DateTime();
}
$date->setTimezone(timezone::getDefaultTimeZone());
$value = sprintf(_('%s - by %s'), $date->format('Y-m-d H:i:s'), $author);
}
......
  • SonarQube analysis reported 1 issue

    • :information_source: 1 info

    Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:

    1. :information_source: Complete the task associated to this "TODO" comment. :blue_book:
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment