If I call a form that does not exist(or is defined in non-loaded file) I'll get notice and warning but the form will be displayed.
In addition, if I use form altering hooks(hook_form_alter, hook_form_FORM_ID_alter, hook_form_BASE_FORM_ID_alter) I can put form elements into this non-existing form(though validation and submit functions won't get called).

I think non-existing form should not be rendered at all and it should not call form altering hooks either.

CommentFileSizeAuthor
#4 2108943-nonexisting_forms-v2.patch1011 bytesAnonymous (not verified)
#1 2108943-nonexisting_forms.patch980 bytesAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Status: Active » Needs review
FileSize
980 bytes

Status: Needs review » Needs work

The last submitted patch, 2108943-nonexisting_forms.patch, failed testing.

Anonymous’s picture

Status: Needs work » Needs review

Though the last patch would not work with #1795476 (if it gets commited).

Anonymous’s picture

Status: Needs review » Needs work

The last submitted patch, 2108943-nonexisting_forms-v2.patch, failed testing.

Anonymous’s picture

To pass the tests, they themselves have to be altered to reflect this change and that is a task for someone with more knowledge of all Drupal's tests so I rather leave it to someone else.

swentel’s picture

I don't see why we should be protecting this. If it doesn't exist, it there's a problem with the calling code, not in core.

Anonymous’s picture

Why is this fixed for loading entities via menu path or something like that then?

swentel’s picture

Status: Needs work » Closed (duplicate)

There's a duplicate actually, see #979686: Non-existing form_id can be retrieved, prepared, processed, and even executed - forms are not dynamic like content or menu paths. If there's an error, it's really easy to fix and then we're done really.