When I try to access the dblog I see following error:

TypeError: Argument 2 passed to t() must be of the type array, integer given, called in /var/www/xxx/docroot/modules/dblog/dblog.admin.inc on line 295 in t() (line 1735 of /var/www/xxx/docroot/includes/bootstrap.inc).

The proposed solution is:
dblog.admin.inc on line 295 Change:
$output = t($event->message, unserialize($event->variables)); => $output = t($event->message, [unserialize($event->variables)]);

Comments

adhariwal created an issue. See original summary.

adhariwal’s picture

neeravbm’s picture

Are you sure this is not coming from custom code where instead of passing second argument as an array to t() function, an integer is being passed?

adhariwal’s picture

@neeravbm Nope, it coming from dblog module only if you observe this line `$output = t($event->message, unserialize($event->variables))` you can easily understand that the second argument was not passed as an array here. I replaced the line with `t($event->message, [unserialize($event->variables)]);` which worked fine.

adhariwal’s picture

StatusFileSize
new612 bytes
berdir’s picture

Category: Bug report » Support request
Status: Active » Fixed

It might call it, but this indicates that someone incorrectly used the watchdog() API and provided an integer instead of an array there.

It could maybe do better validation of those values, but this fix is definitely wrong and would break all proper calls.

Check which module logged this row, then look for the problem there and clear your dblog to have it working again.

purushotam.rai’s picture

StatusFileSize
new694 bytes

Using the above patch breaks all other database logging, I guess we need to check before adding the array parenthesis.

alexmoreno’s picture

Status: Fixed » Reviewed & tested by the community

The last submitted patch, 5: 3017944-5.patch, failed testing. View results

jacob.embree’s picture

Status: Reviewed & tested by the community » Fixed

There is a lot of discussion about the arguments to watchdog() at #1279680: watchdog() does not type its array arguments and the related issues, and it certainly seems to be a problem with a calling module, not with dblog or watchdog().
I agree with Berdir that this is a support request and her answer covers it, so this can be marked "Fixed".
Both patches are incompatible with PHP 5.3 anyway.

alexmoreno’s picture

Status: Fixed » Closed (works as designed)

changing the status to closed (works as designed) to avoid confusion, as the patches won't be merged.

Summarising, custom code is responsible of this, so it should be that custom code calling dblog which should be fixed.

tinoscho’s picture

Component: extension system » dblog.module
Status: Closed (works as designed) » Needs review
StatusFileSize
new1.13 KB

Hi,

today I (again) stumbled upon this problem. I recognize that the problem is that the caller is using the API in a wrong way. Yet, the db_log exists to protocol and find problems in the system - which is quite difficult when the log cannot be used at all.

Therefore I suggest the attached patch - which I think is a quite safe and defense way to make at least sure the dblog can be viewed even if the callers are handling the API in a wrong way.

I'd be very happy if you could integrate that patch in future versions of D7.

Tino

tinoscho’s picture

StatusFileSize
new1.1 KB

Hi,
please find attached a new version of the patch without trailing whitespace...

Tino

bburg’s picture

I was running into this today, You can pretty quickly see what might be causing this by looking at the watchdog table directly:

mysql> select type, message, variables from watchdog

In my case, I had something like this in the variables column:

i:3;

In some custom code, I had confused the 3rd and 4th arguments in watchdog. https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/watc..., the 3rd being the variables added into the message, and 4th being the error severity.

The third argument should be an array, but I had passed an integer corresponding with the constant WATCHDOG_ERROR. As a long time watcher of this issue #1279680: watchdog() does not type its array arguments, I know it's unlikely that this will be changed.

bobburns’s picture

Needs to be comitted to core - patch 13 fixes this error which is still occurring, and my logging has contined with it applied

poker10’s picture

Status: Needs review » Closed (duplicate)
Related issues: +#2790857: Log completely unusable when an entry has corrupt serialized data (D7)

I think this is a duplicate of #2790857: Log completely unusable when an entry has corrupt serialized data (D7). Patches here have the same intention to fix the watchdog output in theme_dblog_message(), not the watchdog() function itself as in #1279680: watchdog() does not type its array arguments. Also this issue is newer than the first mentioned.