Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Reading about "versions" in libraries/libraries.api.php:
Each value is an associative array of top-level properties that are entirely overridden by the version.
However, this isn't the case when detecting libraries - only the top level "version arguments" are used.
The work-around is to create a version callback function that first check top level "version arguments" and then all the versions "version arguments":
function mymodule_libraries_get_version($library, $options) {
// Detect the version using library defaults.
$version = libraries_get_version($library, $options);
if (!empty($version)) {
return $version;
}
// Sort versions in descending order (newest first).
krsort($library['versions']);
// Detect the version using version specific overrides.
foreach ($library['versions'] as $version_properties) {
if (isset($version_properties['version arguments'])) {
$options = $version_properties['version arguments'] += $options;
$version = libraries_get_version($library, $options);
if (!empty($version)) {
return $version;
}
}
}
}
Anyway, if there is a new 2.x release please document this better.
Comments