Because it does not return the status of the saved key.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mxr576 created an issue. See original summary.

Sergiu Stici’s picture

Status: Active » Needs review
FileSize
1.52 KB

Here is the patch, please review.

jcnventura’s picture

Status: Needs review » Needs work

I'm pretty sure it still doesn't return the status. I think the proposed patch is not improving anything, as it saves the entity twice.

EntityForm::save(), which this class extends is defined as:

  return $this->entity
    ->save();

Instead of just calling parent::save($form, $form_state); at the beginning (which saves the entity for the first time), delete all the lines before and inside the try (which are saving the entity for the second time). Replace the current try body with $status = parent::save($form, $form_state);. Oh, and then add a return $status at the end of the call, of course.

I haven't checked the code for the other two functions where the patch is calling the base class, but it is very likely that similar changes have to be made.

AaronBauman’s picture

Status: Needs work » Needs review
FileSize
3.24 KB

Here's a reworking of the patch:
1) removes the submitForm() method from KeyConfigOverrideDeleteForm in favor of getDeletionMessage()
2) implements getDeletionMessage() in KeyDeleteForm
3) update KeyFormBase::save() to remove the try/catch, since EntityFormInterface does not accommodate returning NULL.
also replace drupal_set_message() with messenger()

FWIW, many core implementations return void in violation of EntityFormInterface, and also do not perform any exception handling: \Drupal\node\NodeForm::save, \Drupal\menu_ui\MenuForm::save, \Drupal\media\MediaTypeForm::save, \Drupal\workflows\Form\WorkflowEditForm::save, etc.

jcnventura’s picture

rlhawk’s picture

Status: Needs review » Reviewed & tested by the community

This is terrific. Thanks, all.

  • rlhawk committed a081ac5 on 8.x-1.x authored by AaronBauman
    Issue #3048562 by AaronBauman, Sergiu Stici, jcnventura, mxr576:...
rlhawk’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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