We recently upgraded from PHP 5 to 7.4, and out Pear MBD2 package is spamming our Apache2 log with a bunch of ridiculous notices.
PHP Notice: A non well formed numeric value encountered in /usr/share/php/MDB2/Driver/mysqli.php on line 1154, referer:
Our web apps are working fine, and I know its not best practice at all, but how do we shut this notice up?
Is there any way to configure or upgrade Pear/MDB2 to stop?
Pear and MDB2 was installed via docker image, so I'll have to dig for the exact line where its throwing this.
Any help or wisdom would be appreciated.
This is the line it's throwing an issue over:
$statement_name = sprintf($this->options['statement_format'], $this->phptype, $prep_statement_counter++ . sha1(microtime() + mt_rand()));
To get rid of the notices, disable logging of E_NOTICE messages.
At the beginning of your code, add
error_reporting(error_reporting() & ~E_NOTICE);
.. or disable it in the php.ini configuration file by adjusting the error_reporting setting.
Related
Using
PHP 8.1
Symfony 5.4
Problem
Every symfony command console output is followed by deprecation notice
2022-11-23T22:22:33+01:00 [info] Deprecated: ucfirst(): Passing null to parameter #1 ($string) of type string is deprecated
The problem is I am not using ucfirst anywhere in my project, so it probably is some composer package deprecation. However the deprecation notice does not contain neither the path to a file nor any other clue how it can be found.
How can one track the file / code which triggers this deprecation?
You may want to set error_reporting=E_ALL (not mandatory as you have depreciation notice emitted already) and then log_errors = On and perhaps log_error = syslog and then inspect the log entries in syslog and you should have file and line number which potentially could help you back track the culprit.
Aside from this, it's a depreciation notice and not an error. And since it's not in your code, there's not much you can do beside upgrade your dependencies (incl. Symfony) or disabling E_DEPRECATED notices from being emitted. Again, this is a notice, not an error.
I'm building a TYPO3 based website, where I'm using different extensions from the TER. Now two plugins used together produce undesirable results: PHP Warnings in the rendered Website.
The one extension is tt_products, which causes the messages, by accessing undefined indices in some array. The other extension is tkaddress, which displays the messages.
tkaddress is based on Fluid-Templates, and uses the <f:flashMessages /> view helper to display proper errors, like invalid E-Mail address entered when editing address records.
Unfortunately, otherwise ignored PHP warnings are also caught in this view helper, which gives messages like
PHP Warning: Illegal string offset 'name' in /usr/local/www/apache24/data/typo3conf/ext/tt_products/view/class.tx_ttproducts_info_view.php line 301
This only happens in the live server. In my local development environment I don't get such messages. The verions of both extensions are identical, and I cannot trace the problem down to its root case.
(I know, fixing the bugs in tt_products would be the correct way, but I don't want to modify it)
Is the some setting to suppress PHP Warnings when using <f:flashMessages /> in Fluid?
Update:
Dev-Environment:
TYPO3 6.1.5
PHP 5.3.28
tt_products 2.7.6
error_reporting (PHP INI): 22519
OS: Windows 7
Live-Environment:
TYPO3 6.1.5
PHP 5.4.40
tt_products 2.7.6
error_reporting (PHP INI): 22519
OS: FreeBSD
So only the OS and PHP Version differ. I also couldn't find a difference in PHP or TYPO3 related error reporting settings (both have displayErrors set to 1)
The PHP version seems to be causing the described difference between your dev- environment and production environment. I quote;
How do I correct this Illegal String Offset?
However, this warning message is new to PHP 5.4. Old versions didn't
warn if this happened. They would silently convert 'type' to 0, then
try to get character 0 (the first character) of the string. So if this
code was supposed to work, that's because abusing a string like this
didn't cause any complaints on PHP 5.3 and below. (A lot of old PHP
code has experienced this problem after upgrading.)
tt_products
It seems that you're using tt_products version 2.7.6.
Since version 2.7.6 there were a couple of bug fixes, including some code changes inside the file class.tx_ttproducts_info_view.php which may fix your problem as well.
Try updating tt_products to version 2.7.17, see:
http://typo3.org/extensions/repository/view/tt_products
If the problem still occurs in a more recent version of the extension you can submit your issue on:
https://forge.typo3.org/projects/extension-tt_products
Suppress warnings
However ignoring any warning isn't the right way you may look at:
TYPO3: how to supress deprecated warnings?
CodeIgniter 2.x still uses the classic mysql. We all know it's bad practice to still use it, but my job still requires me to use CodeIgniter.
I always have my Console.app (OSX) open watching my Apache/MySQL/PHP/CodeIgniter-native error logs.
Now I mostly have all notices/errors/etc. fixed always instantly when I see them and constantly monitor my development with Webgrind on my MAMP.
Back to the start; I constantly have one big annoying thing each page-load PHP always gives the error about mysql_pconnect is going to get deprecated in the future.
In the CodeIgniter driver the command is suppressed by # to not print the warnings to the screen, but it still ends up in my logs.
Is there any viable way to except one such error specifically in either PHP code or the PHP settings?
Locally I could recompile the whole PHP core and just remove the warning, but I would like to have the logs on our production installations rid of those warnings too :P.
Thanks in advance!
Traditionally, you can use set error verbosity using error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED) (i.e., report everything—except notices and deprecation warnings) as mentioned in "disabling deprecated errors".
Your issue may be related to CodeIgniter taking ownership of all errors.
system/core/CodeIgniter.php calls the function set_error_handler. You can find and modify the function _exception_handler it invokes on error in system/core/Common.php. It doesn't appear to be a configurable, so you may simply want to edit the line that begins with $is_error.
I am using WAMP (Apache 2.2.17, PHP 5.4.3) & WordPress 3.4.2.
Everything was fine until I started to add and activate plugins now I get different sort of errors on the front-end/Admin e.g.
"Notice: Undefined index: plugin_version in
C:\repo\wpdev\wp-content\plugins\wp-rss-multi-importer\inc\upgrade.php
on line 11"
And
"Warning: Illegal string offset 'feedslug' in
C:\repo\wpdev\wp-content\plugins\wp-rss-multi-importer\inc\rss_feed.php
on line 21."
IF I deactivate the plugins everything seems to be fine. I have installed WAMP & WP 2X. The plugins work fine on MediaTemple. The error messages vary depending on the plugins. Search Google and came up empty.
These are Notices and Warnings, which optionally show up depending on your PHP error reporting settings. Find your php.ini and set the following:
error_reporting = E_ALL & ~E_NOTICE
Note, you can find your php.ini location using the phpinfo(); function.
According to the author of the plugin you are using, while waiting for an update you can get rid of that error by commenting out these lines in inc/rss_feed.php, e.g.
//if (!empty($feed_options)){
//add_feed($feed_options['feedslug'], 'rssmi_feed');
//}
When I developed a website on my localserver it was working fine.
Now that I've uploaded it live I'm getting several notices.
Notice: Undefined index: ... on line 14
I've figured out that it happens because I'm using variables which arn't defined, and would like to go through and fix it. But I need a live version working tonight.
Is it possible to suppress the Notices and have the website act as it does on my localhost while its on my live server?
You've got it twice wrong. On your localhost and on your live server!
Localhost
Always show everything on screen, you want to know about notices too before you go live, as you can see now!
Live server
Never show anything on screen, it makes you vulnerable (it's deadly)
Log everything, also notices! So don't do what the other answers tell you!
You can choose which kind of errors will show up on your site on a global scale through php.ini or through .htaccess for specific folders, or per script by using error_reporting().
Read more on that and which options to set for your specific needs at www.php.net/manual/en/function.error-reporting.php
Also read: http://www.php.net/error-reporting
Look in the file php.ini for a line similar to error_reporting = E_STRICT - Edit it to remove the STRICT bit and put in error_reporting = E_ERROR.
I would recommend that in the near future that you fix those errors anyway.