Module breaks webform rest elements endpoint

Created on 20 March 2024, 9 months ago
Updated 5 April 2024, 9 months ago

Problem/Motivation

The webform_rest/webform_id/elements endpoint of the webform_rest module run into an out of memory issue when enabling gin_everywhere. Works fine without.

I think the problem lies in an endless loop inside the serialization process of the form and the addition of things to the form.

Steps to reproduce

Install webform_rest and gin_everywhere and try to access the webform_rest/webform_id/elements rest endpoint.

Proposed resolution

Do not alter the webform_submission form.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇨🇭Switzerland yobottehg Basel

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @yobottehg
  • Merge request !5Resolve #3432341 "Module breaks webform" → (Closed) created by yobottehg
  • Issue was unassigned.
  • Status changed to Needs review 9 months ago
  • 🇨🇭Switzerland yobottehg Basel

    Added a basic fix for the problem.

  • Status changed to Postponed: needs info 9 months ago
  • 🇩🇪Germany Hydra

    Hey @yobottehg,

    are you sure that this is the casue? I tried it with the default contact form provided by webforms and everything worked fine with webform_rest module, see:

    Have you updated to the last version? We had a performance issue in the first version which has been fixed https://www.drupal.org/project/gin_everywhere/issues/3424026 🐛 Performance with getRouteCollection / XDebug Fixed

  • 🇨🇭Switzerland yobottehg Basel

    Hey @hydra,

    I just uninstalled module by module until it worked and the gin_everywhere module was the cause.

    I then step debugged through the code to see that this caused an infinite loop and the provided patch made the endpoint work again.

    Let me try to get a minimum reproducible example.

  • 🇨🇭Switzerland yobottehg Basel

    Okay i got the minim steps to reproduce:

    drupal/core: 10.2.4
    drupal/webform_rest: 4.1.0
    drupal/gin_everywhere: 1.1.0
    drupal/gin

    Use gin as admin and as frontend theme!

    We have a decoupled Drupal instance without a frontend and with using gin as frontend theme the endpoint breaks without the patch.

  • Status changed to Needs review 9 months ago
  • 🇩🇪Germany Hydra

    Ok, so setting gin as a frontend theme might cause this. Will have another look into this. Thx for the research!

  • 🇨🇭Switzerland yobottehg Basel

    I added a more appropriate check which also solves the problem.

  • 🇩🇪Germany Hydra

    Thx! This looks much more reasonable to me than before. But I think it's a vaild use case to use gin as a frontend theme as well and also in combination with forms. I would prefer a way which would allow for that.

    It seems to be an issue with using t() - don't know why this is not working properly.

    I think what we could do is check if the request format is html, which should always be the case when altering forms but in this case... its json or xml I guess. Not sure whats the right way :/ It does not feel like the right solution yet.

      // Make sure we are on a html request.
      // @see See https://www.drupal.org/project/gin_everywhere/issues/3432341
      if (\Drupal::request()->getRequestFormat() != 'html') {
        return;
      }
    
  • 🇩🇪Germany Hydra

    @yobottehg I could not sleep and dived a bit deeper into the problem and found out, that the webform submission is implementing the EntityOwnerInterface interface without providing an owner key on the entity type. This results in wrong from alterations from gin_everywhere. Can you have a look at my MR to check if this helps with your issue?

  • 🇨🇭Switzerland yobottehg Basel

    @Hydra I can confirm that this also solves the problem.

    Looks like we should create an issue on webform or perhaps use the interface method instead of the array key ? https://api.drupal.org/api/drupal/core%21modules%21user%21src%21EntityOw...

  • Pipeline finished with Skipped
    9 months ago
    #126189
  • Status changed to Fixed 9 months ago
    • Hydra committed 5129950c on 1.x
      Issue #3432341 by yobottehg, Hydra: Module breaks webform rest elements...
  • 🇩🇪Germany Hydra

    Yeah we are checking for the EntityOwnerInterface in gin_everywhere. I am willing to commit the additional check since it does not harm anything and helps addressing your issue. Feel free opening an issue on webforms issue queue for that :)

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

Production build 0.71.5 2024