3

Just on certain pages, I'm led instead to /core/install.php...

This has happened to me a great number of times now, in certain twig templates. But, I can't imagine why. Has anyone else had this happen? What causes it? It just doesn't work in some templates. I'm only asking this because I have never seen anyone ask anything like it, and it has happened to a coworker as well.

  • 1
    I've had the same issues. Although I've never found out the reason of this behaviour, my advice is to use Twig Tweaks and print variables with {{ dd(my_var) }}. Doesn't cause any redirects and is a LOT faster than kint. – Hudri Aug 10 '17 at 8:20
  • Thanks for teaching me about that, although for future reference I'll note that I didn't realize you had to run 'composer require symfony/var-dumper' to get the function to work. I like the UI better than kint, too. – RaisinBranCrunch Aug 10 '17 at 19:51
6

That will be caused by an overload on resources. kint() is very resource intensive. If you are calling kint in a views-view-files.html.twig template for example then it could get called multiple times and overload the system.

If you check your logs you'll find an error like this:

General error: 2006 MySQL server has gone away

The DB has been overloaded and Drupal thinks there's no install, hence ending up on the install page.

Here are three ways of limiting the kint maxLevels variable which can help avoid this. Set maxLevels to 3 or 4.

1) In settings.php:

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

2) In /modules/contrib/devel/kint/kint/ duplicate the config.default.php file to config.php and modify this line:

$_kintSettings['maxLevels'] = 3;

3) In a preprocess function, add the following:

kint_require();
Kint::$maxLevels = 3;

You can also filter the kint output so it only shows the KEYS, e.g.

{{ kint(_context|keys) }}

Alternatively, use Symfony var-dumper which is a bit more lightweight:

composer require symfony/var-dumper

Visit the devel settings page and set Symfony var-dumper as the Variables Dumper.

Example usage:

{{ devel_dump() }}
{{ kpr() }}
{{ dpm() }} 
  • 1
    Just adding to this: In windows, XAMPP, the settings for mysql is set to too low and cause this issue on DB intensive tasks. Increasing that will definitely help. – Anish Sheela Mar 28 '18 at 3:12
  • As Anish says you can also increase the amount of resources available. But how you do this can vary a lot depending on your development environment. I really encourage developers to look into docker.com if you have not already. There is a bit of a learning curve but once you get into using containers you will not look back!!! – featherbelly Mar 31 '18 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.