There isn't any way to define the maximum supported library version If you have a module that needs a specific older jQuery library version, because the newest version isn't tested or has some compatibility issues with other modules.

You can however define multiple supported version in your hook_libraries_info(). But it only checks if the library itself is equal or higher than the supported versions.

This doesn't allow the option for module maintainers to say through hook_requirements(): 'We support version 2.9 to 4.3, but not 4.4 or higher, because 4.4 or higher needs a rewrite of this module.'

Also the 'versions' array is unset, what could be very handy for your hook_requirements().

At the end this patch could help with downsizing the support questions in issue queues about library versions that doesn't work.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Tessa Bakker created an issue. See original summary.

Tess Bakker’s picture

Status: Active » Needs review
FileSize
1.65 KB

Example code to make version 3 or higher unsupported with the patch:

    'versions' => array(
      '2.1.2' => array(
        'files' => array(
          'js' => array(
            'jquery.imagesloaded.min.js',
          ),
        ),
      ),
      '3' => array(), // Unsupported
    ),

Status: Needs review » Needs work

The last submitted patch, 2: allow_to_define_the-2567525-2.patch, failed testing.

Tess Bakker’s picture

FileSize
5.08 KB

New patch, with tests for 'version too low' and 'version too high'.

In favor of succeeding the tests, I didn't remove the 'versions' element in the library array as seen in the first patch.

Tess Bakker’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: allow_to_define_the-2567525-4.patch, failed testing.

tstoeckler’s picture

Priority: Normal » Major

Wow, I had always assumed specifying a max version was somehow possible, but you may be right, that we are missing this in the current implementation. Thanks for starting this!

Tess Bakker’s picture

:) Let me know if I need to change something, couldn't found 'Failing Test' problem with the current patch.