Problem/Motivation

ActiveTheme::getStyleSheetRemove() was marked as deprecated, but does not trigger a deprecation error.

Proposed resolution

This is a little tricky because the method is still used in core. In 8.0.x we 'deprecated' the stylesheets-remove key in theme info.yml files, but didn't quite know what we were doing. Here we should trigger an error if we detect a theme using that key, and test that the error is triggered. A decision should be made to either undeprecated the getStyleSheetRemove method until drupal 9 when it is no longer used, or to allow an exception to the deprecation policy and mark it deprecated with no trigger errir

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

mikelutz created an issue. See original summary.

voleger’s picture

Issue summary: View changes
Status: Active » Postponed
Issue tags: +Drupal 9
StatusFileSize
new1.58 KB

Here the patch, But it's deprecation removal without replacement. So postpone it on 9.x.

mikelutz’s picture

This still needs work in D8, and it looks to be a bigger issue than I had originally realized. Flipping through the original issue when libraries-override was added way back in 8.0.x-RC, it looks like the intention was to deprecate the stylesheets-remove key in the theme yml files to be removed in Drupal 9. We didn't know how to do deprecations then, and the CRs don't mention the deprecation of stylesheets-remove. The only real documentation is the @todo remove in drupal 9 spread throughout the system.

First, we need to confirm with RM and/or front end FM that stylesheet-remove should and can still be deprecated.
Then we need to properly deprecate it by detecting its use on discovery and triggering a deprecation error so themes can know to stop using it
And we need a proper change record indicating that it will not be supported in Drupal 9
Finally the BC layer supporting it for Drupal 8 needs to have proper @internal annotations, and a follow up issue to actually do the removal when the branch opens.

As it sits, the @deprecated tag on ActiveTheme::getStyleSheetsRemove() can't stay there because core needs to use that method, and we can't remove support for that key in Drupal 9 without proper deprecation and CRs and documentation.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new1.52 KB

This deprecates it explicitly by doing a @trigger_error() on discovery, including naming the theme that uses this feature.

IMHO keeping getStyleSheetsRemove() as @deprecated without a @trigger_error() is fine, it really is deprecated, so seems strange to change to @internal or so, which also wouldn't be correct as it is not an internal helper function, it is a public API, just deprecated.

There are almost no reasons for calling it anyway, http://grep.xnddx.ru/search?text=getStyleSheetsRemove shows just a few special theme things as well s devel/webprofiler which are just calling it to show the info. So I wouldn't worry about it too much.

We have two test themes that are using the deprecated key, but I suspect they are used in quite a few tests and we'll need to move that to separate test themes that we only use for a single deperecation test. So this should have a chunk of failing tests.

Status: Needs review » Needs work

The last submitted patch, 4: stylesheet-remove-3069052-4.patch, failed testing. View results

mikelutz’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update
StatusFileSize
new3.11 KB
new1.59 KB

Lets convert the stylesheet-remove on those two themes over to libraries-override syntax and see if anything breaks. If not, then we can add an explicit test for the deprecation system around the stylesheet-remove key.

I've come around to the opinion regarding these methods that we use but are deprecated should just be undeprecated until Drupal 9 opens. The method shouldn't be deprecated right now because it is used. as soon as the 9.0.x branch opens, the method use can be removed, and it can sit there and be deprecated and return an empty array and trigger an error until Drupal 10, becuase at that point it is unneeded and so that is when it should be deprecated. I realize that is just a hard line by-the book approach that doesn't really take into account how much the method is used at all, so I'm more than happy to be overruled, I just feel like a public method on an object provided by the theme manager probably shouldn't just disappear per our BC policies, but there's not reason it can't just sit there doing nothing during the D9 cycle.

Status: Needs review » Needs work
mikelutz’s picture

Status: Needs work » Needs review
StatusFileSize
new3.98 KB
new1.4 KB

There's a third theme that uses it, and I didn't use it correctly in one spot.

berdir’s picture

Status: Needs review » Needs work

Looks good, need a test theme for deprecation testing and a corresponding test now :)

mikelutz’s picture

Title: Properly deprecate ActiveTheme::getStyleSheetsRemove() » Properly deprecate the stylesheets-remove key from theme info.yml files.
Status: Needs work » Needs review
StatusFileSize
new4.89 KB
new6.88 KB

