Problem/Motivation
Six resources answer form submissions by handing a message to the core contact module: MyrestResourceContactForm::create() fetches contact.mail_handler from the container with no check, and five resources extend it. The module declares no dependency on contact and none of those resources declares myrest_requires_module either, so on a site without the contact module they are registered, offered on the settings screen, and throw the moment one of them is instantiated.
Every other optional integration of this module is handled properly and is worth naming as the contrast: the nine index-backed resources declare myrest_requires_module = "search_api" and are not registered without it; the image styles are resolved through a hasDefinition() check and fall back to the original file; paragraphs, facets, redirect and the metatag integration are all guarded. The form resources are the one place where the pattern was not applied.
Proposed resolution
- Declare
myrest_requires_module = "contact"on the six form resources, so that a site without the contact module simply does not get those endpoints and keeps the other forty. That is the mechanism this module already uses for the search-backed resources, and it is a better fit than an install-time dependency: contact forms are not the heart of the module. - Guard the container fetch in the base class the way the metatag helper is guarded, so a resource that is somehow reached still fails as an error response rather than as an exception.
- Cover it: with the contact module absent, the form resources are not among the definitions, and the rest of them are.
- While the dependencies are open: the robots.txt resource reads
robotstxt.settingsand invokeshook_robotstxt()without the module being named anywhere in the documentation. Reading absent configuration is harmless, so this is a documentation fix, not a code one - the module belongs in the optional table of README.md next to the others.
Remaining tasks
Everything.
Issue fork myrest-3619210
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
Comment #4
sergeydruua commentedComment #6
sergeydruua commented