-
Notifications
You must be signed in to change notification settings - Fork 28
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
Bug: Nginx/PHP-FSM environments subject to infinite recursions (internal redirects) #213
Comments
Hi, |
Separate out each problem's solution as its own PRThe first thing I note is that you're solving two separate problems (and have even clearly marked them as separate problems) - since there are two ways to solve the second problem but only one way to solve the first, can you please split out your solution to the first problem (i.e. the recursion protection for That way we can review and merge that PR on its own merits, and it will be much simpler to compare the two remaining PRs which only include the different solutions for problem 2. The approach for problem 2I haven't taken the time to fully understand how the share draft module works, but manipulating (or even reading the PHP globals at this layer just feels like a bad way to handle things. It feels to me like this URL rewriting should be handled in middleware, or by getting and setting values from a |
The approach for
|
Checking in, here. :) My thoughts on the involvement of |
Fixes #213: Nginx/PHP-FSM environments subject to infinite recursions (internal redirects) - Option B
Thanks for reporting and fixing this! |
We've come across a strange occurrence on Nginx/PHP-FSM environments where a combination of the most up to date
silverstripe-trailing-slash
andsharedraftcontent
versions lead to infinite internal redirects, causing "exceeds memory" fatal errors (or "exceeds time limit" fatal errors, when configured for max memory). The issue did not impact Apache configurations running the identical code base.Before diving in, I reached out to @wilr (who contributed to #144) for context and suggested direction.
I started just dumping all the data as it was executed from TrailingSlashRedirector.php and comparing the outputs between Nginx/php-fsm (not working) and Apache (working) and eventually found the discrepancy....
Ultimately, we isolated it to
ShareDraftController
where it sets up a clean environment internally, sets the URL via$variables['_SERVER']['REQUEST_URI'] = $url;
, and then saves it to the environment viaEnvironment::setVariables($variables);
I printed
Environment::getEnv('REQUEST_URI');
before and again afterEnvironment::setVariables($variables);
is executed, and sure enough...Solution
Two alternate solutions - both accomplish the same thing in different ways. I'm not as deeply familiar with the
Environment
class and the generally acceptable usages so I'm submitting both for consideration (pick one), though, @wilr and I agree that Option B seems a bit clearer and there might be unknown repercussions to unilaterally overwritingstatic::$env
as happens Option A.The end result is the same for both implementations:
It really just comes down to whether we use only
Environment::setVariables
(Option A) or a combination ofEnvironment::setVariables
andEnvironment::setEnv
(Option B).I have to wonder if perhaps
Environment::setVariables
is not being used correctly in the first place? Because I noticed the source code forEnvironment::setVariables
setsstatic::$env
variables in a VERY different way compared toEnvironment::setEnv
:What doesn't work....
I did attempt to replace
Environment::setVariables
entirely with onlyEnvironment::setEnv
calls -- it broke both environments. So, somehow$GLOBALS
are a necessary component.Context / related:
@muskie9 @jsirish @oddnoc @phil-quinn @wilr
PRs
OR
The text was updated successfully, but these errors were encountered: