Problem/Motivation

#3272242: Expose audit trail report as a View added the new report view.

Because the view config yml has a dependency on the user module, the view is not installed during the installation of a Drupal Profile because all modules, including core and contrib, are installed alphabetically unless there are dependencies.

Steps to reproduce

  1. Create a Drupal Profile that lists admin_audit_trail as a dependency.
  2. Install Drupal using that Profile
  3. Note that the view is not installed and the report is not available

Proposed resolution

Two options:

  1. Remove "user" from the view dependencies. user should always be installed (eventually) anyway.
  2. Add "drupal:user" as a module dependency

Remaining tasks

  • ✅ File an issue
  • ✅ Addition/Change/Update/Fix
  • ✅ Testing to ensure no regression
  • ➖ Automated unit testing coverage
  • ➖ Automated functional testing coverage
  • ➖ UX/UI designer responsibilities
  • ➖ Readability
  • ➖ Accessibility
  • ✅ Performance
  • ✅ Security
  • ➖ Documentation
  • ✅ Code review by maintainers
  • ✅ Full testing and approval
  • ✅ Credit contributors
  • ✅ Review with the product owner
  • ✅ Release notes snippet
  • ✅ Release admin_audit_trail-1.0.9

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

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

shawn dearmond created an issue. See original summary.

segovia94’s picture

Title: View report doesn't install via install profile. » View report doesn't install in Drupal 10

This has nothing to do with the user dependency. It is a problem with D10.

I just tried this in d11 and it worked fine. However in drupal 10 (specifically I tried 10.6.2) it will not install the view.

I manually imported the config and received the following error when trying to view the report page:
InvalidArgumentException: A valid cache entry key is required. Use getAll() to get all table data. in Drupal\views\ViewsData->get() (line 137 of core/modules/views/src/ViewsData.php).

Trying to edit the views gives the following errors:

Warning: Undefined array key "uid" in Drupal\views\Plugin\views\HandlerBase->getEntityType() (line 800 of core/modules/views/src/Plugin/views/HandlerBase.php).
Warning: Trying to access array offset on null in Drupal\views\Plugin\views\HandlerBase->getEntityType() (line 800 of core/modules/views/src/Plugin/views/HandlerBase.php).
Warning: Trying to access array offset on null in Drupal\views\Plugin\views\HandlerBase->getEntityType() (line 800 of core/modules/views/src/Plugin/views/HandlerBase.php).

nadim hossain made their first commit to this issue’s fork.

nadim hossain’s picture

Issue -
The module uses Attribute-based hooks (#[Hook('views_data')]) located in src/Hook/AdminAuditTrailViewsHooks.php. During the Drupal update lifecycle, the Service Container is often in a "frozen" or "minimal" state. Because Attribute-based hooks require a full container rebuild and class discovery to be registered, the Views module fails to "see" the admin_audit_trail table definition when the update hook attempts to save the View entity.

Since the View configuration references a base_table that the system doesn't currently recognize, the ViewsData service returns a null key, causing the crash in HandlerBase.

Solution -
Added a traditional admin_audit_trail.views.inc file in the module root.

I have submitted the merge request and just adding this patch file to use it in the composer.

daaan’s picture

I tried the patch file suggested in #5, but that didn't apply.
I created my own patch using https://git.drupalcode.org/project/admin_audit_trail/-/merge_requests/26... and that worked on Drupal 10.6.2

rajab natshah’s picture

Status: Active » Needs review
rajab natshah’s picture

Thanks, Shawn and Mark for reporting and following up.
Thank you Nadim for the MR fix

rajab natshah’s picture

Assigned: Unassigned » josebc
Issue summary: View changes
Issue tags: +admin_audit_trail-1.0.9
rajab natshah’s picture

Assigned: josebc » Unassigned
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

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