Disable deprecated warning

8 posts by 2 authors in: Forums > CMS Builder
Last Post: November 22   (RSS)

By kitsguru - November 16

Within CMSB backend and viewer I want to disable Deprecated warnings. What is the best way to do this?

Jeff Shields

By Dave - November 16

Hi Jeff, 

Can you give some more details, are they showing up in the page or in the Developer Log? 

Also, be aware that future versions of PHP may turn deprecated warnings into errors and/or remove the features..   

Dave Edis - Senior Developer
interactivetools.com

By kitsguru - November 16

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
Jeff Shields

By kitsguru - November 17

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.

Jeff Shields

By Dave - November 20

Hi Jeff, 

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: 
<?php
echo "Current PHP error_reporting level: ".error_reporting();
exit;
?>
  • 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.

Thanks!

Dave Edis - Senior Developer
interactivetools.com

By kitsguru - November 20

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.

Jeff Shields

By Dave - November 22

Hi Jeff, 

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.

Thanks!

Dave Edis - Senior Developer
interactivetools.com