The CSV export display collides with a REST export the site already made
Problem / Motivation
ai_disclosure_csv_export attaches its export as a display named rest_export_1 on
views.view.ai_disclosure_report. Views gives that same name to the first REST export a site
adds from the Views UI, so the two collide.
Steps to reproduce
Measured on Drupal 11.4.5, module at 4f46e74.
- Install
ai_disclosure, withviewsandnode. - On
views.view.ai_disclosure_report, add a REST export display from the Views UI. Views names itrest_export_1. - Install
ai_disclosure_csv_export. - The view still carries the site's display, and the default display has no
ai_disclosure_report_exportcommand in its footer. Nothing was attached, and nothing said so. - Uninstall
ai_disclosure_csv_export. The site'srest_export_1is gone, with its path.
The other order behaves. With the submodule installed first, Views names the site's display
rest_export_2, and uninstalling the submodule leaves it alone.
Cause
_ai_disclosure_csv_export_attach_export_display() returns early when a display named
rest_export_1 exists, reading the site's display as work it had already done.
ai_disclosure_csv_export_uninstall() deletes that key without checking who created it.
Proposed resolution
Name the display ai_disclosure_csv_export, which no site can produce from the Views UI. A
hook_update_N renames it where the submodule is already installed. The path does not change,
so the export keeps answering on the same URL.
Two tests belong with the fix: the submodule installed onto a view that already has a
rest_export_1, and the site's own display left in place when the submodule is uninstalled.