Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drupal-check fails when some modules exist #42

Closed
adamfranco opened this issue Apr 15, 2019 · 8 comments
Closed

drupal-check fails when some modules exist #42

adamfranco opened this issue Apr 15, 2019 · 8 comments
Labels
drupal code phpstan-drupal Issue relates to PHPStan Drupal extension upstream Ticket involves dependencies

Comments

@adamfranco
Copy link

I found that having the examples module installed in a Drupal instance (even if not enabled) will cause drupal-check to fail with an opaque error and no other output:

\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.

This can be replicated by creating brand-new install of Drupal built via the composer command in the readme, then installing the examples module with composer before running drupal-check:

composer create-project drupal-composer/drupal-project:8.x-dev drupal --no-interaction --stability=dev
cd drupal
composer require 'drupal/examples:1.x-dev'
drupal-check ./

Here is a portion of the backtrace where the exception was being generated:

#0  Drupal::getContainer() called at [/home/afranco/drupal/web/core/lib/Drupal.php:159]
#1  Drupal::service(extension.list.module) called at [/home/afranco/drupal/web/core/includes/bootstrap.inc:241]
#2  drupal_get_filename(module, tabledrag_example) called at [/home/afranco/drupal/web/core/includes/bootstrap.inc:293]
#3  drupal_get_path(module, tabledrag_example) called at [/home/afranco/drupal/web/core/includes/module.inc:134]
#4  module_load_include(inc, tabledrag_example, tabledrag_example.data) called at [/home/afranco/drupal/web/modules/contrib/examples/tabledrag_example/tabledrag_example.install:14]
#5  require(/home/afranco/drupal/web/modules/contrib/examples/tabledrag_example/tabledrag_example.install) called at [/home/afranco/.composer/vendor/mglaman/drupal-check/vendor/mglaman/phpstan-drupal/src/Drupal/Bootstrap.php:100]
#6  PHPStan\Drupal\Bootstrap->register() called at [/home/afranco/.composer/vendor/mglaman/drupal-check/vendor/mglaman/phpstan-drupal/phpstan-bootstrap.php:3]
#7  require_once(/home/afranco/.composer/vendor/mglaman/drupal-check/vendor/mglaman/phpstan-drupal/phpstan-bootstrap.php) called at [/home/afranco/.composer/vendor/mglaman/drupal-check/vendor/phpstan/phpstan/src/Command/CommandHelper.php:209]
#8  PHPStan\Command\CommandHelper::PHPStan\Command\{closure}(/home/afranco/.composer/vendor/mglaman/drupal-check/vendor/mglaman/phpstan-drupal/phpstan-bootstrap.php) called at [/home/afranco/.composer/vendor/mglaman/drupal-check/vendor/phpstan/phpstan/src/Command/CommandHelper.php:210]
#9  PHPStan\Command\CommandHelper::begin(Symfony\Component\Console\Input\ArgvInput Object ([Symfony\Component\Console\Input\ArgvInputtokens] =>

While drupal-check can't be responsible for all modules, it would be helpful to at least catch exceptions in the Bootstrap process and output a message indicating which module or theme is the offending one.

@adamfranco
Copy link
Author

It looks like this is related to the fix for mglaman/phpstan-drupal#51, but that one doesn't seem to cover the .install files.

@mglaman mglaman added the phpstan-drupal Issue relates to PHPStan Drupal extension label Apr 26, 2019
@mglaman
Copy link
Owner

mglaman commented Apr 26, 2019

The problem is this line in the .install file.

/**
 * Loads the basic data to be stored for all tabledrag examples.
 */
module_load_include('inc', 'tabledrag_example', 'tabledrag_example.data');

I may need to tag a new phpstan-drupal release.

@mglaman
Copy link
Owner

mglaman commented Apr 28, 2019

The problem is definitely in the .install file for tabledrag_example

@mglaman mglaman added the upstream Ticket involves dependencies label May 3, 2019
@mglaman mglaman added this to Needs triage in Issue triage May 3, 2019
@mglaman mglaman moved this from Needs triage to High priority in Issue triage May 3, 2019
@prudloff-insite
Copy link

Hello,
I am getting a similar error when realistic_dummy_content is installed:

\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.

If I remove this module, I don't get this error anymore.

@mglaman
Copy link
Owner

mglaman commented May 13, 2019

This will be fixed in 1.0.10 to not be a hard failure.

@mglaman
Copy link
Owner

mglaman commented Jun 14, 2019

Releasing 1.0.10 shortly, please test. It should recover this error and just print it.

@mglaman mglaman closed this as completed Jun 14, 2019
Issue triage automation moved this from High priority to Closed Jun 14, 2019
@prudloff-insite
Copy link

I confirm this is fixed in 1.0.10, thanks!

@adamfranco
Copy link
Author

I can confirm this is fixed in 1.0.10 as well. Thanks!

Screen Shot 2019-06-17 at 11 12 04 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
drupal code phpstan-drupal Issue relates to PHPStan Drupal extension upstream Ticket involves dependencies
Projects
Issue triage
  
Closed
Development

No branches or pull requests

3 participants