Closed (fixed)
Project:
Payment
Version:
8.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Dec 2015 at 07:28 UTC
Updated:
16 Aug 2018 at 18:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
berdirComment #3
johnchquePull request created https://github.com/bartfeenstra/drupal-payment/pull/29 .
Comment #4
xanoThank you for fixing this issue! I'm marking this as postponed pending the PR at https://github.com/bartfeenstra/drupal-payment/pull/29. Once that has been merged, we can close this issue.
Comment #5
xanoI like this! Committed and pushed to 8.x-2.x. Thanks a lot!
Comment #8
jurgenhaas@Berdir I'm just coming across the same error and tried this patch/workaround, with no luck.
First try was to update from beta3 to 2.x-dev release as the patch above is included there, but that didn't solve the problem.
Second try then was to put this into my controller:
But I still get this error:
Any chance that you could help me with this? If you prefer, we can do that on PM or Slack or which ever channel you prefer.
Comment #9
berdirThis only works if whoever creates the Url adds the necessary cacheablity metadata and only if it is really the URL.
For example I had a bug with search_api_solr that created a URL for the solr connection and that made it fail. You need to debug the cacheability metadata you have and see if you can track that down to the module that is causing it.
Comment #10
jurgenhaasSorry, I'm not getting it. I use the payment module and I have a controller that creates and executes the payment object and then wants to redirect to the external URL given by the payment module. The controller looks like this:
So, that returns a TrustedRedirectResponse instance to
EarlyRenderingControllerWrapperSubscriber::wrapControllerExecutionInRenderContext()which checks if the response is instance of CacheableResponseInterface and if so, always throws the exception. And any TrustedRedirectResponse instance is of type CacheableResponseInterface and so I have no idea how to prevent the error.What am I missing?
Comment #11
jurgenhaasNow I found it. I'm testing with the payment method https://www.drupal.org/project/mollie_payment and they are calling Drupal::url() to generate the return URLs and that calls some render function. I've now replaced that with Url()->toString(TRUE)->getGeneratedUrl() and now it is working because the render context remains empty.
Phew, that is somehow dangerous. It means that any other contrib module can break a lot if they call any function that inheritly calls any render function, maybe even by mistake.
Comment #12
berdirYes, ->execute() does something, probably create Url objects and so on. Those are added to the global stack of cache metadata and then not handling it results in this.
if it is a contrib payment method, report a bug there, if it is your own, you'll have to debug it yourself. Contact us (info@md-systems.ch) if you want to pay us to look into it, I can't see more without seeing the code/being able to debug it.
Comment #13
jurgenhaasIt's not mine but I submitted a patch to the module, see #2802999: Do not use Drupal::url() any longer
Comment #14
berdirI know: #2638686: Correctly handle cache data instead of throwing an Exception in EarlyRenderingControllerWrapperSubscriber()
Comment #15
StephanW commented@Berdir:
I'm trying to use the payment datatrans module and am now also stuck at this error and don't know how to avoid it.
I just installed the needed modules and my controller does this:
I also tried
and got the same error message.
What am I doing wrong?
Comment #16
pounardI finally ended up with this very ugly solution:
Which is an imperial DX failure.