Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
With https://www.drupal.org/node/2665232 we got line numbers for backtrace information, which was very helpful. I think adding the file name is also important because sometimes the code/line number are not related, meaning sometimes it is showing the code executed on the line of another file. Attaching the patch with the file information.
An example output:
The website encountered an unexpected error. Please try again later.
Exception: Example in Drupal\some_module\Controller\WeekController->content() (line 44 of modules/custom/c4l_lesson_planner/src/Controller/WeekController.php).
call_user_func_array(Array, Array) (in /var/www/example.com/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php on line 128)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (in /var/www/example.com/public_html/core/lib/Drupal/Core/Render/Renderer.php on line 577)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (in /var/www/example.com/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php on line 129)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (in /var/www/example.com/public_html/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php on line 102)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (in /var/www/example.com/public_html/vendor/symfony/http-kernel/HttpKernel.php on line 139)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (in /var/www/example.com/public_html/vendor/symfony/http-kernel/HttpKernel.php on line 62)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (in /var/www/example.com/public_html/core/lib/Drupal/Core/StackMiddleware/Session.php on line 62)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (in /var/www/example.com/public_html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php on line 53)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (in /var/www/example.com/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php on line 103)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (in /var/www/example.com/public_html/core/modules/page_cache/src/StackMiddleware/PageCache.php on line 82)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (in /var/www/example.com/public_html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php on line 51)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (in /var/www/example.com/public_html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php on line 55)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (in /var/www/example.com/public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php on line 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (in /var/www/example.com/public_html/core/lib/Drupal/Core/DrupalKernel.php on line 637)
Drupal\Core\DrupalKernel->handle(Object) (in /var/www/example.com/public_html/index.php on line 19)
Comment | File | Size | Author |
---|---|---|---|
#21 | 2688615-file-name-in-backtrace-4.patch | 2.74 KB | rballou |
| |||
#7 | 2688615-file-name-in-backtrace-3.patch | 2.63 KB | rballou |
#5 | 2688615-file-name-in-backtrace-2.patch | 651 bytes | rballou |
#2 | 2688615-file-name-in-backtrace.patch | 683 bytes | rballou |
Comments
Comment #2
rballou CreditAttribution: rballou at Aten Design Group commentedAttaching patch
Comment #3
dawehnerIdeally we should expand the test coverage
IMHO we don't need this replacement of DRUPAL_ROOT, having absolute filepaths doesn't really cause an issue.
Comment #5
rballou CreditAttribution: rballou at Aten Design Group commentedSounds good, new patch attached with the full file path
Comment #6
dawehnerYou have to adapt/expand the existing test coverage for that
Comment #7
rballou CreditAttribution: rballou at Aten Design Group commentedHere's a new patch with the updated tests
Comment #8
dawehnerSetting back to needs review, so the testbot executes it.
Comment #10
dawehnerIt would be great to give an example in the issue summary of before and after ... so its easier for people to judge the proposed change.
Comment #11
rballou CreditAttribution: rballou at Aten Design Group commentedAdded example output to the issue summary.
Comment #13
dawehnerThanks a ton!
Comment #15
catchCommitted 0d77fa5 and pushed to 8.2.x. Thanks!
Leaving RTBC for 8.1.x - this looks fine for a patch release but we're in rc commit freeze at the moment.
Comment #16
alexpottI'm not totally convinced about the format
Line: NN:FILE
. The colon are being used weirdly.Comment #17
alexpottHow about we copy PHP and do something like
(in FILE on line NN)
...The standard PHP error message looks like this:
Comment #18
rballou CreditAttribution: rballou at Aten Design Group commentedI'd support that. I was just trying to roll with what was started in the related issue. Let me know if that's the direction we should head and I can update the patch.
Comment #19
catchMakes sense to me as well.
I went ahead and reverted the 8.2.x commit so it's just a single patch for both branches again. Moving back up and CNW for that change.
Comment #21
rballou CreditAttribution: rballou at Aten Design Group commentedNew patch with the "in FILE line N" format. I left the parenthesis around that information but that can also easily be removed those are not desired. Thanks
Comment #22
rballou CreditAttribution: rballou at Aten Design Group commentedUpdated summary
Comment #23
dawehner.
Comment #33
geek-merlinComment #34
geek-merlindawehner said in #3:
> IMHO we don't need this replacement of DRUPAL_ROOT, having absolute filepaths doesn't really cause an issue.
We should really put that in again. I have 2 hosters that have ~200 character root paths, which include a build specific hash...
Comment #35
dawehner@axel.rutz fair point. Do you mind putting it back in?