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.
DevelDumperBase could implements a method (::getInternalAliases()
) that returns a list of methods and function considered internal for the dumper system. The list returned from this method could be very useful for dumpers that add a backtrace to the output for detecting internal methods and functions and exclude them from the backtrace.
The method could be very helpful for solving problem like #2643392: dpm()'s / Kint shows the file and line from devel module, not from where dpm() was called
Comments
Comment #2
willzyx CreditAttribution: willzyx commentedComment #3
joachim CreditAttribution: joachim commentedIs this patch meant to solve the problem at #2643392: dpm()'s / Kint shows the file and line from devel module, not from where dpm() was called? It's not doing that for me -- dsm() output says:
> Called from /8-drupal/modules/contrib/devel/kint/src/Plugin/Devel/Dumper/Kint.php:32 [Drupal\kint\Plugin\Devel\Dumper\Kint->export()]
Comment #4
willzyx CreditAttribution: willzyx commentedas the dockblock states the method in the patch does nothing by itself.. it simply provide the list of all methods and function that should be considered internal.
For solve #2643392: dpm()'s / Kint shows the file and line from devel module, not from where dpm() was called we could use the method in the kint dumper plugin for configure kint aliases. Something like
\Kint::$aliases = array_merge_recursive(\Kint::$aliases, $this->getInternalAliases());
Comment #5
Ben Buske CreditAttribution: Ben Buske at werk21 commentedShouldn't these functions be included in the list, because this issue isn't only about kint.
Comment #6
joachim CreditAttribution: joachim commented'could be very useful' doesn't read right for actual code. How about 'is intended for'
Needs to document the nested structure of the array.
Comment #7
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedRevised patch
Comment #8
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedI think the test fail is unrelated
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedLet's rename to getInternalFunctions
Comment #10
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedDone #9.
New patch also fixes typo on the quote position for some of the functions in the list.
Comment #11
salvisCouldn't we just check for
'/devel/'
(and maybe some other fragments) in the file path?IAC, it should be a variable, so that it can be configured locally without hacking Devel.
(Also, I'm not sure against which branch this should go.)
Comment #12
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedThanks @salvis
No I think it doesn't work that way. It is the dumper plug-in that does the check. In the case of kint like this:
I don't see any way to pass a regex.
Please can you explain what scenario you are thinking of and what should be a variable? Any base dumper class can easily override
getInternalFunctions()
without any hacking of Devel.Normally in Drupal we commit to the newest branch then maybe back-apply.
Setting back to "needs review" for response from reviewer.
Comment #13
salvisI mean configuration. People might want to add to or remove from the list.
Comment #14
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedAs I see it the purpose of this issue is to ensure that the internal functions of devel are excluded from backtrace. The problem is explained clearly in #2643392: dpm()'s / Kint shows the file and line from devel module, not from where dpm() was called - which I just noticed that you raised:-). When you add a dump line of code to a function
my_func_to_debug
, then the trace should reports the backtrace starting frommy_func_to_debug
, and not including the debug line of code that you added such asksm()
. So it seems to me that the list of internal functions is determined by the code present in this module - i.e. they are internal to this module (or whatever module the dumper plugin is in).Ah I see, thanks for clarifying. Do you have an example in mind of when this would be required?
I don't really have time to extend the patch for configuration. I propose that the patch as it stands is useful so why don't we commit it. We can raise a follow on issue for further enhancements.
Comment #15
salvisSomeone may want to wrap, say, dpm(), for whatever reason, and want to exclude their wrapper as well. Hard-coded lists of function names just don't feel right...
Comment #16
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedAh yes I see, I agree that is a valid possibility. However I would say that less than 1% of people will want to do that.
As I mentioned, unfortunately I don't have time for that. The patch as it stands is a significant improvement. Nothing in this patch makes any obstacle to adding the ability to configure extra functions later. How about if we raise a separate issue to add configuration?
I guess the alternative is to set this needs work and wait hoping that someone will feel inspired to do the work.
Comment #17
salvisI'm fine to leave it at NR.
Comment #18
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedThanks @salvis
Comment #19
salvisThank you, AdamPS! :-)
Comment #21
moshe weitzman CreditAttribution: moshe weitzman commentedMany thanks, @AdamPS.
Comment #22
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedThanks @moshe weitzman
Comment #24
joachim CreditAttribution: joachim commentedHere's the patch backported to 8.x-2.x, for the benefit of everyone still running that version.
Comment #25
joachim CreditAttribution: joachim commentedUpdated 8.x-2.x patch -- I finally figured out the problem with warning messages being removed!
Comment #26
salvisAnyone interested in reviewing #25 with Drupal 8.6?
Comment #27
moshe weitzman CreditAttribution: moshe weitzman commentedIf someone else can verify that this works on 2.x branch, I'll merge it.
Comment #28
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedI just scanned the issue queue and it looks to me like 8.x-3.x is in good shape now - very little left in "Needs Review" or "RTBC", thanks Moshe for the recent commits. So another alternative that could be considered more forward-looking is to create a 3.x release then mark 2.x as unsupported soon after.
Comment #29
moshe weitzman CreditAttribution: moshe weitzman commentedJust created a 3.x release - https://www.drupal.org/project/devel/releases/8.x-3.0-beta1. Final release will come soon as well. I'll leave this open for a bit in case someone really wants to backport and can verify it works.
Comment #30
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedExcellent, many thanks @moshe. I have been running with local patches to devel for 2 years but now running clean, the latest release is great.
Comment #31
moshe weitzman CreditAttribution: moshe weitzman commented