Add hook_requirements() to check library and print status report

Created on 6 November 2023, about 1 year ago
Updated 13 September 2024, 3 months ago

Problem/Motivation

On the module page it says that 1.9.x of https://www.datatables.net/download/ is required.
In datatables.libraries.yml it says

datatables_core:
  version: 1.10

While there is already a version 1.13.x available.

Does it produce problems upgrading to the current 2.x-dev while not updating the library from 1.9.4 to 1.10 or higher?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ“Œ Task
Status

Fixed

Version

2.0

Component

Documentation

Created by

๐Ÿ‡ฆ๐Ÿ‡นAustria maxilein

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

Merge Requests

Comments & Activities

  • Issue created by @maxilein
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance Chris64 France

    Indeed @maxilein, the library version is an important subject. The new 2.0 module release allows to use the 1.10 datatables library version. See ๐Ÿ“Œ [META] Keep track of jQuery DataTables library updates in the Drupal implementation Needs review . In the installed system it is possible to know the datatables library 1.10 version used using command composer show datatables/datatables. Actually 1.10.21.

  • Status changed to Needs review 11 months ago
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance Chris64 France
  • ๐Ÿ‡ฆ๐Ÿ‡นAustria maxilein

    Thank you. Now I can figure out which problems come from a higher library ...

    Maybe it is possible to add a warning on the status page if the library is not the expected version. That always helps a lot to identify problems.

    Something like:

    datatables needs datatables/datatables 1.10.21. The version in the libraries folder is 1.XX and not currently supported.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance Chris64 France

    @maxilein, actually installing the datatables library with composer is possible but rather not simple.The next step now is to install this library in simple way via composer (See ๐Ÿ“Œ The module needs a composer.json file Needs review ). The means to get the library version with the drush show command would be explained in the README.md file. However, indeed, this version should be reflected in a code file, like .libraries.yml as you suggest in the IS.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom kingfisher64

    Hello,

    I'm trying to install the data tables module, however, it doesn't look like the library is installed properly. Every now and again I get the following notice:

    Warning: file_get_contents(libraries/datatables/media/js/jquery.dataTables.js): Failed to open stream: No such file or directory in Drupal\Core\Asset\JsOptimizer->optimize() (line 39 of core/lib/Drupal/Core/Asset/JsOptimizer.php).

    I have copied the library from vendor to libraries/datatables/datatables as the documentation.

    Is there a way to put the library status under "status report"? I only suggest there as webform and other mods put it there.

  • Arijit Acharya โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Indranil Roy kolkata

    Hi,

    I have tested the MR, and it is working fine for me. Here are the steps I followed:

    1. Installed the module.
    2. Applied the patch.
    3. Installed the required libraries as described in the readme file.

    After installing the libraries properly, the error message no longer appears on the status report page.

  • Status changed to RTBC 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Indranil Roy kolkata
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance dqd London | N.Y.C | Paris | Hamburg | Berlin

    Good finding and good work. +1

  • Pipeline finished with Skipped
    4 months ago
    #269418
  • Status changed to Fixed 4 months ago
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance dqd London | N.Y.C | Paris | Hamburg | Berlin
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States NicholasS

    I am confused, I have updated datatables, but status report says I am missing assets.

    This added a check for the following assets
    https://git.drupalcode.org/project/datatables/-/blob/2.x/datatables.modu...

    // Check if the essential CSS and JavaScript files exist.
        $essential_assets = [
          'css' => ['jquery.dataTables.css', 'dataTables.bootstrap.css'],
          'js' => ['jquery.dataTables.js', 'dataTables.bootstrap.js'],
        ];

    But the libraries.yml only loads the non-bootstrap assets.

    datatables_core:
      version: 1.10
      js:
        /libraries/datatables/media/js/jquery.dataTables.js: {}
      css:
        component:
          /libraries/datatables/media/css/jquery.dataTables.css: {}
      dependencies:
        - core/jquery

    So how are we supposed to load the dataTables.bootstrap.css dataTables.bootstrap.js assets? There is nothing in the readme about that. It seems like those should be removed from the status page check for correct assets, some projects don't use bootstrap.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States NicholasS

    Looks like the path to check for assets is incorrect, composer does not place the datatables library in a subfolder called datatables.

    I'll create a new issue about this.

Production build 0.71.5 2024