Here's a dedicated test, and I'm un-deprecating the getStyleSheetsRemove method because I think the correct thing to do is deprecate it in Drupal 9 once it's no longer needed. If there's serious objection, I'll do something different, but I hate having a deprecated method that we can't trigger an error from. I really feel like the right thing to do is deprecated it once it's no longer needed/used by core.

Status: Needs review » Needs work
mikelutz’s picture

Status: Needs work » Needs review
StatusFileSize
new8.29 KB
new4.75 KB

Let's base the legacy test theme off of classy. I don't want to have to add it to the subtheme list on another test.

Thinking/looking further for precedence on the idea of undeprecating ActiveTheme::getStyleSheetsRemove(), I notice that ThemeInitialization::prepareStylesheetsRemove Effectively performs the same type of a BC layer role and is not deprecated, it only has a @todo to remove in Drupal 9.0.x.

So I've cleaned up the documentation around both to indicate that they should be deprecated in 9.0.x once they are no longer needed.

catch’s picture

I think we can probably mark methods like this @internal and still remove them in the 9.x branch, on the basis absolutely nothing outside the deprecated code paths should be calling them.

mikelutz’s picture

Honestly, even if we couldn't remove it in the 9.0.x branch, I'm all for adding @internal anyway, just to discourage use.

mikelutz’s picture

Actually, let's add @internal to ThemeInitialization::prepareStyleSheetsRemove() as well.

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.

longwave’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

#15 needs rerolling due to conflict in core/lib/Drupal/Core/Theme/ActiveTheme.php

ravi.shankar’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new8.33 KB

Here I have added a re-roll.

