New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Request() in DocumentRenderer clears RequestContext Data #3579

solverat opened this Issue Nov 7, 2018 · 0 comments


None yet
1 participant

solverat commented Nov 7, 2018

$request = new Request();

As you can see here, pimcore generates a new request object if the request stack has no active requests (in cli mode for example).

That's ok if you're submitting just one email per request. But if you're going to send multiple mails (or something else with an involved request context) via CLI in a loop, this becomes a major problem. For example:


  • Populate system settings host with
  • Create a email
  • Create a command with a containing loop (more than one cycles) and send the mail on each cycle:
foreach ($infos as $info) {
   $email = Email::getByPath('/your-email');
   $productLink = $this->urlGenerator->generate('route_name', []);
   $mail = new Mail();
   $mail->setParam('url', $url);


  • Mail 1: Param url is
  • Mail 2: Param url is http://localhost/my-url-structure


  1. The first mail generation is valid since the default RequestContext contains the default host (search forpimcore.routing.router.request_context service in your compiled container).
  2. DocumentRenderer does not find any request and creates a new one
  3. Empty request will be injected in RouteListener => $this->context->fromRequest($request);
  4. In the next cycle, the context does not have any default data anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment