Disable Xdebugstack trace in apache error.log without disabling Xdebug - php

I recently installed xdebug, and now stack traces are printed to my apache error.log:
PHP Fatal error: Call to a member function get_upload() on null in /var/www/html/template/user/post-single.php on line 10
PHP Stack trace:
PHP 1. {main}() /var/www/html/index.php:0
PHP 2. include() /var/www/html/index.php:19
I dont like them, as they clutter my log, and if i need them i will get them from my debugging client. Is there any way i can disable them?
EDIT: To be clear, i do not want to disable Xdebug, I just want it to not print the stack traces.

Related

PHP error dump message are truncated to 5 characters only

PROBLEM: Error dump messages are truncated to 5 characters only.
In the following example it is 'Canno'
[07-Nov-2022 23:42:06 Europe/Berlin] PHP Fatal error: Canno in /httpdocs/includes/Database.php on line 570
[07-Nov-2022 23:42:06 Europe/Berlin] PHP Stack trace:
[07-Nov-2022 23:42:06 Europe/Berlin] PHP 1. {main}() /httpdocs/home.php:0
[07-Nov-2022 23:42:06 Europe/Berlin] PHP 2. require_once() /httpdocs/home.php:4
[07-Nov-2022 23:42:06 Europe/Berlin] PHP 3. require_once() /httpdocs/includes/master.inc.php:61
P.S. the question is NOT about the PHP error, but about the SIZE of the error message itself. In some cases it is 3 chars only in others - 5.
No more, no less.
Yes, it happened on
client's server
local machine, Apache, php 5.6.
Yes, I immediately checked the php.ini settings for log-errors-max-len or any other trace of incnsistency, but found no problems at all.
An idiot programmer put a ini_set("log_errors_max_len", 3); message in one of major include files....somewhere in the middle of the file....and ini_set("log_errors_max_len", 5); in another.
I found it, when explicitly started to eliminate gazillion of includes. And in some cases received 3char messages , while some others gave 5 chars.

How to attach stack trace to error log messages in PHP?

I run multiple WordPress sites which have multiple themes and plugins from multiple different authors. I always check my error log and try to contact the authors to fix bugs in their code, but a lot of them are logged as something like:
PHP Deprecated: wpmu_new_blog is <strong>deprecated</strong> since version 5.1.0! Use wp_insert_site instead. in /wp-includes/functions.php on line 5148
PHP Warning: array_merge(): Argument #3 is not an array in /wp-includes/class-wp-customize-widgets.php on line 376
PHP Warning: Error while sending QUERY packet. PID=23688 in /wp-includes/wp-db.php on line 2033
PHP Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /wp-includes/wp-db.php on line 1635
As you can see, the warnings occurred in files inside wp-include, which are available to all plugin/theme/core authors, so there is no way for me to find out who called the deprecated function, passed the wrong function parameters or whatever they did.
I also cannot easily reproduce the error in a dev environment because I don't know what action triggered it.
Everything would be much easier if I could change some PHP (or even server) setting that would cause a stack trace to be appended to each error log message.
This is one of those things that, as common as my problem probably is, Google is unhelpful because all search results try to explain how to append the stack trace to my own code, not to anyone's code.
You could install the Xdebug extension to PHP, which overrides the error logging mechanism of PHP and adds stack traces to errors, warnings, etc. when enabled. See Xdebug documentation.

Duplicate entries in PHP error_log using set_exception_handler

