+++ b/core/modules/dblog/dblog.admin.inc
@@ -58,13 +58,29 @@ function dblog_overview() {
foreach ($result as $dblog) {
...
+ if (isset($dblog->message) && isset($dblog->variables)) {
...
+ $message,
If a query result row does not have a ->message and ->variables for any reason, then $message contains the $message of the last row.
+ // Messages without variables or user specified text.
+ if ($dblog->variables === 'N;') {
+ $message = $dblog->message;
+ }
+ // Message to translate with injected variables.
+ else {
+ $message = t($dblog->message, unserialize($dblog->variables));
+ }
Could we have added a dblog_format_message() helper function instead of duplicating the same code in multiple places?
Add a formatMessage() helper to DbLogController.
None at this time.
Comments
Comment #1
sunComment #2
star-szrComment #3
star-szrSomething like this?
Comment #4
areke commentedIt looks like that after sitting here for half a year, the patch needs to be re-rolled because it doesn't apply.
Comment #5
star-szrWorking on it.
Comment #6
star-szrUpdated patch. Thanks for bringing this back @areke :)
Comment #7
star-szrEh, there's still that same message formatting code in dblog_top() in dblog.admin.inc. The best way forward may be to postpone on #1982954: Convert dblog_top() to a controller, I don't think we should add a procedural helper (or a static method?) for this.
Comment #8
star-szrLooks like it might be a good time to revisit this.
Comment #9
amitgoyal commentedPatch in #6 no longer applies. So please review attached patch.
Comment #11
star-szrNice, thanks @amitgoyal :)
filter_xss should be Xss::filter I think.
Use $this->t() instead of t() here.
Comment #12
amitgoyal commentedOh! yes, you are right. Thanks for the feedback!
Please review updated patch.
Comment #13
star-szrGreat, let's see if we can refactor topLogMessages() now as well because it contains logic that can be replaced by the new formatMessage().
Comment #14
amitgoyal commentedPlease review revised patch with fixes in #13.
Comment #15
star-szrI think that's changing the logic, it didn't have the truncate before.
Comment #16
amitgoyal commentedSure. Please review revised patch with fixes in #15.
Comment #17
star-szrI don't think we want
$this->l, that wasn't called before either, same withXss::filter().Without seeing the whole code I think roughly what we might want here is:
(edited to add code tags)
Comment #18
amitgoyal commentedPlease see if the updated patch with suggested fixes in #17 looks good.
Comment #19
star-szrThis is looking good to me, I only have one small suggestion for improvement:
The first two lines here could be combined into one:
if ($message = $this->formatMessage($dblog))Comment #20
amitgoyal commentedSure, here is the revised patch as per suggestion in #19.
Comment #21
star-szrBeen a while since I worked on this so going for RTBC and updating the issue summary. Thanks @amitgoyal!
Comment #22
alexpottCommitted 0fa25d5 and pushed to 8.x. Thanks!