Skip to content
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

sorely missing option to change error reporting mode during code execution #135

Open
subpardaemon opened this issue Nov 21, 2016 · 0 comments

Comments

@subpardaemon
Copy link

hi,

just jump to the tl;dr part for the actual problem.

lately i've ran into a problem where an external package that is vital for our services started spewing deprecation warnings like there is no tomorrow.

i was told that until there is a fix (which they're working on now) i should just turn off deprecation warnings.

i'm using phpconsole, and namely, in the old compatibility mode (hadn't had time to update all my dependent codes to the new version). i'm also a very pickish person when it comes to errors, so i like to see all errors (notices, warnings, deprecations, etc) reported. that is one of the reasons why i love phpconsole.

so the obvious solution not to crash my system (i'd had the system run out of allowed memory because of the sheer number of deprecation warnings) is to turn off deprecation warnings ONLY if the execution requires the external package (which is like 10% of the time, but then it's vital -- it's a payment interface). of course, setting error_reporting(..) never worked as by that time phpconsole's internal settings were in effect.

after a bit of investigation, i've arrived at this solution:

TL;DR

to change error reporting level mid-execution, i'd do

PhpConsole::getInstance()->getHandler()->setErrorsHandlerLevel(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);

and i was rewarded with a nice little exception saying that i need to set it BEFORE initialising phpconsole. haha. which is of course impossible because at that point in the code i have no idea whether i need to run the troublesome extension or not.

so i changed line 138 in Handler.php to comment out
$this->checkIsCalledBeforeStart();
and now everything works as expected.

question: why not skip this condition check altogether? is there a reason why it's so bad to change error reporting level mid-run?

thanks,a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant