Hi, I'm seeing the following error when scanning deprecation through both UI and Drush command

 [error]  TypeError: Argument 1 passed to Drupal\upgrade_status\DeprecationMessage::setFile() must be of the type string, null given, called in /var/www/mint/docroot/modules/contrib/upgrade_status/src/LibraryDeprecationAnalyzer.php on line 148 in Drupal\upgrade_status\DeprecationMessage->setFile() (line 92 of /var/www/mint/docroot/modules/contrib/upgrade_status/src/DeprecationMessage.php) #0 /var/www/mint/docroot/modules/contrib/upgrade_status/src/LibraryDeprecationAnalyzer.php(148): Drupal\upgrade_status\DeprecationMessage->setFile(NULL)
#1 /var/www/mint/docroot/modules/contrib/upgrade_status/src/LibraryDeprecationAnalyzer.php(96): Drupal\upgrade_status\LibraryDeprecationAnalyzer->analyzeLibraryDependencies(Object(Drupal\Core\Extension\Extension))
#2 /var/www/mint/docroot/modules/contrib/upgrade_status/src/DeprecationAnalyzer.php(309): Drupal\upgrade_status\LibraryDeprecationAnalyzer->analyze(Object(Drupal\Core\Extension\Extension))
#3 /var/www/mint/docroot/modules/contrib/upgrade_status/src/Commands/UpgradeStatusCommands.php(261): Drupal\upgrade_status\DeprecationAnalyzer->analyze(Object(Drupal\Core\Extension\Extension))
#4 /var/www/mint/docroot/modules/contrib/upgrade_status/src/Commands/UpgradeStatusCommands.php(145): Drupal\upgrade_status\Commands\UpgradeStatusCommands->doAnalyze(Array, Array)
#5 [internal function]: Drupal\upgrade_status\Commands\UpgradeStatusCommands->analyze(Array, Array)
#6 /var/www/mint/vendor/consolidation/annotated-command/src/CommandProcessor.php(257): call_user_func_array(Array, Array)
#7 /var/www/mint/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#8 /var/www/mint/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#9 /var/www/mint/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(302): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#10 /var/www/mint/vendor/symfony/console/Command/Command.php(255): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/mint/vendor/symfony/console/Application.php(1005): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/mint/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/mint/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/mint/vendor/drush/drush/src/Runtime/Runtime.php(118): Symfony\Component\Console\Application->run(Object(Drush\Symfony\DrushArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/mint/vendor/drush/drush/src/Runtime/Runtime.php(49): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/mint/vendor/drush/drush/drush.php(72): Drush\Runtime\Runtime->run(Array)
#17 /var/www/mint/vendor/drush/drush/includes/preflight.inc(18): require('/var/www/mint/v...')
#18 phar:///usr/local/bin/drush/bin/drush.php(141): drush_main()
#19 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#20 {main}. 

It looks like the file variable doesn't exist for the second if statement and thus causing the error.

error

The error is currently blocking deprecation scanning on module/theme library file with deprecated dependencies because the scanned result is now showing 500 error as problem instead of the actual deprecated issue.

scan issue

I'm seeing the same error on both 3.x-dev and 3.0-beta2.

I haven't tested it on 2.x version yet.

Reproducible steps:

1. Go to any module/theme with `.libraries.yml` file
2. Change one of the dependencies of any library to a non-existing library

for example:

from

drupal:
  version: VERSION
  js:
    misc/drupal.js: { weight: -18 }
  dependencies:
    - core/drupalSettings

to

drupal:
  version: VERSION
  js:
    misc/drupal.js: { weight: -18 }
  dependencies:
    - foo/drupalSettings

Since the dependency "foo/drupalSettings" doesn't exist, it will be detected as a deprecation issue by this module.

3. Clear cache

4. Run the scan against the module/theme and you should see the error.

Comments

sker101 created an issue. See original summary.

sker101’s picture

Here's a patch that declares the file variable outside the foreach loop since the variable value would most likely stay the same for each loop and also allowing the second if statement to access the variable.

sker101’s picture

Issue summary: View changes
StatusFileSize
new52.75 KB
sker101’s picture

Issue summary: View changes

It looks like the error is only thrown when scanning themes.

sker101’s picture

Issue summary: View changes

Ok, it looks like it's not just the theme.

Reproducible steps added.

  • Gábor Hojtsy committed eb0c099 on 8.x-3.x
    Issue #3178187 by sker101: Error "TypeError: Argument 1 passed to Drupal...
gábor hojtsy’s picture

Status: Active » Fixed

Good find, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.