meeting-room-booking-system / mrbs-code

MRBS application code
Other
127 stars 63 forks source link

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

Open jberanek opened 1 year ago

jberanek commented 1 year ago

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.

Reported by: muenkner

Original Ticket: mrbs/bugs/537

Attachments: https://sourceforge.net/p/mrbs/bugs/537/attachment/functions_ical.inc_tzurl-patch

jberanek commented 1 year ago

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

Original comment by: campbell-m

jberanek commented 1 year ago

Also, could you post the value of vtimezone please?

Original comment by: campbell-m

jberanek commented 1 year ago

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.

Original comment by: muenkner

Attachments: https://sourceforge.net/p/mrbs/bugs/_discuss/thread/3247ccf779/42e1/attachment/zoneinfo.dump

jberanek commented 1 year ago

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.

Original comment by: campbell-m

jberanek commented 1 year ago

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.

Original comment by: campbell-m

jberanek commented 1 year ago

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.

Original comment by: campbell-m

jberanek commented 1 year ago

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.

Original comment by: muenkner

jberanek commented 1 year ago

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.

Original comment by: campbell-m