Verify that the library files exist

Created on 2 April 2014, over 11 years ago
Updated 5 June 2025, about 2 months ago

Problem/Motivation

Library API can find files also into the /libraries folder so it could be used for manage external libraries defined in contrib modules (i.e. to hold javascript file with a different license than Drupal). These modules require a way to verify the existence of the required files (maybe in hook_requirements) so they can notify the user to download the library into the /libraries folder.

Proposed resolution

We could add a new method into LibraryDiscovery class to verify that required files exist.

Remaining tasks

  • The patch is ready for review
  • Tests to be written
  • Documentation to be written

User interface changes

None

API changes

None (just a new method added to the class LibraryDiscovery)

Feature request
Status

Needs work

Version

11.0 🔥

Component

asset library system

Created by

🇮🇹Italy lussoluca Italy

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • 🇫🇷France Grimreaper France 🇫🇷

    Hi,

    Regarding patch from comment 8, when looking for dependencies:

        if (array_key_exists('dependencies', $library)) {
          foreach ($library['dependencies'] as $dependency) {
            $parts = explode('/', $dependency, 2);
            $dependencyLibrary = $this->getLibraryByName($parts[0], $parts[1]);
            $valid = $this->isLibraryValid($dependencyLibrary);
          }
        }
    

    I think it should return FALSE as soon as a dependency is not satisfied.

  • 🇫🇷France Grimreaper France 🇫🇷

    And also before the dependencies, as soon as file is not found it should return FALSE.

  • Merge request !12315Resolve #2231385 "Verify that the" → (Open) created by Grimreaper
  • 🇫🇷France Grimreaper France 🇫🇷

    MR created from patch 8 + my suggestion.

    Test not copied because a test file with the same name exists now in Core.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 197s
    #515068
Production build 0.71.5 2024