I cannot seem to locate the source of this issue. I actually have nearly the same Docker container and Exception handler lib running in another app. However, for some reason, I'm getting duplicate log entries in the error log file.
The issue is that it's not just duplicate entries that are the same (that'd be another interesting issue). It's the same Exception being logged and the same stack trace, but one is from my custom Exception handler (JSON), and the other is the default PHP error log handler (or so it seems - tested with CLI SAPI as well as PHP-FPM).
I was under the assumption that PHP wouldn't write to the log file if an exception handler was set. I'm also executing die(1) at the end of the callback function for the Exception handler.
Again, all of the Exception handling code seems to be working well. It's just that PHP is still logging the Exception. Is there a setting or something else that I'm missing here needing to be done on the PHP config side?
Below is a copy of the error log output:
[24-Nov-2018 02:20:11 UTC] PHP Exception: Testing in /srv/www/boot/common.php on line 65
[24-Nov-2018 02:20:11 UTC] PHP Stack trace:
[24-Nov-2018 02:20:11 UTC] PHP 1. {main}() /srv/www/public/index.php:0
[24-Nov-2018 02:20:11 UTC] PHP 2. require() /srv/www/public/index.php:13
{"timestamp":"2018-11-24 02:20:11 UTC","level":"critical","message":"Testing","app_version":{},"environment":"dev","class":"Exception","file":"\/srv\/www\/boot\/common.php","line":65,"code":0,"previous":null,"trace":[{"file":"\/srv\/www\/public\/index.php","line":13,"function":"require"}],"user":[],"tags":[],"extra":[],"output_buffers":[]}
Going to leave this here for anyone that might come across this. The issue turned out to be XDebug which hijacks your Exceptions. It was enabled on this particular app in our dev env.

php_mysql is disabled so why am I still getting the mysql_connect() error?

I am working with IIS. I just upgraded php from 5.2 to 7.0. Unfortunately, I'm getting the WSOD. However, the WSOD happens inside my dashboard area and not on the home page (I'm on a multisite installation, by the way).
I added the necessary lines in my php.ini file to get the errors to show and this is what came up on the white screen:
"Uncaught Error: Call to undefined function mysql_connect() in E:\inetpub\fcpsblogs\wp\wordpress\wp-includes\wp-db.php:1564
Stack trace:
`#0 E:\inetpub\fcpsblogs\wp\wordpress\wp-includes\wp-db.php(592): wpdb->db_connect()
`#1 E:\inetpub\fcpsblogs\wp\wordpress\wp-includes\load.php(404): wpdb->__construct('[username]', '[password]', 'wp', 'localhost:3307')
`#2 E:\inetpub\fcpsblogs\wp\wordpress\wp-settings.php(106): require_wp_db()
`#3 E:\inetpub\fcpsblogs\wp\wordpress\wp-config.php(124): require_once('E:\inetpub\fcps...')
`#4 E:\inetpub\fcpsblogs\wp\wordpress\wp-load.php(37): require_once('E:\inetpub\fcps...')
`#5 E:\inetpub\fcpsblogs\wp\wordpress\wp-admin\admin.php(31): require_once('E:\inetpub\fcps...')
`#6 E:\inetpub\fcpsblogs\wp\wordpress\wp-admin\index.php(10): require_once('E:\inetpub\fcps...')
`#7 {main} thrown in E:\inetpub\fcpsblogs\wp\wordpress\wp-includes\wp-db.php on line 1564"
(all minus the tick marks at the beginning of each line. I added those so that the pound symbol can show)
So I researched the error and it said that WP was thorwing this because I was using php_mysql as opposed to php_mysqli. I searched high and low and I cannot find where php_mysql is. I believe it's disabled everywhere. There's not even a reference to it in my php.ini file. Can anyone tell me where else I can check so that I can get past this issue?

xdebug is not showing the full stack trace

If I throw an exception somewhere deep in my php code, it is printed by xdebug in front with this default orange layout, if you know what i mean. Problem is, that the call stack or stack trace there is too short. It shows only the first 5 steps.
If I catch the exception directly after throwing and print the ->xdebug_message variable out, it shows the complete call stack / stack trace, which has 14 steps.
Do anybody has an idea what could cause this problem? I'm searching already the whole day for a solution.
Versions:
PHP 5.3.6
Xdebug 2.2.3
xdebug.show_exception_trace
Type: integer, Default value: 0
When this setting is set to 1, Xdebug will show a stack trace whenever an exception is raised - even if this exception is actually caught.

Categories