| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --TEST-- | ||
| Fatal error backtrace | ||
| --INI-- | ||
| fatal_error_backtraces=On | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| eval("class Foo {}; class Foo {}"); | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Cannot redeclare class Foo (%s) in %s : eval()'d code on line %d | ||
| Stack trace: | ||
| #0 %sfatal_error_backtraces_001.php(%d): eval() | ||
| #1 {main} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --TEST-- | ||
| Fatal error backtrace w/ sensitive parameters | ||
| --INI-- | ||
| fatal_error_backtraces=On | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| function trigger_fatal(#[\SensitiveParameter] $unused) { | ||
| eval("class Foo {}; class Foo {}"); | ||
| } | ||
|
|
||
| trigger_fatal("bar"); | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Cannot redeclare class Foo (%s) in %s : eval()'d code on line %d | ||
| Stack trace: | ||
| #0 %sfatal_error_backtraces_002.php(%d): eval() | ||
| #1 %sfatal_error_backtraces_002.php(%d): trigger_fatal(Object(SensitiveParameterValue)) | ||
| #2 {main} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --TEST-- | ||
| Fatal error backtrace w/ zend.exception_ignore_args | ||
| --INI-- | ||
| fatal_error_backtraces=On | ||
| zend.exception_ignore_args=On | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| function trigger_fatal($unused) { | ||
| eval("class Foo {}; class Foo {}"); | ||
| } | ||
|
|
||
| trigger_fatal("bar"); | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Cannot redeclare class Foo (%s) in %s : eval()'d code on line %d | ||
| Stack trace: | ||
| #0 %sfatal_error_backtraces_003.php(%d): eval() | ||
| #1 %sfatal_error_backtraces_003.php(%d): trigger_fatal() | ||
| #2 {main} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| --TEST-- | ||
| error_get_last() w/ fatal error | ||
| --INI-- | ||
| fatal_error_backtraces=On | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| function trigger_fatal_error_with_stacktrace() { | ||
| eval("class Foo {}; class Foo {}"); | ||
| } | ||
|
|
||
| register_shutdown_function(function() { | ||
| var_dump(error_get_last()); | ||
| echo "Done\n"; | ||
| }); | ||
|
|
||
| trigger_fatal_error_with_stacktrace(); | ||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Cannot redeclare class Foo (%s) in %s on line %d | ||
| Stack trace: | ||
| #0 %serror_get_last_002.php(%d): eval() | ||
| #1 %serror_get_last_002.php(%d): trigger_fatal_error_with_stacktrace() | ||
| #2 {main} | ||
| array(5) { | ||
| ["type"]=> | ||
| int(64) | ||
| ["message"]=> | ||
| string(%d) "Cannot redeclare class Foo %s" | ||
| ["file"]=> | ||
| string(%d) "%serror_get_last_002.php(%d) : eval()'d code" | ||
| ["line"]=> | ||
| int(%d) | ||
| ["trace"]=> | ||
| array(2) { | ||
| [0]=> | ||
| array(3) { | ||
| ["file"]=> | ||
| string(%d) "%serror_get_last_002.php" | ||
| ["line"]=> | ||
| int(%d) | ||
| ["function"]=> | ||
| string(%d) "eval" | ||
| } | ||
| [1]=> | ||
| array(4) { | ||
| ["file"]=> | ||
| string(%d) "%serror_get_last_002.php" | ||
| ["line"]=> | ||
| int(%d) | ||
| ["function"]=> | ||
| string(%d) "trigger_fatal_error_with_stacktrace" | ||
| ["args"]=> | ||
| array(0) { | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Done |
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis is supposed to be readable in HTML, but I doubt the backtrace will be displayed in a readable manner. Perhaps, this should be wrapped in a <pre> tag or smth alike?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityGood catch, I'll look into that.
Semi-related tangent so feel free to disregard: Is it on anyone's radar to refactor this function at all? I saw "Deprecate the error_prepend_string and error_append_string INI directives" in https://wiki.php.net/rfc/deprecations_php_8_5, which would help make this a little more readable, but I wonder if there's more we could do simplify this logic. I acknowledge that is probably easier said than done, however.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI doubt refactoring this function is on someone's TODO list. There are indeed some outdated pieces (e.g. the ones you mentioned but also xmlrpc_errors imo). However, the question with refactoring is always how much it's worth spending time on this. This function likely is not on any hot code path and refactoring also brings in a risk of breaking things 🤷
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitywould be also nice to break up those huge long lines when you are in it...
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality@nielsdos apologies, but what's the best way to wrap a zend_string in <pre>? strpprintf? Or would it be the worst thing to just change this to %s%s%s and then pass in ZSTR_LEN(backtrace) ? "<pre>Stack trace:\n" : "", ZSTR_VAL(backtrace), ZSTR_LEN(backtrace) ? "</pre>" : ""? We could also drop adding the pre at all since we already have some fatal errors with stack traces that do not have pre: https://github.com/search?q=repo%3Aphp%2Fphp-src+%22%3Cb%3EFatal+error%3C%2Fb%3E%22&type=code, e.g.
<br /> <b>Fatal error</b>: Uncaught Error: Cannot access private property test::$pri in %s004.test.php:8 Stack trace: #0 {main} thrown in <b>%s004.test.php</b> on line <b>8</b><br />@bukka I received feedback elsewhere to not break up long lines, though maybe here is a good counterpoint. I'd personally like to err on keeping it as-is since I'd like to be able to merge this relatively soon, but if people feel strongly I could break this up. This is kind of what I was getting at with my earlier comment - this function could probably be simplified to make it more readable, besides just the long line length.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIf we wrap it with pre it should be done consistently.
If I were to write the code, I would go for the ZSTR_LEN() ternary trick.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI'm not sure I follow - what I was saying was that we currently do not wrap it with <pre> (for errors that already have backtraces before my change), so if we wrap it with <pre> here we'd be inconsistent with existing errors like:
php-src/sapi/cgi/tests/004.phpt
Lines 43 to 46 in 72708f2
Thanks, I was leaning that way but I wanted your opinion. I'm still not convinced we should add the <pre> based on the above, but if you think we should I'll go the ZSTR_LEN route.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIn case you are referring to my remark here: #16937 (comment) - this case of a printf-style function is quite different and splitting it across multiple lines would be reasonable, because it accurately represents the complexity of the statement.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityOk let's not do the <pre> conversion.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality@TimWolla I was! and when I said "maybe here is a good counterpoint", I meant that I could see that you might agree with splitting this up. My preference was to not do this myself though, since for consistency I should probably do that for all of them, and I was concerned with making it a topic for bikeshedding.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.