[aur-dev] Output buffering and header() usage
Trying to reproduce FS#24580 [1] I stumbled upon a design flaw that apparently remained concealed for a long time due to a series of (un-)fortunate circumstances. Short summary of the bug report for reference: A package search currently seems to erroneously return an empty search result, if * Russian language is selected AND * there's no active session (the user is logged off) AND * a search term that would normally return a single package is used. Without going into details, I was surprisingly able to reproduce that. The cause seems to be the usage of header() to redirect to the package details page in case of single search results, where the HTML header and some more stuff has already been printed out. Due to PHP's output buffering being enabled by default with a buffer size of 4096 this only comes into effect in some corner cases, tho (coincidentally, most setups seem to result in header output with a size of just below 4kiB). Reducing PHP's "output_buffering" setting locally, I was able to reproduce that bug with other configurations as well. Some possible solutions/workarounds that came into my mind: * Use javascript redirects instead. * Just buffer output everywhere (ob_start(), ob_flush()). * Rewrite package search to retrieve package search results before even printing out anything. Thoughts? I tend to prefer the latter, cause it seems to be the only clean way (and the MVC way) of doing this. [1] https://bugs.archlinux.org/task/24580
On Tue, Jun 21, 2011 at 11:11 AM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
Some possible solutions/workarounds that came into my mind:
* Use javascript redirects instead.
* Just buffer output everywhere (ob_start(), ob_flush()).
* Rewrite package search to retrieve package search results before even printing out anything.
Thoughts? I tend to prefer the latter, cause it seems to be the only clean way (and the MVC way) of doing this.
"Don't automatically redirect" is actually what I just did. Not because archweb had the bug, but I was finding the behavior annoying, and at least in the case where a package may or may not be in testing, sometimes the redirect happens while other times it doesn't. However, if you are going to do anything, I'd say package search itself should be refactored off into some library code, and once you get the results back you can actually start thinking about what to do with them. -Dan [1] http://projects.archlinux.org/archweb.git/commit/?id=00eb8f426a8ddb905fcf8b2...
On Tue, Jun 21, 2011 at 9:19 AM, Dan McGee <dpmcgee@gmail.com> wrote:
On Tue, Jun 21, 2011 at 11:11 AM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
Some possible solutions/workarounds that came into my mind:
* Use javascript redirects instead.
* Just buffer output everywhere (ob_start(), ob_flush()).
* Rewrite package search to retrieve package search results before even printing out anything.
Thoughts? I tend to prefer the latter, cause it seems to be the only clean way (and the MVC way) of doing this.
"Don't automatically redirect" is actually what I just did. Not because archweb had the bug, but I was finding the behavior annoying, and at least in the case where a package may or may not be in testing, sometimes the redirect happens while other times it doesn't.
However, if you are going to do anything, I'd say package search itself should be refactored off into some library code, and once you get the results back you can actually start thinking about what to do with them.
I agree with Dan, and would like to additionally go on record as firmly against redirecting with javascript.
On Tue, Jun 21, 2011 at 11:19:29AM -0500, Dan McGee wrote:
On Tue, Jun 21, 2011 at 11:11 AM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
Some possible solutions/workarounds that came into my mind:
* Use javascript redirects instead.
* Just buffer output everywhere (ob_start(), ob_flush()).
* Rewrite package search to retrieve package search results before even printing out anything.
Thoughts? I tend to prefer the latter, cause it seems to be the only clean way (and the MVC way) of doing this.
"Don't automatically redirect" is actually what I just did. Not because archweb had the bug, but I was finding the behavior annoying, and at least in the case where a package may or may not be in testing, sometimes the redirect happens while other times it doesn't.
Good point. Just fixed that [1]. Thanks! [1] http://projects.archlinux.org/aur.git/commit/?id=0e9f8c0f
participants (3)
-
Dan McGee
-
elij
-
Lukas Fleischer