Review main Merged

95768[TASK] Add caller file and line to DebugUtility::debug()

Alexander Hofbauer CR +2 V +2 Normal +80 −7 updated 09/15/26, 05:02

Commit message

Append the caller's file path and line number to the debug header
to make debug statements easier to locate in the source code.
This applies to both the default header and custom headers.

Paths inside the project directory are shortened by removing the
project path prefix. Paths outside the project remain absolute.

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Radostin Milenov +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Radostin Milenov +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 2736

Show 711 earlier messages
  1. Alexander Hofbauer uploaded patch set 1 09/11/26, 10:24

  2. core-ci voted on patch set 1 V +1 09/11/26, 10:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108293

  3. Garvin Hicking commented on patch set 1 09/11/26, 11:14

    I like this, thanks! We might even want to backport this to v14, and it would help to easier remove stray debugs left in code. However: 1. We should remove the minor breaking change, and not change the signature of debug(). 2. I talked to this with Tobias Gülzow and he recommended a nice idea out of the problem "how else do we append the file location then": We could just append the file name to any header output always: ``` public static function debug(mixed $var = '', string header = 'Debug'): void { $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1); $caller = $backtrace[0] ?? null; if ($caller !== null) { $header .= ' @ ' . ($caller['file'] ?? 'unknown') . ':' . ($caller['line'] ?? '?'); } ``` What do you think?
  4. Alexander Hofbauer commented on patch set 1 09/11/26, 11:27

    I think it might get a little cluttered then, but I like the idea in general. Is there a way to resolve the absolute filesystem path from @$caller['file']@ to a path relative to the typo3 root path? That would shorten the filepath and be equally helpful when working with multiple debug statements. I thought about this before creating the patch, but wanted to keep the debug method as dependency free as possible to keep it as robust as possible. But shortening the path would probably not reduce stability. What do you think?
  5. Garvin Hicking commented on patch set 1 09/11/26, 11:36

    Reply

    I thought about that too but think a debugging output will probably already clutter something? But if that is worrysome we could only append this in case the title is "Debug" (the default string). You can fetch the base directory from `TYPO3\CMS\Core\Core\Environment::getProjectPath()` and then do some substring replace magic at the beginning of the string if you want to shorten...
  6. Alexander Hofbauer uploaded patch set 2 V +1 09/11/26, 12:03

  7. Alexander Hofbauer uploaded patch set 3 09/11/26, 12:04

  8. core-ci voted on patch set 2 V -1 09/11/26, 12:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108295

  9. core-ci voted on patch set 3 V -1 09/11/26, 12:13 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108296

  10. Alexander Hofbauer uploaded patch set 4 V -1 09/11/26, 12:19

  11. core-ci voted on patch set 4 V +1 09/11/26, 12:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108297

  1. Garvin Hicking commented on patch set 4 09/11/26, 12:36

    DebugUtility.php:43

    I think this string replacement logic could be buggy. If a PHP file is outside the project path (could happen) then the path would be cut seemingly random. Instead I would do a `substr_replace` logic with `0, strlen(...)` of the project path to be safe, so thhat a "/tmp/file.php" would really return "/tmp/file.php" instead of "e.php" for example
  2. Alexander Hofbauer uploaded patch set 5 V +1 09/11/26, 13:13

  3. core-ci voted on patch set 5 V -1 09/11/26, 13:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108300

  4. Alexander Hofbauer uploaded patch set 6 V -1 09/11/26, 14:20

  5. core-ci voted on patch set 6 V -1 09/11/26, 14:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108302

  6. Alexander Hofbauer uploaded patch set 7 V -1 09/11/26, 14:56

  7. core-ci voted on patch set 7 V +1 09/11/26, 15:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108303

  8. Garvin Hicking commented on patch set 7 V +1 09/11/26, 21:56

    Reply

    Done

    Reply

    Done

    DebugUtility.php:43 Reply

    Thanks for adapting! Could you uodate the commit message to reflect the current variant and let's add 14.3 as a scope for the "Releases" line, Id be happy to have that in 14.3 as an improvement already.
  9. Radostin Milenov updated the commit message in patch set 8 V +1 09/13/26, 13:48

  10. Radostin Milenov commented on patch set 8 CR +1 V +1 09/13/26, 13:49

    DebugUtility.php:43 Reply

    Done
  11. core-ci voted on patch set 8 V +1 09/13/26, 13:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108452

  12. Garvin Hicking commented on patch set 8 09/13/26, 19:56

    DebugUtility.php:43 Reply

    The commit message does not yet reflect the actual change
  13. Radostin Milenov updated the commit message in patch set 9 CR +1 V +1 09/14/26, 02:56

  14. Radostin Milenov commented on patch set 9 09/14/26, 02:57

    DebugUtility.php:43 Reply

    Indeed missed that. Is it clear enought now ?
  15. core-ci voted on patch set 9 V +1 09/14/26, 03:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108471

  16. Garvin Hicking commented on patch set 9 CR +1 V +1 09/14/26, 07:27

    DebugUtility.php:43 Reply

    Great, thanks!
  17. Alexander Hofbauer commented on patch set 9 09/14/26, 15:52

    Reply

    Done

    Reply

    Done
    @r.milenov@icloud.com Thanks for handling the commit message update!

    DebugUtility.php:43 Reply

    Done
  18. Radostin Milenov commented on patch set 9 09/14/26, 16:05

    Reply

    My pleasure, now we just need need another core developer to approve it.
  19. Garvin Hicking commented on patch set 9 09/14/26, 17:41

    Reply

    Actually I just need a vote from you, @r.milenov@icloud.com :-D
  20. Radostin Milenov commented on patch set 9 CR +1 09/14/26, 18:17

    Reply

    Well in that case...
  21. Radostin Milenov voted on patch set 9 V +1 09/14/26, 18:18

  22. Radostin Milenov voted on patch set 9 CR 0 09/14/26, 18:19

  23. Radostin Milenov voted on patch set 9 CR +1 09/14/26, 18:19

  24. Garvin Hicking voted on patch set 9 CR +2 V +2 09/14/26, 18:43

  25. Garvin Hicking merged patch set 10 09/15/26, 05:02