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?
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.
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.
I have a form that allows upload three files at the same time but just one is required. That works fine, my only problem is the following: if I upload three files I haven't any problem but if I upload one or two files (leaving two or one files empties) I obtain the following notice:
Notice: No file uploaded in Unknown on line 0
As much as empty files. The files are uploaded properly without any other problem, but I want remove that notice... or unless hide it, although I prefer remove it. I tried to hide it using
error_reporting(0);
and
ini_set('display_errors',0);
but neither of two worked...
It is the first time that I have problem, if someone could lead me I'd be very grateful due to that I am stuck with it.
If you are having the same problem as me, check with phpinfo() if you are using a debug version of PHP. If you see that Debug Build has a value of yes, your problem will be fixed if you install a live version of PHP instead of a debug version
The Error itself is caused by running a Debug version of PHP 7, see the bug report. As noted by HPierce because it was a Debug build it overrides the usual PHP settings for error_reporting. However as the Original question is actually about how to hide certain [expected] error messages (Notices), my answer is to this detail specifically.
Kevin, the attempted ways to hide errors you've listed in your question would normally work on non-debug PHP builds. However, it is unwise to ignore the errors, rather than solving them at source. It's also (more) unwise to hide all errors simply due to having expected errors appearing.
As it's only a Notice, you can work around it by setting your error_reporting() value as below:
//report all errors except notices.
error_reporting(E_ALL & ~E_NOTICE);
I would suggest this is far wiser than turning off error reporting entirely which is not recommended. If you want to stop errors being output to browser (as referenced by Tina) you can use display_errors.
Perhaps you may also need to set
ini_set('error_reporting', 0);
depending on your php ini configuration?
Also make sure you set it before carrying out any of the code.
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 get a TON of these errors when I migrated my WP to a VirtualBox Centos machine:
Undefined variable: rawHTML
Is my PHP not set up correctly? How can I tell? I'm quite lost because most of the site appears to be normal.
I'm migrating from a PHP 5.2 to a 5.3 Centos server.
Additional errors include:
Notice: has_cap was called with an argument that is deprecated since version 2.0!
and
Notice: wp_register_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks.
Any help is greatly appreciated
Possibly that error has always been there, but PHP on the old machine was set to not show errors at Notice level. Compare the values for error_reporting in php.ini on the two machines.
It may also be that now you have display_errors set to on, whereas the old machine sent the to the log file, or didn't report them.