The most obvious problem is that all the log messages show escaped HTML.
The other problem is that the User column is always empty.
And a big WTF is that the individual log items are each wrapped in <div><ul><li> ... </li></ul></div> then saved to the database with all that extra HTML. Note that a log item is at most one entry, so there is only one bullet each.

Here's a patch that fixes the rendering of the page so that we see the User column and we don't see escaped HTML. At the same time, it fixes the saving of the log entries so that extra HTML is not added and not stored in the DB.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TR created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, order-log.patch, failed testing.

TR’s picture

Status: Needs work » Needs review
FileSize
3.55 KB

  • TR committed 5073a14 on 8.x-4.x
    Issue #2647802 by TR: Multiple problems with /admin/store/orders/%/log
    
TR’s picture

Status: Needs review » Fixed

Committed.

longwave’s picture

       foreach ($changes as $key => $value) {
         if (is_array($value)) {
-          $items[] = t('@key changed from %old to %new.', ['@key' => $key, '%old' => $value['old'], '%new' => $value['new']]);
+          $entry = t('@key changed from %old to %new.', ['@key' => $key, '%old' => $value['old'], '%new' => $value['new']]);
         }
         else {
-          $items[] = (string) $value;
+          $entry = (string) $value;
         }
       }

I was sure there was a case somewhere where this was called with multiple values; at the moment if $changes contains more than one value then only the last one is stored, as $entry is overwritten on each pass of the loop.

TR’s picture

I had intended to move the db_insert() inside the loop. Here's a follow-up patch to do that. EDIT: I accidentally committed it before I posted it here (commit f859b9cd), and it got mixed up with something else I was doing so it has the wrong commit message. Sigh.

logChanges() really should be scrapped and we should use the logger service instead to write to our own table. But it works such as it is and there are much more important to work on right now.

Status: Fixed » Closed (fixed)

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