I have installed a fresh new Typo3 installation.
I have Windows 7 and use Apache 2.4
PHP 5.6.11 with Zend Engine 2.6.0 and with Xdebug v2.3.3.
Typo3 uses their own error handler so it is possible to control the error levels in the configuration file. However the mysqli still throws warnings for mysqli::init() and mysqli::stmt_init(). In both cases the error are
PHP Warning: mysqli::stmt_init(): Property access is not allowed yet in W:\typo3\sysext\core\Classes\Database\DatabaseConnection.php on line 782
PHP Warning: mysqli_init(): Property access is not allowed yet in W:\typo3\sysext\core\Classes\Database\DatabaseConnection.php line 1190
I have tried to read the thread mysqli + xdebug breakpoint after closing statment result in many warnings but it seems the warning is related to some bugs in mysqli. As what I read these bugs should be resolved.
Since these errors comes from the core of Typo3 I think it will be foolish to edit in the DatabaseConnection.php file.
However, I have tested my connection using mysqli::__construct instead of mysqli_init(). mysqli::__construct does not throw any warnings/errors. http://php.net/manual/en/mysqli.construct.php
In typo3conf/LocalConfiguration.php I have set errorHandlerErrors and exceptionalErrors to 30965 instead of 30466 such that Typo3 does not trows an exception for warnings. This only solved the problem for mysqli_init() - not stmt_init().
So what can I do?
The problem is solved by set the error reporting level to E_ALL except E_STRICT in php.ini.
That is because the built in error handler in Typo3 is more sensitive that default error handler.
error_reporting(E_ALL ^ E_STRICT);
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 using NGINX with PHP-FPM in seperated Docker containers. I want to get errors only to stderr, so that I can collect them on a centralized log-server. Problem is: I'm using WP and seems to have some not well written plugins. They work but cause warnings like this:
2017/06/17 01:16:08 [error] 7#7: *1 FastCGI sent in stderr: "PHP
message: PHP Warning: Parameter 1 to wp_default_scripts() expected to
be a reference, value given in /www/wp-includes/plugin.php on line 601
Example script for testing, which should give me a fatal error in the stderr:
<?php
not_existing_func();
PHP-FPM was configured to log errors to stderr like this:
[global]
log_level = error
error_log = /proc/self/fd/2
I'm wondering that this gave me nothing in the script above. Just after I switched the log_level to at least notice, I got the exception on the console of the docker container:
[17-Jun-2017 01:45:35] WARNING: [pool www] child 8 said into stderr:
"NOTICE: PHP message: PHP Fatal error: Uncaught Error: Call to
undefined function not_existing_func() in /www/x.php:2"
Why the hell is this a notice? For me we've clearly a fatal error here like the message indicates, cause the script can't continue (and we get a 500 error in the browser, of course). It can't be true that I have to set log_level to notice so that I don't miss fatal errors which are delcared as warnings. And simultaneously, my logs get filled with trash warnings from wordpress themes, plugins and so on, that I haven't developed and I don't want to fix for update reasons...
I tried a bit and found out that log_errors in php.ini is essential for PHP-FPM to get any information. But the log level from error_reporting seems wired too. For testing purpose, I used the following configuration:
display_errors = Off
log_errors = On
error_log = /proc/self/fd/2
;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
error_reporting = 0
Result: I got notices, but NO info about my fatal error...
First of all, I learned that I was wrong: Wordpress is the root cause for this issue, not PHP directly. It's a known fact that WP manipulates the error_reporting when debugging is enabled, so I tried to define WP_DEBUG as false in my config; BUT even having this set, the documentation says
[...]
Except for 'error_reporting', WordPress will set this to 4983 if WP_DEBUG is defined as false.
[...]
So my settings into php.ini were correct and sufficient. I don't even need the php-fpm settings, when errors are redirected to stdout in the php.ini file.
How to prevent WordPress from manipulating the error reporting?
This is not so easy, too. Although the WordPress documentation says, that the wp-config.php is a good place to set global wide settings like the error reporting, they got overwritten later to 4983. I don't know where; maybe it's not even the Core of Wordpress, but rather some poor developed plugin or theme.
We can handle this by adding error_reporting to the disabled functions:
disable_functions = error_reporting
Now it's not possible to overwrite our error_reporting. I think this is the best solution to make sure that we don't get any other error reporting by external influence from plugins or themes. Also in the future, since PHP allows such chaos, we need to reckon with such things.
Basically, we could criticize that this prevent us from getting more logs by setting WP_DEBUG to true, that's right, but as we're on a production system, it seems wrong for me to do troubleshooting in such a way there. We shouldn't do this on an application base, especially without display_errors! Instead, the workflow to find problems should be to look at the error logs.
Fatal errors should always be logged and checked on a regular basis. If that is not enough, error_reporting could be set on a higher level to get information about possible problems like warnings.
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.
Anyone knows how to solve the error below?
Deprecated: Function ereg() is deprecated in C:\wamp\www\includes\file.inc on line 895
It is happening after installing Drupal 6.13 on wamp server 2.0i with PHP 5.3.0
Use
preg_match('/\.([^\.]*$)/', $this->file_src_name, $extension);
Instead of
ereg('\.([^\.]*$)', $this->file_src_name, $extension);
Drop your error reporting level below E_DEPRECATED.
PHP 5.3 introduced two new error reporting levels, E_DEPRECATED and E_USER_DEPRECATED and - for the first time in PHP's history - they've started to walk away from older parts of their API. The ereg_* function will still work, but this warning is intended to let you know that "hey, these function will be going away soon, probably in the next major revision).
Just add # in front of the function. e.g.
#ereg()
more issue relating upgraded your web servers which running PHP 5.3.0, pls refer
http://www.rain-forest-forum.com/dotproject-net-installation-issues-t263.html
This is not a Drupal issue.In the Drupal site it is noted that it does not yet support PHP 5.3 and there have been new error flags added to PHP.
Solution1 : You can degarde the PHP version.You can revert back to PHP 5.2.x. As I am unsure of other conflicts with Drupal and PHP 5.3.
Solution2 : However, if you prefer to keep PHP 5.3, you can always suppress the deprecated function errors. In Drupal’s includes/common.inc,
Find the line :
if ($errno & (E_ALL ^ E_NOTICE)) {
And replace it with:
if ($errno & (E_ALL & ~E_NOTICE & ~E_DEPRECATED)) {
This will now always suppress the Deprecated error messages.
One solution is to upgrade the offending sourcecode :-)
It's explained here: http://drupal.org/node/514334#comment-2852940
You can edit you common.inc file to quietly disregard the deprecated error flags. See my post:
http://funkinetics.org/klink/function-ereg-is-deprecated-error-in-drupal-6x-with-php-53/
Looks like the problem is with PHP 5.3.0. You could try downgrading to 5.2.9 as suggested by this drupal link: http://drupal.org/node/514334
Because I don't have time to update legacy code, I addeded following line to php code to suppress warnings.
error_reporting(E_ALL ^ E_DEPRECATED);
this line suppress only deprecated warnings. other errors are shown as usual.