watchdog() does not type its array arguments

Created on 14 September 2011, about 13 years ago
Updated 31 August 2023, about 1 year ago

Problem/Motivation

If a third argument is passed to watchdog() that is not NULL or an array, the dblog page at admin/reports/dblog fails with a fatal error. This is because bad data is saved in the serialized 'variables' column in the watchdog table, and is not checked before passing to t() in dblog_overview()

Proposed resolution

Type hint the third argument to watchdog() as array.

Remaining tasks

None. Documentation has now been added, and a fix is committed to D8.

User interface changes

No UI changes.

API changes

No API changes. watchdog() will now throw an error if anything other than an array or NULL is given as the 3rd argument to the function.

Original report by cam8001

A contrib module passed some bad arguments to watchdog(), the data was saved to the watchdog table, then passed to t() for display at admin/reports/dblog. t() fails on the bad data, and now I cannot view logs at admin/reports/dblog.

I can get around the issue and restore the page's functionality by deleting the offending rows from the watchdog table.

πŸ› Bug report
Status

Fixed

Version

8.0 ⚰️

Component
Database LoggingΒ  β†’

Last updated about 2 months ago

  • Maintained by
  • πŸ‡¦πŸ‡·Argentina @dagmar
Created by

πŸ‡³πŸ‡ΏNew Zealand Cameron Tod

Live updates comments and jobs are added and updated live.
  • needs profiling

    It may affect performance, and thus requires in-depth technical reviews and profiling.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΈπŸ‡°Slovakia poker10

    Thanks all for working on this. I think we should close the D7 attempt as Won't fix. The reason is, that we cannot introduce a strict agrument typing, as it can cause fatal errors on sites (see #90). On the other hand, the patches in #91 and #103 are doing the similar thing that was already committed in #2790857: Log completely unusable when an entry has corrupt serialized data (D7) β†’ . So I think we do not need to add this protection again. The protection on output should be sufficient and we should allow to write even if it is not an array. We are also printing a message on output, if the variables are malformed, to I do not see anything else we can do here for D7.

    Closing this as Fixed for D8, so that credits get assigned correctly.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024