Menu

#537 $tz_url in functions_ical.inc is undefined if the TZURL: is not found in the database retrieved zoneinfo

Minor
open
nobody
1
2023-02-17
2023-02-16
No

When during generating an ics-report a timezone url is not found in the data base, $tzurl in functions_ical.inc is undefined when used the first time.

Moreover, any error message is saved as report.ics and only on inspecting that file with an editor, the error message can be found. The user otherwise has no idea that the report failed.

Backtrace starts like this:

E_NOTICE in /....../mrbs-1.11.0/functions_ical.inc at line 74
Undefined variable: tz_url
#0 MRBS\generate_backtrace() called at [/....../mrbs-1.11.0/functions_error.inc:221]
#1 MRBS\output_error() called at [/....../mrbs-1.11.0/functions_error.inc:251]
#2 MRBS\error_handler(8, Undefined variable: tz_url, /....../mrbs-1.11.0/functions_ical.inc, 74, array) called at [/....../mrbs-1.11.0/functions_ical.inc:74]
#3 MRBS\get_vtimezone(Europe/Berlin) called at [/....../mrbs-1.11.0/functions_ical.inc:764]
#4 MRBS\create_ical_event(PUBLISH, array) called at [/....../mrbs-1.11.0/functions_ical.inc:1006]
#5 MRBS\export_icalendar(object, false, 1681768800) called at [/....../mrbs-1.11.0/report.php:1878]
Uncaught exception 'TypeError' in /....../mrbs-1.11.0/functions.inc at line 192
Argument 1 passed to MRBS\url_get_contents() must be of the type string, null given, called in /....../mrbs-1.11.0/functions_ical.inc on line 74
#0 /....../mrbs-1.11.0/functions_ical.inc(74): MRBS\url_get_contents(NULL)
#1 /....../mrbs-1.11.0/functions_ical.inc(764): MRBS\get_vtimezone('Europe/Berlin')
#2 /....../mrbs-1.11.0/functions_ical.inc(1006): MRBS\create_ical_event('PUBLISH', Array)
#3 /....../mrbs-1.11.0/report.php(1878): MRBS\export_icalendar(Object(MRBS\DBStatement), false, 1681768800)
#4 {main}

I do not understand why the timezone url is not found in the database (the entry for the time zone is there and vtimezone does contain the correct TZURL: - entry).

Attached is a small patchfile that inserts initialises tz_url as an empty string, after which the report works.

1 Attachments

Discussion

  • Campbell Morrison

    What is the last_updated value for your entry in the database?

     
  • Campbell Morrison

    Also, could you post the value of vtimezone please?

     
  • Stefan Muenkner

    Stefan Muenkner - 2023-02-17

    Last update was 18. Jan. before. I checked this, after the successful export it was reset to yesterday. Attached is a dump of the zoneinfo table (zoneinfo.dump). At least in the dump it seems, that the vtimezone only contains \n as line endings instead of the expected \r\n . That install is a rather old installation, updated once from 1.4.9 to 1.9.4 in Oct. 2021 and just recently to 1.11.0. A new installation has the correct line endings in vtimezone. Thanks for pointing me in that direction.

     
  • Campbell Morrison

    Thanks. When I looked at the code I saw that there were a number of problems apart from this one, so I've rewritten it in 8b30fee.

     
  • Campbell Morrison

    Moreover, any error message is saved as report.ics and only on inspecting that file with an editor, the error message can be found. The user otherwise has no idea that the report failed.

    I think that's probably because you had $debug = true;. The errors will also be in your PHP error log.

     
  • Campbell Morrison

    That install is a rather old installation, updated once from 1.4.9 to 1.9.4 in Oct. 2021 and just recently to 1.11.0

    If you haven't done so already it's probably worth emptying the vtimezone table to flush out any incorrect entries.

     
  • Stefan Muenkner

    Stefan Muenkner - 2023-02-17

    so I replaced the vtimezone info with a correct one. The export after that works without the clunkd $tz_url=""; from patch I sent in.

    report.ics even without $debug = true; contained a html-page ("Whoops! Unfortunately MRBS has encountered a fatal error. Please consult your system administrator."). I am not too familiar with http-request-response scheme that is used for the report. It seems that anything produced by the report-request gets send to the file.

     
  • Campbell Morrison

    report.ics even without $debug = true; contained a html-page ("Whoops! Unfortunately MRBS has encountered a fatal error. Please consult your system administrator."). I am not too familiar with http-request-response scheme that is used for the report. It seems that anything produced by the report-request gets send to the file.

    OK, I'll investigate further.