| Summary: | Disable caching when a SQL error exists | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Community | Reporter: | Denis Roy <denis.roy> | ||||
| Component: | Website | Assignee: | Christopher Guindon <chris.guindon> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | chris.guindon | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| See Also: |
https://git.eclipse.org/r/150895 https://git.eclipse.org/c/www.eclipse.org/eclipse.org-common.git/commit/?id=b885a69628cb63222602db069aa8a695f0c033ce |
||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
As discussed on Slask with Denis, we should return a status 500 on these error page to avoid caching from nginx. I will submit a patch to address errors triggered by $App->mysqlErrorCheck(); New Gerrit change created: https://git.eclipse.org/r/150895 I don't think this will work, as there is output content prior to setting the header. As the output is buffered by php, we may have a chance.
I suggest this prior to your header() call:
$stuff = ob_get_contents();
ob_end_clean();
header('HTTP/1.1 500 Internal Server Error');
echo $stuff; # Send the actual error to the screen. Do we want to do this?
exit();
I submitted an edit. https://git.eclipse.org/r/#/c/150895/ (In reply to Denis Roy from comment #4) > I don't think this will work, as there is output content prior to setting > the header. As the output is buffered by php, we may have a chance. > > I suggest this prior to your header() call: > > $stuff = ob_get_contents(); > ob_end_clean(); > header('HTTP/1.1 500 Internal Server Error'); > echo $stuff; # Send the actual error to the screen. Do we want to do this? > exit(); What will not work? The status code won't be a 500 or the mysql error won't be printed on the page? The php script below should return a status 500 with the content "before and after!": <?php echo 'before '; ob_start(); echo 'and after!'; header('HTTP/1.1 500 Internal Server Error'); exit; It's important to note that both solution won't work if the server already sent the headers and we can't assume that output buffering is enabled since the error could occur prior to turning it on. Also, headers are sent even if output buffering is enabled: https://www.php.net/manual/en/function.ob-start.php I did some testing on my end and I am getting the same result with both solution. (In reply to Christopher Guindon from comment #7) > I did some testing on my end and I am getting the same result with both > solution. My 2c: let's keep my solution, since it handles the ob explicitly. But I don't have strong opinions about it. (In reply to Denis Roy from comment #8) > (In reply to Christopher Guindon from comment #7) > > I did some testing on my end and I am getting the same result with both > > solution. > > My 2c: let's keep my solution, since it handles the ob explicitly. But I > don't have strong opinions about it. +1 I don't have strong opinion about it as-well since both seems to behave the same! Commit has been changed. Gerrit change https://git.eclipse.org/r/150895 was merged to [master]. Commit: http://git.eclipse.org/c/www.eclipse.org/eclipse.org-common.git/commit/?id=b885a69628cb63222602db069aa8a695f0c033ce *Commit has been merged. |
Created attachment 280070 [details] Error screenshot If a SQL error occurs, I believe there are no no-cache headers, so the error page gets cached by our nginx device for longer than it needs to be. Can we set no-cache headers if there's an SQL error?