Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED Stop PHP Error Notices and Warnings from being logged?

Discussion in 'EasyApache' started by verdon, Jul 31, 2018.

  1. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    868
    Likes Received:
    3
    Trophy Points:
    168
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    Hello,

    I'm confused about configuring php error_reporting. I'm essentially using the stock configurations for php7 and php 5.6 in EA 4. Logging is happening and going to where I would expect it too, but it is very noisy.

    This is what I have configured
    Code:
    error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING
    and yet the error_log files are getting filled with lines like
    Code:
    PHP Notice:  Trying to get property of non-object in /home/username/public_html/wp-content/plugins/iwp-client/stats.class.php on line 441
    
    How can I stop the Notices and Warnings from being logged?
     
  2. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    729
    Likes Received:
    248
    Trophy Points:
    93
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    You could try some of the suggestions here:

    ecenica.com/support/answer/disable-php-error-logs/

    I probably wouldn't use the php.ini method - I think you would need to research if it was still an acceptable method to use.

    If you have the PHP Manager available in cPanel, you may be able to edit the php.ini file as described in :

    How to Edit Your php.ini File - cPanel Knowledge Base - cPanel Documentation
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    #2 rpvw, Jul 31, 2018
    Last edited by a moderator: Jul 31, 2018
  3. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    868
    Likes Received:
    3
    Trophy Points:
    168
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    @rpvw

    Thanks. I appreciate the reply. Problem is, I don't want to turn logging off, I just want to suppress PHP Notices and Warnings. I still want to log errors. I know how to edit my global (and any local) php.ini files. The issue is I believe I have the correct string for what I want logged globally, it just seems that it is being ignored.

    These values
    Code:
    ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING
    
    should be directing to not log notices, deprecated functions, strict messages or warnings, yet they appear to be getting logged.
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,367
    Likes Received:
    1,857
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello @verdon,

    Can you verify which PHP handler is enabled for the version of PHP you are modifying that setting on? Is PHP-FPM enabled on the accounts you are testing with?

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    868
    Likes Received:
    3
    Trophy Points:
    168
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    Hi @cPanelMichael

    No. suphp on ea-php56 and ea-php70. ea-php70 is the default and used on most accounts. There are a couple of accounts on the server still using 5.6. PHP-FPM is not enabled at all.

    And here's some typical lines in an error_log file
    Code:
    [31-Jul-2018 19:04:08 UTC] PHP Warning:  Declaration of theme_navigation::update() should be compatible with WP_Widget::update($new_instance, $old_instance) in /home/username/public_html/wp-content/plugins/child-page-navigation/child-page-navigation.php on line 85
    [31-Jul-2018 19:04:09 UTC] PHP Warning:  Declaration of theme_navigation::update() should be compatible with WP_Widget::update($new_instance, $old_instance) in /home/username/public_html/wp-content/plugins/child-page-navigation/child-page-navigation.php on line 85
    [31-Jul-2018 19:04:09 UTC] PHP Warning:  Declaration of theme_navigation::update() should be compatible with WP_Widget::update($new_instance, $old_instance) in /home/username/public_html/wp-content/plugins/child-page-navigation/child-page-navigation.php on line 85
    [31-Jul-2018 19:04:09 UTC] PHP Warning:  Declaration of theme_navigation::update() should be compatible with WP_Widget::update($new_instance, $old_instance) in /home/username/public_html/wp-content/plugins/child-page-navigation/child-page-navigation.php on line 85
    [31-Jul-2018 19:04:10 UTC] PHP Warning:  Declaration of theme_navigation::update() should be compatible with WP_Widget::update($new_instance, $old_instance) in /home/username/public_html/wp-content/plugins/child-page-navigation/child-page-navigation.php on line 85
    
    
     
    #5 verdon, Jul 31, 2018
    Last edited: Jul 31, 2018
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,367
    Likes Received:
    1,857
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Can you let us know the output upon running the commands below?

    Code:
    grep error_reporting /opt/cpanel/ea-php70/root/etc/php.ini
    /opt/cpanel/ea-php70/root/usr/bin/php -i|grep error_reporting
    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    868
    Likes Received:
    3
    Trophy Points:
    168
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    @cPanelMichael
    Thanks

    Code:
    # grep error_reporting /opt/cpanel/ea-php70/root/etc/php.ini
    ; error_reporting
    error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING
    ; Eval the expression with current error_reporting().  Set to true if you want
    ; error_reporting(0) around the eval().
    
    Code:
    # /opt/cpanel/ea-php70/root/usr/bin/php -i|grep error_reporting
    error_reporting => 22517 => 22517
    
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,367
    Likes Received:
    1,857
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello @verdon,

    Can you open a support ticket so we can take a closer look at the affected system to see what's happening? You can post the ticket number here and we will link this thread to it.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    868
    Likes Received:
    3
    Trophy Points:
    168
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
  10. verdon

    verdon Well-Known Member

    Joined:
    Nov 1, 2003
    Messages:
    868
    Likes Received:
    3
    Trophy Points:
    168
    Location:
    Northern Ontario, Canada
    cPanel Access Level:
    Root Administrator
    RESOLVED.

    To follow up on this, I am grateful to cPanel support (and a little embarrassed for not thinking of it myself). It was determined that several Wordpress and WP Plugin scripts, in most accounts on the server, were actually resetting the value for 'error_reporting'. Since almost every account on the server has the same combination of WP and plugins, it seemed systematic.

    So, nothing at all to do with my basic Apache/PHP/EA configuration. From the googling I am doing, this may be harder to stop than it should be. It's easy to control that within .htaccess directives, but apparently not so much within actual scripts. Time for more reading :) It may be in the end that I just use a cron task to purge error_log files from time-to-time.
     
  11. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,367
    Likes Received:
    1,857
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello @verdon,

    I'm glad to see you were able to determine the cause of the issue. Thank you for sharing the outcome.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice