Skip to content

Generate exception to log on php errors - #23083

Merged
rullzer merged 1 commit into
masterfrom
bugfix/extend-php-error-logging
Sep 29, 2020
Merged

Generate exception to log on php errors#23083
rullzer merged 1 commit into
masterfrom
bugfix/extend-php-error-logging

Conversation

@juliusknorr

Copy link
Copy Markdown
Member

This will make sure we get some more useful error log messages that contain a trace to the actual place in code that caused the issue when a PHP error is catched, e.g. for a "Trying to access array offset on value of type null" error.

Example output:

{
"reqId": "SDrgQ5mzjHWyKLd9bP3u",
"level": 0,
"time": "2020-09-29T06:53:42+00:00",
"remoteAddr": "192.168.21.9",
"user": "admin",
"app": "PHP",
"method": "GET",
"url": "/test.php",
"message": {
"Exception": "Error",
"Message": "Trying to access array offset on value of type null at /var/www/html/test.php#15",
"Code": 0,
"Trace": [
{
"file": "/var/www/html/test.php",
"line": 15,
"function": "onAll",
"class": "OC\\Log\\ErrorHandler",
"type": "::",
"args": [
8,
"Trying to access array offset on value of type null",
"/var/www/html/test.php",
15,
{
"foo": null,
"bar": null
}
]
},
{
"file": "/var/www/html/test.php",
"line": 18,
"function": "bar",
"args": []
},
{
"file": "/var/www/html/test.php",
"line": 30,
"function": "foo",
"args": []
}
],
"File": "/var/www/html/lib/private/Log/ErrorHandler.php",
"Line": 98,
"CustomMessage": "--"
},
"userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"version": "21.0.0.0"
}

Signed-off-by: Julius Härtl <jus@bitgrid.net>

@rullzerrullzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O nice!

@ChristophWurstChristophWurst added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Sep 29, 2020
@ChristophWurstChristophWurst added this to the Nextcloud 21 milestone Sep 29, 2020
@faily-bot

faily-botBot commented Sep 29, 2020

Copy link
Copy Markdown

🤖 beep boop beep 🤖

Here are the logs for the failed build:

Status of 33447: failure

mysql8.0-php7.4

@rullzer
rullzer merged commit 18411b8 into masterSep 29, 2020
@rullzer
rullzer deleted the bugfix/extend-php-error-logging branch September 29, 2020 08:02
@rullzer

Copy link
Copy Markdown
Member

/backport to stable20

@rullzer

Copy link
Copy Markdown
Member

/backport to stable19

@rullzer

Copy link
Copy Markdown
Member

/backport to stable18

@backportbot-nextcloud

Copy link
Copy Markdown

The backport to stable18 failed. Please do this backport manually.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to releaseReady to be released and/or waiting for tests to finishbug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@juliusknorr@rullzer@ChristophWurst