When Drop Drupal 8.8 Support: Remove call to deprecated Libraries function libraries_detect()

Created on 10 March 2020, over 4 years ago
Updated 4 July 2024, 5 months ago

Ran drupal-check against 06ca0ec.

 12/12 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ------------------------------------------------------------------
  Line   image_widget_crop.install
 ------ ------------------------------------------------------------------
  27     Call to deprecated function libraries_detect():
         Will be removed before a stable Drupal 8 release. Please use the
         new library load and managment concepts described at:
         https://www.drupal.org/node/2170763
 ------ ------------------------------------------------------------------

 ------ ------------------------------------------------------------------
  Line   image_widget_crop.module
 ------ ------------------------------------------------------------------
  102    Call to deprecated function libraries_detect():
         Will be removed before a stable Drupal 8 release. Please use the
         new library load and managment concepts described at:
         https://www.drupal.org/node/2170763
 ------ ------------------------------------------------------------------

 ------ ------------------------------------------------------------------
  Line   src/Form/CropWidgetForm.php
 ------ ------------------------------------------------------------------
  132    Call to deprecated function libraries_detect():
         Will be removed before a stable Drupal 8 release. Please use the
         new library load and managment concepts described at:
         https://www.drupal.org/node/2170763
 ------ ------------------------------------------------------------------


 [ERROR] Found 3 errors

📌 Task
Status

Needs work

Version

2.0

Component

Code

Created by

🇺🇸United States FatGuyLaughing

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.

  • 🇨🇦Canada teknocat

    It looks like this is now removed in Drupal 10, yet this module says it is D10 compatible. It did seem to be fine in Drupal 9, right up to 9.5, so I guess they haven't removed the deprecated functions until D10.

    The patch is fine for now, but this should ideally be addressed quickly with a new release that drops D8 support and applies the changes for D10.

  • 🇨🇦Canada teknocat

    After installing this patch it looks like it's still not enough to have it fully working in Drupal 10.

    The next error is: Drupal\libraries\ExternalLibrary\Exception\LibraryDefinitionNotFoundException: The library definition for the library 'cropper' could not be found.

    I will try to submit another patch once I can figure this out.

  • 🇨🇦Canada teknocat

    So after investigating further I understand that in order to continue to use the libraries API the cropper library would really need to be committed to the libraries registry. As that doesn't appear to have been done yet, using libraries doesn't seem like the best short-term option.

    For maximum compatibility and to allow developers to choose their preferred option, I would suggest allowing for the use of the composer merge plugin to install the library locally from bower-assets. That can be one option, with libraries as a second, falling back on the CDN if it's not available locally.

    I'm suggesting libraries as the second option to prevent the library definition not found error if it tries to use that method first. I have looked at how the Dropzone module checks for it's requirement of the dropzone js library in it's hook_requirements, which provides optimum compatibility (though it is still using some deprecated functions).

    I will submit a patch once I've found a decent solution, though it won't guarantee that it'll work with libraries until somebody else can fully test it that way.

  • 🇨🇦Canada teknocat

    I have pushed a commit to my issue fork and attached a patch for use in the short term.

    These changes seem to work on Drupal 10 so far, but will need testing on other Drupal versions, as well as a review by the community to determine if this seems like an appropriate solution for optimal compatibility.

    I think it might be worth creating a new D10-only branch, however, so that dependency injection can be used properly in the form class instead of \Drupal::service() to load the libraries directory file finder service available in newer Drupal versions.

  • The last submitted patch, 17: 3119005-17.patch, failed testing. View results
    - codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • Status changed to Needs work almost 2 years ago
  • 🇨🇦Canada teknocat

    My previous patch would not apply against the 8.x-2.4 release of the module, only against the current 8.x-2.x branch.

    Here is a patch that will apply against the 8.x-2.4 release.

  • 🇨🇦Canada teknocat

    I'm sorry I don't know how to update the automated tests, so that will likely need work, plus some other tweaks before these changes can be accepted. However, upon apply my second patch to my current live D10 installation, it does work and the status report page does indeed show it as correctly configured. It says it's using Libraries API files even though I'm using the composer merge plugin, so that's one of the minor things that might be prudent to update as well.

    But suffice it to say, the patch works to eliminate errors and get it working fully in D10 for now.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    Patch Failed to Apply
  • 🇭🇺Hungary Balu Ertl Budapest 🇪🇺

    Notes: Some docs I managed to found for this libraries_detect() function in Drupal 7.

Production build 0.71.5 2024