Commit 07daa79e authored by catch's avatar catch
Browse files

Issue #3163500 by lauriii, jungle, raman.b, JeroenT, catch, longwave,...

Issue #3163500 by lauriii, jungle, raman.b, JeroenT, catch, longwave, larowlan: Detect when libraries-override or libraries-extend is used on deprecated library
parent 0774f689
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -136,6 +136,11 @@ protected function applyLibrariesExtend($extension, $library_name, $library_defi
    $libraries_extend = $this->themeManager->getActiveTheme()->getLibrariesExtend();
    if (!empty($libraries_extend["$extension/$library_name"])) {
      foreach ($libraries_extend["$extension/$library_name"] as $library_extend_name) {
        if (isset($library_definition['deprecated'])) {
          $extend_message = sprintf('Theme "%s" is extending a deprecated library.', $extension);
          $library_deprecation = str_replace('%library_id%', "$extension/$library_name", $library_definition['deprecated']);
          @trigger_error("$extend_message $library_deprecation", E_USER_DEPRECATED);
        }
        if (!is_string($library_extend_name)) {
          // Only string library names are allowed.
          throw new InvalidLibrariesExtendSpecificationException('The libraries-extend specification for each library must be a list of strings.');
+5 −0
Original line number Diff line number Diff line
@@ -382,6 +382,11 @@ protected function applyLibrariesOverride($libraries, $extension) {
      foreach ($libraries as $library_name => $library) {
        // Process libraries overrides.
        if (isset($libraries_overrides["$extension/$library_name"])) {
          if (isset($library['deprecated'])) {
            $override_message = sprintf('Theme "%s" is overriding a deprecated library.', $extension);
            $library_deprecation = str_replace('%library_id%', "$extension/$library_name", $library['deprecated']);
            @trigger_error("$override_message $library_deprecation", E_USER_DEPRECATED);
          }
          // Active theme defines an override for this library.
          $override_definition = $libraries_overrides["$extension/$library_name"];
          if (is_string($override_definition) || $override_definition === FALSE) {
+14 −0
Original line number Diff line number Diff line
@@ -5,3 +5,17 @@ theme_stylesheets_override_and_remove_test:
      css/base-remove.css: {}
      css/sub-override.css: {}
      css/sub-remove.css: {}

deprecated_library:
  version: VERSION
  css:
    base:
      css/foo.css: {}
  deprecated: 'The "%library_id%" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com'

another_deprecated_library:
  version: VERSION
  css:
    base:
      css/bar.css: {}
  deprecated: 'The "%library_id%" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com'
+10 −0
Original line number Diff line number Diff line
@@ -4,3 +4,13 @@ description: 'Test theme to test deprecated functionality.'
version: VERSION
package: Testing
base theme: test_theme

libraries-override:
  theme_test/deprecated_library:
    css:
      base:
        css/foo.css: css/bar.css

libraries-extend:
  theme_test/another_deprecated_library:
    - test_legacy_theme/library
+4 −0
Original line number Diff line number Diff line
library:
  css:
    base:
      css/baz.css: {}
Loading