As it's documented on https://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/watc... the third parameter is an array or have to be set to NULL if you want to make the message untranslatable.
Keeping the backward compatibility possible we with @alexverb propose the following change in dblog module in order to be able to handle other types too (see patch), because currently if you use e.g. a string as third parameter, watchdog writes the record to db, and it brakes the interface until you don't remove the wrong item from db. Also to make it less possible for contributed and custom solutions to do the same mistake, it would be good if even a wrong value goes to watchdog db table, it won't crash the interface just because theme_dblog_message function doesn't handle it well.
As 'N;' string is the manifestum of an empty array after serialization, it makes confusion why it has to be identically equal when it gets compared with the variables. Instead of this wizard it should be checked is it an array or not after unserializing it.
Following the documentation of watchdog, we think with this solution it's more realistic and understandable how theme_dblog_message works.
Comment | File | Size | Author |
---|---|---|---|
#13 | success-drupal-7x.png | 31.57 KB | mgoncalves |
#13 | error-drupal-7.x.png | 35.22 KB | mgoncalves |
#12 | after_patch.png | 140.75 KB | Vj |
#12 | before_patch.png | 121.11 KB | Vj |
#8 | watchdog_breaks-2865789-8.patch | 1.1 KB | lisotton |
Comments
Comment #2
tatarbjComment #3
tatarbjComment #4
Wim LeersComment #5
dagmarThis is already fixed in D8, but with some minor modifications:
It would be nice to see this implemented in the same way in D7.
Comment #6
Wim LeersComment #7
lisotton CreditAttribution: lisotton at CI&T commentedWorking on a new patch.
Comment #8
lisotton CreditAttribution: lisotton at CI&T commentedNew patch using the same approach of D8.
Comment #9
mgoncalves CreditAttribution: mgoncalves at CI&T commentedReviewing it.
Comment #10
code-drupal CreditAttribution: code-drupal commentedThe line in the patch submitted seems incorrect.
$args = @unserialize($event->variables)
If the unserialize() statement is preceded with a '@' to avoid cluttering the logs with warns or notices there will be absolutely no clue as to why the script stopped working.
Comment #11
lisotton CreditAttribution: lisotton at CI&T commentedHi @code-drupal,
It's the same approach used in Drupal 8 as suggested by @dagmar.
Comment #12
Vj CreditAttribution: Vj as a volunteer commentedTested patch #8. Worked for me.
Screenshot before patch
Screenshot after patch
Comment #13
mgoncalves CreditAttribution: mgoncalves at CI&T commentedHello all,
This is result of patch #8.
Before:
After:
Works for me.
Thanks for the patch @lisotton.
Comment #14
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedSeems closely related to #1279680: watchdog() does not type its array arguments - I think we want to fix it at the root (as done in some of the patches there) but fixing it here also might be OK (especially for sites that already have broken entries in the logs).
Comment #15
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedThis actually looks like a duplicate of #2790857: Log completely unusable when an entry has corrupt serialized data (D7) which is further along than this since it's backporting the tests from Drupal 8 also, but the patch here doesn't have any tests. Let's consolidate efforts to fix this over there.