longwave’s picture

  1. +++ b/core/lib/Drupal/Core/Theme/ActiveTheme.php
    @@ -209,11 +209,19 @@ public function getLibraries() {
    +   * should have it's usages removed and be deprecated once it is no longer
    

    it's -> its

  2. +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
    @@ -312,6 +312,11 @@ protected function resolveStyleSheetPlaceholders($css_file) {
    +   * should have it's usages removed and be deprecated once it is no longer
    

    it's -> its

  3. +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
    @@ -320,7 +325,9 @@ protected function resolveStyleSheetPlaceholders($css_file) {
    +   * @todo Deprecate or remove in Drupal 9.0.x.
    ...
    +        @trigger_error('The theme info key stylesheets-remove implemented by theme ' . $base->getName() . ' is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. See https://www.drupal.org/node/2497313', E_USER_DEPRECATED);
    

    The deprecation is already done?

ravi.shankar’s picture

Status: Needs review » Needs work

Back to NW as per comment #19.

andypost’s picture

  1. +++ b/core/lib/Drupal/Core/Theme/ActiveTheme.php
    @@ -209,11 +209,19 @@ public function getLibraries() {
    +   * This method is used in Drupal 8 as a BC layer to access the contents
    +   * of the deprecated stylesheets-remove key in theme info.yml files.  It
    

    it needs to add trigger_error() to properly deprecate in 8

  2. +++ b/core/lib/Drupal/Core/Theme/ActiveTheme.php
    @@ -209,11 +209,19 @@ public function getLibraries() {
    +   * @todo Deprecate or remove in Drupal 9.0.x.
    
    +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
    @@ -320,7 +325,9 @@ protected function resolveStyleSheetPlaceholders($css_file) {
    +   * @todo Deprecate or remove in Drupal 9.0.x.
    

    @todo require link to issue

  3. +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
    @@ -330,6 +337,7 @@ protected function prepareStylesheetsRemove(Extension $theme, $base_themes) {
           if (!empty($base->info['stylesheets-remove'])) {
    +        @trigger_error('The theme info key stylesheets-remove implemented by theme ' . $base->getName() . ' is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. See https://www.drupal.org/node/2497313', E_USER_DEPRECATED);
    
    @@ -339,6 +347,7 @@ protected function prepareStylesheetsRemove(Extension $theme, $base_themes) {
         if (!empty($theme->info['stylesheets-remove'])) {
    +      @trigger_error('The theme info key stylesheets-remove implemented by theme ' . $theme->getName() . ' is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. See https://www.drupal.org/node/2497313', E_USER_DEPRECATED);
    

    so it was not properly deprecated, looks needs split into 8.x (properly deprecate) and 9.x (remove)

berdir’s picture

> it needs to add trigger_error() to properly deprecate in 8

No, we still have to call this method, as it's still necessary if themes define it.

> so it was not properly deprecated, looks needs split into 8.x (properly deprecate) and 9.x (remove)

That's what the title says and this issue does? Yes, it wasn't _properly_ deprecated, but it already was deprecated in 8.0.

I think we can still remove it from D9, it's already being done in my Drupal\Core issue,

longwave’s picture

Status: Needs work » Needs review
StatusFileSize
new8.3 KB
new2.21 KB

Reworded some comments with stronger intentions and linked the @todos to the existing removal issue.

lauriii’s picture

The deprecation was introduced in #2451411: Add libraries-override to themes' *.info.yml. It doesn't seem like the change record for that issue mentions the deprecation at all: https://www.drupal.org/node/2497313. I tried to search for another change record that would mention this, but it seems like we might not have properly announced that stylesheets-remove is deprecated, and that it will be removed. I discussed this issue with @catch and we thought that we might have to schedule the removal to happen prior to Drupal 10.0.0.

berdir’s picture

Version: 8.9.x-dev » 9.0.x-dev
Issue tags: +Drupal 9.0.0-beta1 requirement
StatusFileSize
new8.73 KB
new4.9 KB
new8.68 KB

Ok, as discussed, updated the patch to change this to a D10 deprecation. I removed the "used in Drupal 8" part, as I think it's not necessary and will be used in 8 and 9.

I think this too is a beta blocker, just like every other D9 deprecation issue?

Also including a D8 patch, while git can actually auto-merge it, DrupalCI probably can't.

lauriii’s picture

+++ b/core/lib/Drupal/Core/Theme/ActiveTheme.php
@@ -209,11 +209,18 @@ public function getLibraries() {
+   * @todo Remove in https://www.drupal.org/project/drupal/issues/3104307

+++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php
@@ -320,7 +324,9 @@ protected function resolveStyleSheetPlaceholders($css_file) {
+   * @todo Remove in https://www.drupal.org/project/drupal/issues/3104307

This doesn't seem like the correct issue to be reference here since this is a 9.0.x issue.

berdir’s picture

We can't create issues for D10 yet, so we could either create one in 9.x that says it's actually for D10 or juts remove the @todo.. I think we'll find this when searching for @trigger_error() then for D10.

lauriii’s picture

How about just a comment along the lines of @todo Remove in Drupal 10.0.x.?

berdir’s picture

Status: Needs review » Needs work

works for me, we already have such a comment. I'll try to provide that as a patch tonight, but maybe someone else can pick it up before then.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new8.65 KB
new1.05 KB
new8.61 KB

Updated those two instances.

Status: Needs review » Needs work

The last submitted patch, 30: 3069052-30-D8.patch, failed testing. View results

longwave’s picture

Status: Needs work » Needs review

Random fail in WidgetUploadTest, requeued.

lauriii’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/lib/Drupal/Core/Theme/ActiveTheme.php
@@ -191,11 +191,18 @@ public function getLibraries() {
+   * @internal
...
   public function getStyleSheetsRemove() {

I had a concern that not giving deprecation warning on this method could lead into someones code breaking accidentally when upgrading to Drupal 10.

I talked to @Berdir on Slack and he pointed out that the method has been marked internal and that there is only three usages in the contrib ecosystem: http://grep.xnddx.ru/search?text=getStyleSheetsRemove&filename=. Based on this I think it's fine for us to proceed with the current approach 👍

alexpott’s picture

Version: 9.0.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed 9bb53f5 and pushed to 9.0.x. Thanks!
Committed 599d4e0 and pushed to 8.9.x. Thanks!

I considered backported to 8.8.x to get the improved deprecations there but considering the scope of the change - adding new @trigger_error()'s to runtime code - I would like a release manager +1.

  • alexpott committed 9bb53f5 on 9.0.x
    Issue #3069052 by mikelutz, Berdir, longwave, ravi.shankar, voleger,...

  • alexpott committed 599d4e0 on 8.9.x
    Issue #3069052 by mikelutz, Berdir, longwave, ravi.shankar, voleger,...
gábor hojtsy’s picture

Version: 8.8.x-dev » 8.9.x-dev
Status: Patch (to be ported) » Fixed

Asked @catch he said

Was thinking probably not because it's, 10.x deprecation now and might cause new test failures.

Status: Fixed » Closed (fixed)

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