Disable deprecated warning
They show on the page and the log. I use several composer libraries for symphony/twig, symphony/yaml and others. They have deprecated warnings, which I do not care about.
I do not need to see this on the page at any time - either development or production. I have edited the ini file on my development machine
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
Okay, you can disable the logging completely by editing /lib/errorlog_functions.php and setting this to false:
$enableLogging = true;
Otherwise, if you can let me know which version of PHP you're using and an example of the deprecated errors you're getting I can look into it. I tried to recreate a few deprecated errors but I don't think I was able to replicate the situation.
Actually what I was thinking was more along the lines of checkboxes to turn on and off the different error flags.
My app uses CMSB viewer functions which traps all errors whether generated by CMSB or other libraries. The deprecated errors are not necessarily CMSB in origin.
Instead of editing the ini files, htacess or the code base. I would like to be able to enable/disable each of the flags via the Security Panel in CMSB.
I use cypress.io for end to end testing. On the first run after updating any ot the libraries I woiuld want all errors detected. After that I am testing the UI, html validity, accessibility via AXE and broken links. For these tests I do not need deprecated messages as they interfer with the results.
We're catching ALL errors with these PHP functions in /lib/errorlog_functions:
// setup handlers
set_error_handler('_errorlog_catchRuntimeErrors'); // for php errors
set_exception_handler('_errorlog_catchUncaughtExceptions'); // for exceptions
register_shutdown_function('_errorlog_catchFatalErrors'); // for uncaught fatal errors
And it's basically all or nothing so we'd need to add code in the handler functions.
We can add a checkbox to disable logging and display of deprecated and strict errors, which would match the php.ini recommendation for production sites. The issue is that we don't always have control of what php.ini has error_reporting set to before the script runs. So sometimes those errors will get thrown as fatal parse errors before the PHP even runs.
With my test deprecated errors I either got a fatal parse error before php ran, or an ignored error, but wasn't able to recreate an error that got logged or displayed.
Can you confirm the following for me so I can look into it further:
- What PHP version are you running?
- What is error_reporting set to on your server? Run this isolated PHP script:
echo "Current PHP error_reporting level: ".error_reporting();
- Do you have some examples of deprecated errors that are being displayed or logged that I can use to reproduce the issue locally?
Let me know that info and I can research further.
I run multiple versions of php depending on the client, from version 7.4 to 8.1.
On my development machine (Mac Mini M2 Pro) Sonoma 14.1.1 I use 'sphp switcher' to change versions. I test across all versions.
On production, I want errors logged except for deprecated warnings. In development, I want to control which errors I see.
As I mentioned, the deprecated warnings are not from CMSB directly but from composer-installed libraries, but CMSB still traps them. These are not issues I can address directly and I don't need to get emails on them or fill up the log.
Can you forward some of the error logs to me via email and/or send me a login (via email)? I need to recreate the errors so I can work on it. It doesn't matter if there from composer libraries, we just need to recreate them one way or another.