Allow modules to remain uninstalled if they have no libraries data

Created on 22 August 2022, over 2 years ago
Updated 30 August 2024, 4 months ago

Problem/Motivation

Upgrade Status shows an error if a module is uninstalled. This is so that it can perform library analysis regardless if the module influences the site's library definitions:

    if (!in_array($extension->getName(), $installed_modules) && !in_array($extension->getName(), $installed_themes)) {
      $message = sprintf("The '%s' extension is not installed. Cannot check deprecated library use.", $extension->getName());

Proposed resolution

Check the following first:

* Has libraries.yml
* Has hook_library_info_build
* Has hook_library_info_alter

If those are false, just ignore analysis. We want modules which implement hook_library_info_alter to be installed to know the true state of library definitions

Remaining tasks

Make this proper:

  private function analyzeLibraryDependencies(Extension $extension): array {
    $library_file = sprintf('%s/%s.libraries.yml', $extension->getPath(), $extension->getName());
    $has_hook = \Drupal::moduleHandler()->hasImplementations('library_info_build', $extension->getName());
    if (!$has_hook && !file_exists($library_file)) {
      return [];
    }

User interface changes

API changes

Data model changes

โœจ Feature request
Status

Needs work

Version

4.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States mglaman WI, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ท๐Ÿ‡บRussia ilya.no

    I'm not sure, whether this issue is related to my problem, but in custom theme I have dependency on `jquery_ui_selectmenu/selectmenu` and it causes the error, saying, that library `is not defined because the defining extension is not installed. Cannot decide if it is deprecated or not`. The problem is that module `jquery_ui_selectmenu` is installed, but it doesn't have any libraries, because its library is added by `jquery_ui` module in `library_info` hook.

    Attaching the patch, which fixes this issue.

  • ๐Ÿ‡ท๐Ÿ‡บRussia ilya.no

    Attaching reroll for the latest version.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary Gรกbor Hojtsy Hungary

    My comment in #4 still stands that this undoes the reporting that there may be deprecated API uses that cannot be detected because its not enabled, given the hasImplementations() will not find the hook if the module is disabled and thus the patched code will return no errors.

Production build 0.71.5 2024