Skip to content

Only run plugins when there are tasks #9

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

Merged
merged 1 commit into from
Mar 16, 2017
Merged

Conversation

zarathustra323
Copy link
Member

When only a plugin was enabled (no tasks), the entire response was being modified as if there were tasks assigned. This was causing unintended results.

Going forward:

  • Plugins should only manipulate the response when post process tasks are set.
  • The response headers and content should only be modified when tasks are set - not when only plugins are set.

@solocommand
Copy link
Member

That’s not the intention of a plugin. Plugins are supposed to always modify the response, whereas tasks are only run when there is something to run.

@solocommand
Copy link
Member

If a plugin is enabled, it always runs. If you don't want that to happen, don't load a plugin

@zarathustra323
Copy link
Member Author

I disagree. Plugins should only be used in conjunction with tasks, not as a cart blanche response manipulator. If you need to manipulate the response, use the native kernel.response event provided by Symfony.

Take the following example:

  • We have a NR plugin set
  • Because that's set, ALL responses are having the Connection: close header appended to it
  • In addition, response body lengths are also being manipulated
  • Furthermore, the NR plugin is now setting ALL responses as being post process, when in fact they're not

@zarathustra323
Copy link
Member Author

You know very well that "don't set a plugin" isn't REALLY a solution, as they are being set at DI time, not at run-time

@zarathustra323
Copy link
Member Author

Connection: close as well as manipulated the response is required for task running, not for plugins, but plugins are causing this side effect even when no tasks are set.

@solocommand
Copy link
Member

My point though is that if you/we've made a decision to load the NR plugin at DI-time to append the NREUM data to all responses, it should append it to all responses.

While I agree that a plugin should not necessarily force Connection: close, that plugin should still be ran because we chose to enable it. Your change will only run the plugin when there are tasks to process, which is incorrect because of how we chose to configure it.

@zarathustra323
Copy link
Member Author

Overall, our implementation of "plugins" is probably just "wrong." And should either be removed entirely, or should only run in conjunction with a task -- if they don't run with tasks, what's the point of them? They're now being used for a different purpose that's outside the concern of running PHP code after the response has been sent to the browser

@solocommand solocommand merged commit 9c88278 into master Mar 16, 2017
@solocommand solocommand deleted the zarathustra323-patch-1 branch March 16, 2017 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants