NB the problem applies to Drupal core and many different modules - flag module is just an example.

While looking at the flag module with devel

I see get the following stack trace, when I try to inspect a few core containers everything appears ok

Steps to reproduce

1) drush en devel kint flag
2) visit /devel/container/service/flag

2 is the same as going to /devel/container/service page.
getting a list of all containers - then typing flag into the search box and hitting the details button

The website encountered an unexpected error. Please try again later.
Error: Cannot access protected property Drupal\Core\Utility\Error::$blacklistFunctions in Drupal\Core\Utility\Error::getLastCaller() (line 116 of core/lib/Drupal/Core/Utility/Error.php).
Drupal\Core\Utility\Error::getLastCaller(Array) (Line: 65)
_drupal_error_handler_real(8, 'Undefined property: Drupal\Core\Config\ImmutableConfig::$overriddenData', 'XXXXX/drupal/vendor/doctrine/common/lib/Doctrine/Common/Util/Debug.php', 132, Array) (Line: 552)
_drupal_error_handler(8, 'Undefined property: Drupal\Core\Config\ImmutableConfig::$overriddenData', 'XXXXX/drupal/vendor/doctrine/common/lib/Doctrine/Common/Util/Debug.php', 132, Array)
ReflectionProperty->getValue(Object) (Line: 132)
Doctrine\Common\Util\Debug::export(Object, 1) (Line: 132)
Doctrine\Common\Util\Debug::export(Object, 2) (Line: 107)
Doctrine\Common\Util\Debug::export(Array, 3) (Line: 132)
Doctrine\Common\Util\Debug::export(Object, 4) (Line: 132)
Doctrine\Common\Util\Debug::export(Object, 5) (Line: 132)
Doctrine\Common\Util\Debug::export(Object, 6) (Line: 24)
Drupal\devel\Plugin\Devel\Dumper\DoctrineDebug->export(Object) (Line: 50)
Drupal\devel\Plugin\Devel\Dumper\DoctrineDebug->exportAsRenderable(Object, Object) (Line: 127)
Drupal\devel\DevelDumperManager->exportAsRenderable(Object, Object) (Line: 176)
Drupal\devel\Controller\ContainerInfoController->serviceDetail('flag')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 144)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

martin107 created an issue. See original summary.

willzyx’s picture

@martin107 Thanks for reporting.
Please, can you post drupal/devel/flag version used? I'm trying to reproduce the issue without success using drupal 8.x-3.x flag 8.x-4.0-alpha1 devel 8.x-1.x-dev/8.x-1.0-rc1
Thanks

also this seems to be stricty related with the following core bug #2833979: Config::resetOverriddenData() should reset overriddenData value not remove the class property

_drupal_error_handler_real(8, 'Undefined property: Drupal\Core\Config\ImmutableConfig::$overriddenData', 'XXXXX/drupal/vendor/doctrine/common/lib/Doctrine/Common/Util/Debug.php', 132, Array) (Line: 552)
_drupal_error_handler(8, 'Undefined property: Drupal\Core\Config\ImmutableConfig::$overriddenData', 'XXXXX/drupal/vendor/doctrine/common/lib/Doctrine/Common/Util/Debug.php', 132, Array)
ReflectionProperty->getValue(Object) (Line: 132)
martin107’s picture

The flag version was 8.x-4.x
php 7.1.1
Drupal8 - 8.3.x

I will spend a little time on Sunday trying to find a core module that breaks ...

martin107’s picture

I always want the "step to reproduce" list to be as small as possible

kint and the flag module do not need to be installed to reproduce this stack trace.

1) drush en devel

2) go to /devel/container/service - type service_container in the search box or visit

/devel/container/service/service_container

I will try and debug soon ... I am just short on time at the moment..

BeauTownsend’s picture

Similar issue for me while attempting to execute kint in hook_preprocess_views_view_unformatted() from a module. If it matters, the view is outputting a custom Content Entity that i created. The view itself is a very simple output of entities. I didn't change any format or field settings.

Steps to reproduce:

  1. Install an instance of Drupal 8.3.3-dev via drush qd
  2. drush en devel -y
  3. drush en kint -y
  4. drush en views -y
  5. Generate a module using drupal console's drupal generate:module command.
  6. Generate a Content Entity using drupal console's drupal generate:entity:content command.
  7. Create a basic unformatted list view of myEntity as a block.
  8. Place the block in a renderable region.
  9. Add a kint line to hook_preprocess_views_view_unformatted() in my_module.module. (see code below)

Sample of hook_preprocess_views_view_unformatted:

function my_module_preprocess_views_view_unformatted(&$variables) {
  kint($variables);
}

Outputting the keys does not cause on error and works as expected:

function my_module_preprocess_views_view_unformatted(&$variables) {
  kint(array_keys($variables));
}

Resultant call stack:

Error: Cannot access protected property Drupal\Core\Utility\Error::$blacklistFunctions in Drupal\Core\Utility\Error::getLastCaller() (line 116 of core/lib/Drupal/Core/Utility/Error.php).

Drupal\Core\Utility\Error::getLastCaller(Array) (Line: 65)
_drupal_error_handler_real(8, 'Undefined property: Drupal\views\ViewExecutable::$row_index', '/Users/bxt1/Sites/D8-projects/cwb30-8.3.x-dev/drupal/modules/devel/kint/kint/inc/kintParser.class.php', 496, Array) (Line: 566)
_drupal_error_handler(8, 'Undefined property: Drupal\views\ViewExecutable::$row_index', '/Users/bxt1/Sites/D8-projects/cwb30-8.3.x-dev/drupal/modules/devel/kint/kint/inc/kintParser.class.php', 496, Array)
ReflectionProperty->getValue(Object) (Line: 496)
kintParser::_parse_object(Object, Object) (Line: 115)
kintParser::factory(Object) (Line: 383)
kintParser::_parse_array(Array, Object) (Line: 115)
kintParser::factory(Array) (Line: 383)
kintParser::_parse_array(Array, Object) (Line: 115)
kintParser::factory(Array, '$args') (Line: 234)
Kint::dump(Array) (Line: 18)
kint(Array) (Line: 56)
cwb_alerts_preprocess_views_view_unformatted(Array, 'views_view_unformatted', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('views_view_unformatted', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 114)
__TwigTemplate_b28f9e300c133a8745ddffe7e9b8ef0cb917fadbf35a41b8c1b93c5698fa15b0->doDisplay(Array, Array) (Line: 379)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 347)
Twig_Template->display(Array) (Line: 358)
Twig_Template->render(Array) (Line: 64)
twig_render_template('core/themes/classy/templates/views/views-view.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('views_view', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 87)
__TwigTemplate_3a355533b35b529021546f4d0a14fc7eed6c597ad35e79124825e4177a4b804d->block_content(Array, Array) (Line: 186)
Twig_Template->displayBlock('content', Array, Array) (Line: 72)
__TwigTemplate_3a355533b35b529021546f4d0a14fc7eed6c597ad35e79124825e4177a4b804d->doDisplay(Array, Array) (Line: 379)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 347)
Twig_Template->display(Array) (Line: 358)
Twig_Template->render(Array) (Line: 64)
twig_render_template('core/themes/bartik/templates/block.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('block', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 104)
__TwigTemplate_6f7a555a65517c20f128fe77d463147311f381c882763e0f016230a87b7f96a2->doDisplay(Array, Array) (Line: 379)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 347)
Twig_Template->display(Array) (Line: 358)
Twig_Template->render(Array) (Line: 64)
twig_render_template('core/themes/bartik/templates/page.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('page', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 490)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 90)
__TwigTemplate_e8d2f13c0caa5a29d713607b0449b830d37be2435df5f105b3d8058e912da93f->doDisplay(Array, Array) (Line: 379)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 347)
Twig_Template->display(Array) (Line: 358)
Twig_Template->render(Array) (Line: 64)
twig_render_template('core/themes/classy/templates/layout/html.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('html', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 147)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 148)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 656)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
mariusdiacu’s picture

I'm having the same problem with basic Drupal install, devel and kint modules enabled. Here are the steps:

1. I installed Drupal 8.3.1, enabled devel and kint modules. Also, admin_menu is installed, but it has nothing to do with it (tested).
2. Created a basic theme, with themetest.info.yml as follows:

name: Test theme
description: Test theme description
type: theme
core: 8.x
version: VERSION
base theme: false

regions:
    header: Header
    content: Content
    footer: Footer

3. Created file themetest.theme:

/**
 * Implements hook_theme_suggestions_node_alter().
 */
function themetest_theme_suggestions_node_alter(array &$suggestions, array $variables) {
  kint($variables['elements']['#node']);
}

4. Create a basic page node and promoted it to homepage.
5. Access homepage. The bug does not reproduce for node pages, but when accessing teasers of the node, I get the same error as above. No method within devel module works. Neither print_r worked for me.

mariusdiacu’s picture

After some investigations I found that on the $variables['elements']['#node'], which is an instance of Drupal\node\Entity\Node class, in the protected $values a view is stored (Drupal\views\ViewExecutable).
This is the entire homepage view, which is attached to the values property of the node. When the kint is executed, the ReflectionProperty class used to get the values cannot get the row_index and throws this error.

yi_jiang’s picture

so how could I avoid this?

jeremyr’s picture

Just ran into this problem too while working with a views field. I added use Drupal\node\Entity\Node; to the top of the file and now kint works.

colan’s picture

Seems like you need to use whatever you're piping through dd(). In my case it was $form_state->getFormObject() so I needed Drupal\Core\Form\FormState.

chamilsanjeewa’s picture

Added below two lines before kint, its works for me.

require_once DRUPAL_ROOT . '/modules/contrib/devel/kint/kint/Kint.class.php';
Kint::$maxLevels = 3;

andeersg’s picture

I have the same problem on a Drupal 8.4 site, and I don't use the flag module.

AdamPS’s picture

Issue summary: View changes

I had no luck with #9/#10 - presumably I didn't figure out the right class. I didn't try for long as this seems too fiddly to keep adding different use statements for every call to ksm (unless there are only a handful needed for the whole of Core).

#11 works, but again it seems to be a bit of a guess. It assumes that the problem occurs more than 3 levels deep, and that the developer doesn't need to click past the 3rd level when debugging.

#12 I have clarified the summary that it isn't just the flag module.

It would be great if someone could figure out a universal solution. The kint code calls $property->setAccessible( true ); so I don't understand why that doesn't work. Many protected fields seem to be fine, so why do some others fail?

ggeerolf’s picture

Anyone found a solution to this problem yet ?

nicolaj.knudsen@gmail.com’s picture

This is a problem when looking at many different core objects, which makes exploring system objects very hard and tedious.

Here is an even simpler way to reproduce it, execute this line from a clean install with kint and devel (to execute the code) enabled:

kint(\Drupal::config('system.theme'));

I created this issue before finding this thread, that can be closed as a duplicate.

I tested this with Drupal core 8.4.4 and Devel 8.x-1.2

jedihe’s picture

#9 worked for me, I was trying to inspect a $file object loaded this way:

function MYTHEME_preprocess_node(&$variables) {
  $node = $variables['elements']['#node'];
  $img_value = $node->field_image->getValue();
  kint($img_value);
  $file = \Drupal\file\Entity\File::load(reset($img_value)['target_id']);
  kint($file->toArray());
}

After I added use Drupal\node\Entity\Node; the error went away and I was able to inspect the $file variable (as an array).

jnicola’s picture

I'm encountering this error as well. Working on a form used for roles on groups in the Group module, I am attempting to run dpm($form_state->getFormObject()); and I the afforementioned error.

AdamPS’s picture

Status: Active » Needs review
FileSize
711 bytes

This seems to be a bug in the upstream library and I have raised this issue.

Sadly devel is stuck on a very very old unsupported version of the library. Clearly the right way forward is this #2859114: Integrate latest kint library

In the meantime, here is a patch that works for me.

elijahoyekunle’s picture

Alrighty.
I can confirm that the patch in #18 works for me.

AdamPS’s picture

Great - in that case please could you set RTBC to help us get it committed.

elijahoyekunle’s picture

How do I do that? :)

elijahoyekunle’s picture

AdamPS’s picture

@elijahoyekunle Edit the status field to "Reviewed & tested by the community"

elijahoyekunle’s picture

Status: Needs review » Reviewed & tested by the community
altrugon’s picture

I'm confirming too that patch in #18 works. I hope this get merged into the new version soon.

Thanks for all the hard work.

willzyx’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

@all thanks for contributing. Since the patch changes the kint code I think that is not a good idea commit it.
Bugs in libraries used by devel should be fixed in those projects.

Mark this issue as won't fix.

@see #2839515: Remove Kint module and create a kint dumper plugin in devel for an alternative solution.

Thanks

DuneBL’s picture

#18 solve my issue...

paul_leclerc’s picture

#18 saved my life :)

"patches": {
            "drupal/devel": {
                "Drupal Kint fixed protected value access": "https://www.drupal.org/files/issues/devel.ksm_.2857361.18.patch"
            }
}

In your composer.json

paulkerrigan’s picture

#18 doesn't change anything for me.

AltaGrade’s picture

#18 worked in our case too.