fix: #3618801 Restore hook_views_data on cores without hook discovery and install the report view
Issue: https://www.drupal.org/project/admin_audit_trail/issues/3618801
Two defects, both reproduced on a real Drupal 10.6.15 site with the released 1.0.11 and every submodule enabled. Thank you drupalfan2 for the report and the stack trace.
1. hook_views_data() disappeared on cores without hook discovery. Object-oriented hook discovery only exists in Drupal 11.1 and later; the module supports ^10.1 || ^11 || ^12. When admin_audit_trail.views.inc was removed, views_data became the only hook in the module left without a #[LegacyHook] procedural wrapper - help, form_alter, cron, views_pre_render and all eighteen submodules kept theirs. On Drupal 10 and 11.0 the attribute is ignored, so Views has no data for the admin_audit_trail table and the report ends in the reported InvalidArgumentException from ViewsData::get(). A fresh Drupal 11.4 site is unaffected, which is why this was not caught before the release.
2. The report view is not created when Views is enabled alongside the module. The view ships as optional configuration, which Drupal installs only when Views is already enabled at that moment. A fresh install also stamps the schema at the newest update, so the repair update from #3618734 never runs. hook_install() and hook_modules_installed() now call the existing repair.
Verified on Drupal 10.6.15, module plus seventeen submodules:
| Check | Released 1.0.11 | With this MR |
|---|---|---|
hook_views_data() implemented |
no | yes |
| Views table data | empty | present |
| Report view entity | missing | present |
| Report view executes | unreachable | yes |
| Report page in the browser | broken | renders, no errors |
Fourteen events were then logged across node, user, user roles, taxonomy and configuration, all fourteen forwarded to the logger.
Update paths. A fresh install stamps the schema at the newest update, so a site installed on 1.0.11 with a missing view had no update left to run - drush updb reported nothing pending. admin_audit_trail_update_10004() closes that:
| Situation | Repair |
|---|---|
| Schema below 10002 (older releases) | update_10002 |
| Distribution install skipped the view (#3618734) | update_10003 |
| Installed fresh on 1.0.11 with the view missing | update_10004 |
| New installs from now on | hook_install() |
| Views enabled after this module | hook_modules_installed() |
Verified on the Drupal 10.6.15 site by deleting the view and stamping the schema at 10003: drush updb ran update_10004, reinstalled the view, and the report then executed with 17 rows.
Tests: ViewsDataTest asserts the table is exposed with its base definition, every report column is a Views field, the user relationship is present, the shipped view executes, the procedural wrapper exists and returns the same data, and - guarding the whole class of defect - that every #[Hook] in src/Hook/ has a matching procedural wrapper.
Verified locally: 46 tests / 318 assertions green, PHPStan level 7 clean, PHPCS clean, cspell clean.
AI-Generated: Yes
Checkpoints:
- 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
-
Developer Documentation -
User Guide Documentation - Reviewed by human
- Code review by maintainers
- Full testing and approval
- Credit contributors
- Review with the product owner
- Release notes snippet
- Release 1.0.12