stnvh / php-partialzip

Download files located within remote ZIP files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Refactor error handling

stnvh opened this issue · comments

Remove use of ob_flush() as suppression of all output is pretty bad practice

@hempalex

Addressed in 0.1.5

I think you should remove ob_start/ob_flush because it's a library.

If somebody use, for example, a logging to console - it will be suppressed as well. I think you should suppress messages by using @ or some checking

Just so you understand my reasoning for this, the error messages are suppressed only when the output directly to browser option is used, added for convenience. pre-0.1.5, all output was cleared each time a file header was formatted, which was accidental.

It's better practice to leave it up to the user to handle any output before running get() so I'll promptly remove usage of ob_start/clean.

It also seems replacing user_error with throw case makes more sense too, reopening.

Yes, I think you should only document the need for clean output buffer before using "get" method.

I think in a library you should avoid any unwanted side-effects, like output buffering/cleaning or unexpected exits/dies.

For example - enabled output buffering made me surprised then I tried to print some debug (while importing several hundred of jpeg from 2Gb remote zip).

I'd be much more surprised if I got an unexpected exit after some errors :)

Fixed in 0.1.6

Thank you!