Frank_Picabia Posted August 30, 2023 Share Posted August 30, 2023 We already know why there are deprecated PHP warnings while running an old piece of code under PHP 8.0 The PHP code with legacy issues will be updated by someone new about to be hired. For now, we just want php being run out of a cron to use the settings we have in php.ini: error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT This isn't working. Every time the cron runs, it will email the deprecated warning. * * * * * php /usr/local/cron.php >> /usr/local/cron.log Someone claimed in an online forum that for PHP run at the command line, as it would be for a cron, it doesn't have this control over error reporting. I don't know if that is accurate. As a solution for the time being, I've added 2>&1 >> /dev/null to the end of the cron line. But it would be better to use the php error_reporting preference if we could. Quote Link to comment https://forums.phpfreaks.com/topic/317232-how-to-suppress-output-from-php-on-cli-while-deprecated-warnings-are-printed/ Share on other sites More sharing options...
requinix Posted August 30, 2023 Share Posted August 30, 2023 How many php.ini files do you have? Did you edit the right one? Use phpinfo or php -i to see which file it's using. Quote Link to comment https://forums.phpfreaks.com/topic/317232-how-to-suppress-output-from-php-on-cli-while-deprecated-warnings-are-printed/#findComment-1611489 Share on other sites More sharing options...
Frank_Picabia Posted August 30, 2023 Author Share Posted August 30, 2023 Thanks for the response. It's a Redhat Linux 8 system. There's a good number of ini files, but /etc/php.ini contains the line: error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT while grep -r error_report /etc/php.d produces no results. Quote Link to comment https://forums.phpfreaks.com/topic/317232-how-to-suppress-output-from-php-on-cli-while-deprecated-warnings-are-printed/#findComment-1611492 Share on other sites More sharing options...
requinix Posted August 30, 2023 Share Posted August 30, 2023 And php -i says (at the top) that it's reading /etc/php.ini? What number is it showing for the error_reporting setting? You can figure out the meaning using this page (you're looking for 22527). Quote Link to comment https://forums.phpfreaks.com/topic/317232-how-to-suppress-output-from-php-on-cli-while-deprecated-warnings-are-printed/#findComment-1611493 Share on other sites More sharing options...
Frank_Picabia Posted August 31, 2023 Author Share Posted August 31, 2023 Hi, I'm getting an answer from "php-i | grep error" , and seeing this error_reporting => 22527 => 22527 But you said it should be this? I suppose if one adds up all those binary codes it comes to this? Quote Link to comment https://forums.phpfreaks.com/topic/317232-how-to-suppress-output-from-php-on-cli-while-deprecated-warnings-are-printed/#findComment-1611501 Share on other sites More sharing options...
requinix Posted August 31, 2023 Share Posted August 31, 2023 Then it's correct. You can be even more sure by outputting the error_reporting() value in code. What's the actual and full deprecation message? And have you searched the code itself to see if anything changes the error_reporting value at runtime? Quote Link to comment https://forums.phpfreaks.com/topic/317232-how-to-suppress-output-from-php-on-cli-while-deprecated-warnings-are-printed/#findComment-1611513 Share on other sites More sharing options...
Frank_Picabia Posted September 26, 2023 Author Share Posted September 26, 2023 We never did find a solution to controlling the deprecation notices in PHP 8.0. In the meantime, it was found we had a requirement to run the site on PHP 7.4 until some of the legacy pieces can be updated by the application administrator. Quote Link to comment https://forums.phpfreaks.com/topic/317232-how-to-suppress-output-from-php-on-cli-while-deprecated-warnings-are-printed/#findComment-1612123 Share on other sites More sharing options...
MaksOs Posted December 15, 2023 Share Posted December 15, 2023 Oh, if you do find a solution, let us know, it's very interesting to find out Quote Link to comment https://forums.phpfreaks.com/topic/317232-how-to-suppress-output-from-php-on-cli-while-deprecated-warnings-are-printed/#findComment-1613547 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.