[aur-dev] Output buffering and header() usage
Lukas Fleischer
archlinux at cryptocrack.de
Tue Jun 21 12:11:49 EDT 2011
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
More information about the aur-dev
mailing list