Problem/Motivation

We currently have this in our LibraryDiscoveryParser class:

    if ($extension === 'core') {
      $path = 'core';
      $extension_type = 'core';
    }
    else {
      if ($this->moduleHandler->moduleExists($extension)) {
        $extension_type = 'module';
      }
      else {
        $extension_type = 'theme';
      }
      $path = $this->drupalGetPath($extension_type, $extension);
    }

This was only meant as a temporary 'hack' with the plan to remove this in favour of getting this from a parameter instead.

Proposed resolution

Either:

1. Pass the $type into LibraryDiscoveryInterface::getLibrariesByExtension/getLibraryByName
2. Pass an Extension object around instead, as this hold the extension type ($extension->getType())
3. Determine the extension type another way?

Remaining tasks

Discuss, decide, patch, tests.

User interface changes

None

API changes

None

Comments

sun’s picture

Issue tags: +API clean-up

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

rodrigoaguilera’s picture

Title: Pass extension type (or Extension instance?) into Library discovery » Library discovery Parser tries to guess extension type assuming 'theme' for non-existing modules
Version: 8.6.x-dev » 8.7.x-dev
Category: Task » Bug report
Issue summary: View changes
Status: Active » Needs review
Issue tags: -API clean-up
StatusFileSize
new874 bytes

I think that code is now at
LibraryDiscoveryParser

I found a bug trying to get a library from a module that was not enabled with
LibraryDiscovery::getLibraryByName

Giving me the following error

Error message
User warning: The following theme is missing from the file system: example_module in drupal_get_filename() (line 276 of core/includes/bootstrap.inc). 

I feel the solution is closely related to this issue.

I think it can be solved by following proposed resolution number 3. That way we can avoid changing the API since we can detect the type of the extension using handler services available.

This was only meant as a temporary 'hack' with the plan to remove this in favour of getting this from a parameter instead.

If we can guess the type there is no need to pass it earlier.

Let me illustrate first with the attached test test (I hope it produces the warning mentioned above)

Status: Needs review » Needs work

The last submitted patch, 8: test-only-2279551-guess-extension-8.patch, failed testing. View results

rodrigoaguilera’s picture

Title: Library discovery Parser tries to guess extension type assuming 'theme' for non-existing modules » [PP-1] Library discovery Parser tries to guess extension type assuming 'theme' for non-existing modules
Status: Needs work » Postponed
Related issues: +#2347783: Deprecate drupal_get_path() and drupal_get_filename() and replace with ExtensionList::getPath() and ExtensionList::getPathname()

After reading more issues I realized this will be half-solved by
#2347783: Deprecate drupal_get_path() and drupal_get_filename() and replace with ExtensionList::getPath() and ExtensionList::getPathname()
Because at least it will raise an exception.

Let's wait for that issue to be solved before addressing this.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

gábor hojtsy’s picture

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

daffie’s picture

Title: [PP-1] Library discovery Parser tries to guess extension type assuming 'theme' for non-existing modules » Library discovery Parser tries to guess extension type assuming 'theme' for non-existing modules
Status: Postponed » Needs work
larowlan’s picture

Category: Bug report » Task
Issue tags: +Bug Smash Initiative

Triaged this as part of Bug smash initiative

As this is an API cleanup, its less of a bug and more of a task

Reclassifying as such

larowlan’s picture

Status: Needs work » Closed (duplicate)