Problem/Motivation

This class uses a class property for static caching, but it's a very thin wrapper around the cache collector which also does static caching. Probably we had this before we added the cache collector.

We can make library.discovery just be the cache collector itself without the extra service/class, less indirection.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3462871

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

catch created an issue. See original summary.

catch’s picture

Status: Active » Needs review

catch’s picture

The test coverage removed here was added in #2378263: hook_library_alter() must be manually invoked by users of LibraryDiscovery, and has no test coverage, this add a hook_library_alter:

  public function getLibrariesByExtension($extension) {
-    return $this->collector->get($extension);
+    if (!isset($this->libraryDefinitions[$extension])) {
+      $libraries = $this->collector->get($extension);
+      $this->libraryDefinitions[$extension] = [];
+      foreach ($libraries as $name => $definition) {
+        // Allow modules and themes to dynamically attach request and context
+        // specific data for this library; e.g., localization.
+        $library_name = "$extension/$name";
+        $this->moduleHandler->alter('library', $definition, $library_name);
+        $this->libraryDefinitions[$extension][$name] = $definition;
+      }

Then we removed hook_library_alter() in #2472547: Remove deprecated hook_library_alter() and the test was left testing the static caching in LibraryDiscovery, but without checking whether it was still necessary or not.

catch’s picture

Title: LibraryDiscoveryCollector caches unnecessarily » Deprecate LibraryDiscovery and use LibraryDiscoveryCollector instead
Issue summary: View changes

Let's do the deprecation here.

Once it's merged, a couple of the methods are redundant, so we should probably deprecate those too, but maybe those in a follow-up.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new3.82 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

catch’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
catch’s picture

Status: Reviewed & tested by the community » Needs review

Errm, needs review.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Deprecation seems fine, version wise.

Not 100% if all deprecations need a test to make sure the deprecation is returned. I feel like we know that feature works.

catch’s picture

Not 100% if all deprecations need a test to make sure the deprecation is returned. I feel like we know that feature works.

Generally I think we should not do this, and only test deprecations triggered by actual backwards compatibility logic rather than from within deprecated code that's going to be removed. It takes time to write the test, run them every CI run, then remove them again, and they don't tell us much.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new1.77 MB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

nod_’s picture

Status: Needs work » Reviewed & tested by the community

bot has issues

nod_’s picture

Status: Reviewed & tested by the community » Fixed

Committed 1c7a0b5 and pushed to 11.x. Thanks!

  • nod_ committed 1c7a0b50 on 11.x
    Issue #3462871 by catch, smustgrave: Deprecate LibraryDiscovery and use...
nod_’s picture

  • nod_ committed fd8e5aa2 on 11.x
    Issue #3462871 by nod_: Followup for Deprecate LibraryDiscovery and use...

nod_’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.