Problem/Motivation

Something is incomplete or out of date with the display of log entities. The edit form appears fine but the View tab is empty.

Steps to reproduce

I went to https://simplytest.me and created a sandbox with Entity Log 8.x-1.4. (I tried the beta but the configuration screen failed with an error.) Configure anything to record changes and check the "log to entities" checkbox. Make some changes to the configured entities. Go to the log entities list and click on any of the log entities. From the Edit form, click on the View tab.

Proposed resolution

There are two template files. I am pretty sure that the correct file name is entity-log.html.twig. The preprocess function in entity_log.page.inc is looking for something that doesn't exist. But that function doesn't seem to be necessary in any case. I changed the variable in the twig file from 'content' to 'children' and I'm seeing what I expected now.

Remaining tasks

Update the relevant code and files to match the original intent for displaying a log entity.

CommentFileSizeAuthor
#7 3469282 before.png79.35 KBcsakiistvan
#6 3469282 after.png146.83 KBcsakiistvan

Issue fork entity_log-3469282

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

brad.bulger created an issue. See original summary.

sorabh.v6’s picture

Assigned: Unassigned » sorabh.v6

Working on it.

sorabh.v6’s picture

Assigned: sorabh.v6 » Unassigned
Status: Active » Needs review

Updated the code in the template file and its showing up now. Please review.

There's some existing code that I think is not useful and we can create a new issue to remove the unnecessary code.

Thanks

demeritcowboy’s picture

This works for me.

(I'm a bit confused that the log entries don't show you the date/time of the log entry anywhere, but seems like a separate issue. It stores it in the entity_log table, but isn't visible on either view or edit.)

csakiistvan’s picture

Assigned: Unassigned » csakiistvan
StatusFileSize
new146.83 KB

Environment

  • Drupal: 11.4.1
  • PHP: 8.5.5
  • Database: MariaDB 10.11.16
  • DDEV: v1.25.2
  • Entity Log: 1.5.0
  • Browser: Chrome

Prerequisites

  • Enable the module: ddev drush en entity_log -y
  • At /admin/config/system/entity-log enable Log in Entity Log entity and select at least one field (e.g. Title) to log for a content type such as Article.
  • Create or edit an Article node so a log entity is recorded (change the logged field and save).

Steps

  1. Apply the fix from MR !9 (plus the correction below).
  2. Rebuild caches: ddev drush cr
  3. Go to Reports → Entity Log list of entities (/admin/structure/entity_log) and open any log entity.
  4. Click the View tab and observe the rendered fields.

Expected results

  • The View tab renders the logged field data (Field label, Old field value, New field value, etc.).
  • No PHP warning or Twig error is produced.

Actual results

Before the fix the View tab was empty: the entity_log theme hook resolves to the template file entity-log.html.twig (hyphen), but the real template shipped as entity_log.html.twig (underscore) and was never loaded, so only the placeholder comment <!-- Add you custom twig html here --> rendered. After the fix the View tab shows the logged fields, e.g. Field label "Title", Old field value "Cache redirect test node", New field value "Cache redirect test node (edit)".

Note on MR !9

Renaming the template to entity-log.html.twig is correct and required, but printing the whole render element with {{ children }} does not work on Drupal 11: that element still carries #theme: entity_log, so it re-themes itself and triggers a "Recursive rendering attempt aborted" warning, leaving the div empty. The underlying reason the original content variable was empty is that template_preprocess_entity_log() lives in entity_log.page.inc, which entity_log_theme() never registers, so the preprocess never runs. The working template iterates the field items directly:

<div{{ attributes.addClass('entity_log') }}>
  {% for key, item in children %}
    {% if key|first != '#' %}
      {{- item -}}
    {% endif %}
  {% endfor %}
</div>

Testing produced with the assistance of an LLM.

csakiistvan’s picture

StatusFileSize
new79.35 KB
csakiistvan’s picture

Assigned: csakiistvan » Unassigned
Status: Needs review » Reviewed & tested by the community
csakiistvan’s picture

Version: 8.x-1.4 » 8.x-1.5

change version to the latest one, the previous test can reproduce it on 1.4 and 1.5 too