Problem

  • Stylesheets that have been removed by the theme (via .info) load with AJAX content.

Goal

  • Prevent stylesheets that were removed from coming back under all circumstances.

Steps to reproduce

  • Remove system.menus.css via a theme's .info file, e.g. add stylesheets[all][] = system.menus.css and don't include the file in your theme.
  • Visit admin/structure/types/manage/article/display.
  • Click the image configuration options.
  • Watch system.menu.css come back (and wreck your site design if you have different tab styles).

Note

  • The bug does not occur with stylesheets that have been removed via hook_css_alter().

Watch the screencast for a demonstration of the bug in progress:
http://vimeo.com/16672744

Comments

sun’s picture

Awesome issue summary, thanks! :)

The proper solution would be to re-open #901062: Regression: Themes can no longer remove stylesheets by overriding them in .info files against D7 and introduce the originally proposed stylesheets-remove[] .info file property.

jacine’s picture

Still no word on that, and I don't think it's going to happen.

Unfortunately this has serious potential to break sites in a bad way.

effulgentsia’s picture

Status: Active » Needs review
FileSize
1.49 KB

Here's a fix, but a test for it remains challenging until I (or someone else) makes good on the promise in #561858-201: [Tests added] Fix drupal_add_js() and drupal_add_css() to work for AJAX requests too by adding lazy-load to AJAX framework.

jacine’s picture

@effulgentsia Thank you!

The patch solves the problem, the change appears simple enough and the docs are good! Yay :D

I'd mark it RTBC, but I'm not really clear on what needs to happen with regard to the other issue. It seems like a test for this is not even possible and that issue is closed.

jacine’s picture

#3: 967166-ajax-css-3.patch queued for re-testing.

gmclelland’s picture

Is there any fix to prevent this from happening in Drupal 6?

I'm using TAO which strips out core's css using the .info file. When used with Skinr every time I click on Edit Skin it loads an ajax modal popup. When the modal is displayed it reinjects drupal's css causing my theme to break.

Thanks for any help you can provide. I also tried the stylestripper module, but that didn't work.

garrettrayj’s picture

Patch works great. Anything else I can help with to get this into a release version?

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Looks like a straight up bug fix to me. Any test for this would depend on the other issue. Seems like we should fix the bug now.

rfay’s picture

Version: 7.x-dev » 8.x-dev
Status: Reviewed & tested by the community » Needs review

D8 first. Let's get these fixed on D8 and into D7.

effulgentsia’s picture

By the way, #561858-211: [Tests added] Fix drupal_add_js() and drupal_add_css() to work for AJAX requests too by adding lazy-load to AJAX framework contains the tests to finish off that issue. Once that's in, a test can be added to this one.

sun’s picture

sun’s picture

#3: 967166-ajax-css-3.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs backport to D7

The last submitted patch, 967166-ajax-css-3.patch, failed testing.

mfer’s picture

I was just bit by this. The patch in #3 still applies to D7 w/ an offset.

yoroy’s picture

Issue tags: +Novice

A simple reroll would help move things forward here.

aiwata55’s picture

aiwata55’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests, -Novice, -Needs backport to D7

#3: 967166-ajax-css-3.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Needs tests, +Novice, +Needs backport to D7

The last submitted patch, 967166-ajax-css-3.patch, failed testing.

star-szr’s picture

FileSize
1.35 KB

Patch attached which applies cleanly to D8 HEAD, and applies to D7 HEAD with an offset.

mac_weber’s picture

Status: Needs work » Needs review
jhood’s picture

I applied the patch in #20 and the stylesheets no longer come back.

xjm’s picture

Status: Needs work » Needs review

The patch looks good to me, and manual testing in #22 confirms that it resolves the issue. Thanks for the reroll and the manual testing!

The next thing we will need is an automated test for the issue. #561858: [Tests added] Fix drupal_add_js() and drupal_add_css() to work for AJAX requests too by adding lazy-load to AJAX framework has been committed to 8.x, so the comments above seem to indicate it should be possible to write this test now. The test should fail when applied by itself, and pass when applied together with #20.

xjm’s picture

Status: Needs review » Needs work
Issue tags: -Novice

Oops, marking NW for addition of tests.

samerali’s picture

#20: 967166-ajax-css-19.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs backport to D7

The last submitted patch, 967166-ajax-css-19.patch, failed testing.

xjm’s picture

The patch will need to be rerolled against the latested 8.x and for the D8 core/ directory change.

star-szr’s picture

Some changes over in #1287368: Drupal.settings.ajaxPageState.css gets overwritten affected the patch. I've done a re-roll for D8 and D7 and tried not to step on any toes, but please let me know if I missed anything.

effulgentsia’s picture

Assigned: Unassigned » effulgentsia

Thanks! I'll work on adding tests.

xjm’s picture

Status: Needs work » Needs review

Sending to the bot.

effulgentsia’s picture

Assigned: effulgentsia » Unassigned
Issue tags: -Needs tests
FileSize
7.91 KB

Here's the test only. It should fail. Note that most of the -/+ lines are just a change to indentation.

effulgentsia’s picture

FileSize
9.8 KB

Here's #32 plus the fix in #28, but with a slight reworking of the if statement and code comments. This should pass.

KrisBulman’s picture

Status: Needs review » Reviewed & tested by the community

Tested original problem on the 8.x branch of git and was able to reproduce it following Jacine's steps (tested with system.base.css on bartik for a more drastic effect)

ran the patch
$ git apply -v 967166-ajax-css-32.patch

Followed same reproduction steps and can confirm the css file was not loading.

The faster this gets committed to 8, the sooner it'll get backported and we'll be able to remove the unintuitive hook_css_alter() from our themes in 7 :)

RTBC

no_commit_credit’s picture

FileSize
1.01 KB
9.8 KB
xjm’s picture

The above fixes two small things:

Leaving at RTBC because these are trivial changes. Thanks!

catch’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
Issue tags: +Needs backport to D7

This looks fine, most of the change is indentation and test additions, committed/pushed to 8.x.

KrisBulman’s picture

d7 reroll

xjm’s picture

Status: Patch (to be ported) » Needs review
effulgentsia’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
9.69 KB

#38 looks good. It's a straight reroll. This patch only fixes this:

+++ b/modules/simpletest/tests/ajax_test.module
@@ -32,6 +32,14 @@ function ajax_test_menu() {
 /**
+* Implements hook_system_theme_info().
+*/

These two lines need a leading space, which they already have in what was committed to D8.

Trivial change, so RTBC.

jacine’s picture

Hooray!!! Thanks all :D

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 7.x. Thanks!

Status: Fixed » Closed (fixed)
Issue tags: -Needs backport to D7

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