@MichaelHeerklotz opened this Pull Request on November 6th 2017

See https://github.com/piwik/plugin-QueuedTracking/issues/45

When the QueuedTracking plugin and its setting "Process during tracking request" are enabled, "Response->outputResponse()" is called twice, and thus the gif gets sent twice, which will mismatch the Content-Length header and cause some issues.

This patch adds a check to outputTransparentGif() to make sure the gif is only sent to output once.

@MichaelHeerklotz commented on November 6th 2017

After taking a closer look at the code, I see now that there is already a "hasAlreadyPrintedOutput()" function whichs fails in this case. Maybe a better solution would be to modify the existing "strlen($this->getOutputBuffer()) > 0" check to also kepp track of whether outputTransparentGif() was already called? . Or is there an even better way to fix this?

@tsteur commented on November 7th 2017 Owner

I still wonder why it is actually calling outputResponse twice. Can you maybe try what happens if you add the following code to plugins/QueuedTracking/Tracker/Handler.php

    public function finish(Tracker $tracker, RequestSet $requestSet)
        return $this->getResponse()->getOutput();

This might fix it without needing any hacks around whether output has been already sent or not.

@MichaelHeerklotz commented on November 7th 2017

@tsteur This fixes it. Nice solution :+1:

@tsteur commented on November 7th 2017 Owner

Awesome, did you want to adjust the PR or should I create a new PR?

@MichaelHeerklotz commented on November 7th 2017

Done :) Thanks a lot for your help

This Pull Request was closed on November 7th 2017
Powered by GitHub Issue Mirror