After clearing Drupal's cache trying to retrieve a webform via REST as a user other than user 1 results in the following error:
LogicException: The controller result claims to be providing relevant cache metadata, but leaked metadata was detected. Please ensure you are not rendering content too early. Returned object class: Drupal\rest\ResourceResponse. in Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (line 154 of core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php).
After viewing the webform as user 1 normally under admin/structure/webforms the webform is available via REST again to the the other users.
Returning a ModifiedResourceResponse instead of ResourceResponse might get around it, at the expense of some caching I think.
Comments
Comment #2
imclean commentedComment #3
imclean commentedComment #4
imclean commentedComment #5
imclean commentedLeaky cache contexts include the following:
Custom form:
Contact form:
For such a simple module as this, it's too tricky to work out everything which might be cached and add it to the response.
Comment #7
imclean commentedUsing
ModifiedResourceResponseinstead ofResourceResponse.