verbb / kint

Adds Kint, an in-app PHP debugger, to Craft CMS for use in Twig and PHP.
MIT License
3 stars 3 forks source link

PHP error when dumping certain properties using `d()` #9

Open mikesnoeren opened 3 weeks ago

mikesnoeren commented 3 weeks ago

Describe the bug

When executing {{ d(craft.entries) }}, we encounter a PHP error 500.

In Craft 4, we could execute partial queries like the example above to explore available methods associated with the craft.entries property. However, attempting this in Craft 5 leads to the PHP error detailed below:

[11-Jun-2024 12:18:55 Europe/Amsterdam] PHP Fatal error:  Allowed memory size of 1073741824 bytes exhausted (tried to allocate 12288 bytes) in /var/www/html/vendor/kint-php/kint/src/Parser/ClassMethodsPlugin.php on line 87
[11-Jun-2024 12:18:55 Europe/Amsterdam] PHP Fatal error:  Allowed memory size of 1073741824 bytes exhausted (tried to allocate 1052672 bytes) in /var/www/html/vendor/yiisoft/yii2/helpers/BaseFileHelper.php on line 173

Observations:

Steps to reproduce

  1. Add {{ d(craft.entries) }} to any template
  2. Load the page

Craft CMS version

5.1.10

Plugin version

4.0.0

Multi-site?

No

Additional context

No response

engram-design commented 2 weeks ago

Similar to https://github.com/verbb/kint/issues/8 what's the reason for dumping an ElementQuery as opposed to a single or collection of Element objects?

I'll look into this, as it's probably the eager-loading changes in Craft 5 that are causing this, but it might mean we need to fork and maintain our own kint-twig package.

mikesnoeren commented 2 weeks ago

Similar to #8 what's the reason for dumping an ElementQuery as opposed to a single or collection of Element objects?

In this specific project, we're building a filter that updates an element query, in order to debug this, it's nice to have Kint available to see all options in the element query.

engram-design commented 2 weeks ago

Ah, gotcha, good to know! So yep, it looks like the auto eager-loading Craft does is really messing this up, providing an infinite loop of elements. I think the depth setting in supposed to handle this, but maybe that's not quite working.

mikesnoeren commented 2 weeks ago

Even with that set to 1, the page just crashes. So I think something else is going on here. If you require any further information please let me know!

engram-design commented 2 weeks ago

Yeah, I'm in agreement that it's not working. Looking into it...

ruudvdboom commented 1 week ago

I wanted to follow up on this issue and ask if there has been any progress. This issue is currently blocking our workflow, so any updates would be greatly appreciated.

engram-design commented 5 days ago

I've just done some further testing on this, if you'd like to give my latest changes a go? To get this early, run composer require verbb/kint:"dev-craft-5 as 4.0.0".

mikesnoeren commented 4 days ago

I've just done some further testing on this, if you'd like to give my latest changes a go? To get this early, run composer require verbb/kint:"dev-craft-5 as 4.0.0".

Everything seems to be working fine again! Thanks a lot!