Problem/Motivation
When I attempt to scan a module with a node_modules that includes the normalize.css package the scan completes and reports 1 problem but it's just a stack trace and nothing was actually scan.
Here's the last few bits from the giant call stack:
Notice: file_get_contents(): Read of 8192 bytes failed with errno=21 Is a directory in /app/docroot/modules/contrib/upgrade_status/src/CSSDeprecationAnalyzer.php on line 29
Call Stack:
[...]
2.3305 6890880 16. call_user_func_array:{/app/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123}($callback = [0 => class Drupal\upgrade_status\Controller\ScanResultController { protected $entityTypeManager = NULL; protected $entityFormBuilder = NULL; protected $languageManager = NULL; protected $configFactory = NULL; protected $keyValue = NULL; protected $currentUser = NULL; protected $stateService = NULL; protected $moduleHandler = NULL; protected $formBuilder = NULL; protected $loggerFactory = NULL; protected $messenger = NULL; protected $redirectDestination = NULL; protected $stringTranslation = NULL; protected $resultFormatter = class Drupal\upgrade_status\ScanResultFormatter { ... }; protected $projectCollector = class Drupal\upgrade_status\ProjectCollector { ... }; protected $renderer = class Drupal\Core\Render\Renderer { ... } }, 1 => 'analyze'], $args = [0 => 'custom_theme']) /app/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123
2.3305 6890952 17. Drupal\upgrade_status\Controller\ScanResultController->analyze($project_machine_name = 'custom_theme') /app/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php:123
2.8117 9084784 18. Drupal\upgrade_status\DeprecationAnalyzer->analyze($extension = class Drupal\Core\Extension\Extension { protected $type = 'theme'; protected $pathname = 'themes/custom/custom_theme/custom_theme.info.yml'; protected $filename = 'custom_theme.theme'; protected $splFileInfo = NULL; protected $root = '/app/docroot'; public $subpath = 'themes/custom/custom_theme'; public $origin = ''; public $info = ['name' => 'Custom Theme', 'type' => 'theme', 'description' => 'custom_theme.org website theme.', 'base theme' => 'stable', 'core_version_requirement' => '^9 || ^10', 'libraries' => [...], 'ckeditor_stylesheets' => [...], 'regions' => [...], 'logo' => 'images/logo.svg', 'components' => [...], 'core_incompatible' => FALSE, 'lifecycle' => 'stable', 'mtime' => 1675372635, 'engine' => 'twig', 'features' => [...], 'screenshot' => 'themes/custom/custom_theme/screenshot.png', 'version' => NULL, 'php' => '7.3.0', 'libraries_extend' => [...], 'libraries_override' => [...], 'dependencies' => [...], 'regions_hidden' => [...], 'upgrade_status_type' => 'custom', 'upgrade_status_next_major_compatible' => TRUE, 'project' => 'custom_theme', 'upgrade_status_next' => 'scan']; public $owner = 'core/themes/engines/twig/twig.engine'; public $prefix = 'twig'; public $status = 1; public $required_by = []; public $requires = ['stable' => class Drupal\Core\Extension\Dependency { ... }]; public $sort = -3; public $base_themes = ['stable' => 'Stable']; public $module_dependencies = [] }, $options = ???) /app/docroot/modules/contrib/upgrade_status/src/Controller/ScanResultController.php:138
80.7649 15888072 19. Drupal\upgrade_status\CSSDeprecationAnalyzer->analyze($extension = class Drupal\Core\Extension\Extension { protected $type = 'theme'; protected $pathname = 'themes/custom/custom_theme/custom_theme.info.yml'; protected $filename = 'custom_theme.theme'; protected $splFileInfo = NULL; protected $root = '/app/docroot'; public $subpath = 'themes/custom/custom_theme'; public $origin = ''; public $info = ['name' => 'Custom Theme', 'type' => 'theme', 'description' => 'custom_theme.org website theme.', 'base theme' => 'stable', 'core_version_requirement' => '^9 || ^10', 'libraries' => [...], 'ckeditor_stylesheets' => [...], 'regions' => [...], 'logo' => 'images/logo.svg', 'components' => [...], 'core_incompatible' => FALSE, 'lifecycle' => 'stable', 'mtime' => 1675372635, 'engine' => 'twig', 'features' => [...], 'screenshot' => 'themes/custom/custom_theme/screenshot.png', 'version' => NULL, 'php' => '7.3.0', 'libraries_extend' => [...], 'libraries_override' => [...], 'dependencies' => [...], 'regions_hidden' => [...], 'upgrade_status_type' => 'custom', 'upgrade_status_next_major_compatible' => TRUE, 'project' => 'custom_theme', 'upgrade_status_next' => 'scan']; public $owner = 'core/themes/engines/twig/twig.engine'; public $prefix = 'twig'; public $status = 1; public $required_by = []; public $requires = ['stable' => class Drupal\Core\Extension\Dependency { ... }]; public $sort = -3; public $base_themes = ['stable' => 'Stable']; public $module_dependencies = [] }) /app/docroot/modules/contrib/upgrade_status/src/DeprecationAnalyzer.php:419
82.6766 16361552 20. file_get_contents($filename = '/app/docroot/themes/custom/custom_theme/node_modules/normalize.css') /app/docroot/modules/contrib/upgrade_status/src/CSSDeprecationAnalyzer.php:29 {"message":"Scanned custom_theme"}
I'm able to work around the issue by temporarily renaming the normalize.css directory to something without the .css suffix.
Steps to reproduce
- Run
npm install normalize.cssin a theme folder. - Attempt to scan the theme.
Proposed resolution
Prevent the scanner from evaluating files in node_modules? #3162997: Exclude node_modules from scan is somewhat related but this appears to be a different (and, indeed, the files in node_modules do not get reported on when i work around the issue).
Remaining tasks
Determine how to prevent this issue and create a patch.
| Comment | File | Size | Author |
|---|
Issue fork upgrade_status-3338745
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wellsComment #3
gábor hojtsyWe indeed have a few exclusions in the neon file but that does not expand to the CSS Deprecation analyzer. We can port the directory specific checks explicitly there. Such as this one? Throwed in a
!is_dircheck for good. While that itself would be enough to directly fix this issue, this fix would avoid unnecessarily scanning files that are undernode_modulesorbower_components.Comment #4
wellsFix makes sense and the patch applies and resolves the issue. Marking RTBC. Thanks!
Comment #5
joelpittetYou could also use
$ignore_directories = Settings::get('file_scan_ignore_directories', []);which uses has those listed (and any other similar directories or custom ones).But this just the trick for a good chunk of these. Thanks I'll leave it RTBC
Comment #6
randallquesadaa commentedI had exactly the same problem described and the patch #3 worked great for me.
Comment #7
norman.lolRTBC++
Comment #8
gábor hojtsySlightly earlier the ".css in directory name considered a file" problem was resolved in #3324201: CSSDeprecationAnalyzer::getAllCSSFiles() returns directories with a name that ends in ".css", but the code would still traverse into the non-intended directories and find CSS files there, even though it should not. I adapted the patch based on the suggestion from @joelpittet, so the behaviour is more adaptive to site configuration. Please review the MR, I am hiding the patch.
Comment #10
gábor hojtsyComment #11
gábor hojtsyUpdating credits. Tests prove this works well.
Comment #13
gábor hojtsy