Closed (won't fix)
Project:
Drupal core
Version:
8.0.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
24 Nov 2009 at 13:47 UTC
Updated:
29 Jul 2014 at 18:34 UTC
Jump to comment: Most recent file
Comments
Comment #2
casey commentedhmm
Comment #4
casey commentedI tried to create tests first. CSS aggregator however can't handle all tests correctly, so I already disabled some of the new tests. Those can be reenabled when CSS aggregator is ready for them.
Plz review + commit this one first, so I can work from there.
Comment #5
casey commentedretry
Comment #6
rfaysubscribing - I'll take a look.
Comment #7
rfayThis looks like great work, and very valuable. I haven't reviewed the code yet.
See also #494498: Add CSS parsing capability to Drupal.
IMO, really valid aggregation AND actually valid tests will be based on parsing and determining that the resultant parse tree is the same.
Comment #8
casey commentedIt probably will take a while before an actual css parser will get adopted. I think we should at least fix what s fixable. I also volunteer to work on such a parser afterwards.
Fixes this patch contains:
* added a $flatten parameter to drupal_load_stylesheet() so replacement of @import is optional
* D7 allows to optimize inline css too, however @import's shouldn't get replaced in inline css
* all inline css is merged into one <style> tag; @import should proceed any other style
* strengthened _drupal_build_css_path()
* #265719: CSS aggregator produces invalid code and directory names for @import files Breaks IE, Internet explorer does not style page.
* #511998: CSS aggregator change url path in imported files
* #258846: CSS aggregation fails to parse some url()'s
* Replaced usage of chdir() with a safer approach
* Optimized optimization
* More tests
I copied hacks.css from http://code.google.com/p/minify/source/browse/trunk/#trunk/min_unit_test... and the regexps from http://code.google.com/p/minify/source/browse/trunk/min/lib/Minify/CSS/C.... Does it need credit? Where do I add that?
Comment #10
casey commentedThis one should pass them all...
Comment #11
casey commentedComment #12
casey commentedReview is not necessary yet; new patch incoming.
Comment #13
casey commentedI created seperate issues for easier reviewing. When they are commited I'll have a look at what is left in this issue.
Comment #14
casey commentedSecond thoughts, the issues are so much related that fixing them all at once seems easier to me.
Tests included.
Comment #15
casey commentedComment #17
casey commentedFixed fail + added new test + added more comments to tests.
Review plz.
Comment #19
mattyoung commented~
Comment #20
mfer commentedThere seem to be a lot of changes rolled in here. Some might be bug fixes and some are definitely new features. D7 is past the new features stage and now only bug fixes can go in. Plus, this definitely makes changes to the API and that is frozen as well.
I'd suggest a few things.
First, break the patch up into bug fixes and new features. The new features should go in an issue for Drupal 8 and the bug fixes can stay in an issue for Drupal 7.
Second, per Webchick advice, mega patches that change a bunch of things are bad. She would rather deal with individual patches per thing rather than one patch that does a lot of things. This makes it easier to review and get committed.
Third, share and promote your CSS Preprocessor module in contrib during D7. I'm curious to see how it goes.
For Drupal 8 I'd like to make both the CSS and JS preprocessors pluggable. So, we can swap them out with others from contrib. Some people will use something like YUI Compressor to shrink down CSS and not take the runtime performance hit. Others, could take advantage of what you do here. And, still others just want something simple like what core offers now. What do you think of that?
In past issues we've not been able to get core to do anything complex when it comes to shrinking this stuff down. In the JS preprocessing patch it went in initially and was later removed.
Comment #21
casey commentedIt's not really containing new features, other than the the seperate 'aggregate', 'optimize' and 'flatten' options in drupal_add_css(). Without these you lose flexibillity, but if necessary I can strip those.
Minimizing is debatable as a new feature, but I disagree. Current HEAD already minimizes CSS, just not that good. And besides, performance improvements are still allowed right? Well this is also a performance improvement.
About the mega patch. see http://drupal.org/project/issues/search/drupal?issue_tags=CSS%20aggregation. I added seperate issues, but they are all very related. It's just much easier to fix them all at once.
The CSS Preprocessor is going to have a real parser; beside that I would put CSS aggregation in a seperate module in core, that module is something else.
CSS and JS preprocessors are pluggable in Drupal 7! drupal_alter('css') makes that possible very easily. That's why I opened this issue: #643534: separate module for CSS aggregation
Comment #22
casey commentedComment #24
casey commentedThis should do...
Comment #25
mfer commentedThe CSS and JS preprocessors are not pluggable in core. hook_js_alter and hook_css_alter allow you access to the original files but that does not provide the ability to swap out the preprocessor itself. For example, see http://drupal.org/project/sf_cache. This module allows for multiple preprocessed files in groupings. You would need a pluggable system to support the groupings. Something like #352951: Make JS & CSS Preprocessing Pluggable. This is a good place for a plugin (swappable subsystem) not a module.
When it comes to having a more complex parser 2 things concern me. First, is there a project already doing this we can leverage so we don't duplicate code? Second, slow performance of a more complex parser is why tools like YUI say not to use them in setups like this. So, what is performance like? What is the performance change to drupal core?
You said, "* all inline css is merged into one
tag; @import should proceed any other style" Why should imports proceed any other style? What do you mean by "* strengthened _drupal_build_css_path()"? I mean as far as describing what would be different from there currently. So, we can test a change against a stated description. For D7, is there something that's a bug or is this just a better system? If it's a bug can you describe the bug and how to reproduce it? That should be fixed. If this is about a better system for drupal to use I'm afraid that will have to wait until D8.Comment #26
rfay@casey: It looks to me like you're still adding new features ('preprocess', 'aggregate'), which definitely won't fly.
Please confine this to bug fixes, and make sure (if you haven't already) to label the tests as to what bug they test.
For this version of the patch, it would be nice to have comments indicating which bug is fixed by what change as well.
Comment #27
casey commented@mfer you should read the comments of the code and tests.
all inline css is merged into one tag
see test CascadingStylesheetsTestCase::testRenderInlineMediaPrint()
@import should proceed any other style
http://www.w3.org/TR/REC-CSS2/cascade.html#at-import. When a stylesheet is aggregated and non-resolved @import rules (like external stylesheets) should be moved to the top, else browser won't process them.
strengthened _drupal_build_css_path()
see #511998: CSS aggregator change url path in imported files, #265719: CSS aggregator produces invalid code and directory names for @import files Breaks IE, Internet explorer does not style page. and #258846: CSS aggregation fails to parse some url()'s
They are all bugs...
Comment #29
mfer commentedThanks for detailing out the issues with @import. That's the kind of information we need here.
The patch does a lot more than change how @import is handled. This is a mega patch addressing multiple issues. Keeping it that was isn't going to help get the patch committed. I've learned this the hard way. Each desecrate issue needs to be broken out separately. Even if it is easier for you to write it that way.
This patch changes APIs and we are past the API freeze. A whole new way to handle this that changes internal APIs will need to wait for D8. That's the point in the process we are at. If you want this in D7 i'd suggest changing this to multiple issues that address the individual bugs and do them one after another. Otherwise, this will become a D8 issue and the D8 maintainers can sort it out.
Comment #30
mfer commentedComment #31
casey commentedAdded comments to tests with links to the seperate issues.
And removed the 'aggregate', 'optimize' and 'flatten' options. Patch does not contain any new features any more.
Comment #32
casey commentedAbout API change
I did not remove any parameters from public functions, so usage stays the same. I did add some parameters for internal usage. Do I have to remove them? Would result in some duplicate code however.
Module sf_cache does something; it allows grouping.
CSS Aggregation is pluggable for Drupal 7; have a look at module css_preprocessor. When enabled, Core aggregator won't run anymore.
Comment #34
casey commentedBesides it's so large because of the tests.
Comment #36
casey commentedHmm weird, it does pass locally.
Comment #37
casey commented*Now* it should pass!
Comment #39
casey commentedNot sure what is going wrong.
Comment #40
mfer commentedWhat version of PHP are you using? 5.2.x?
Comment #41
casey commented5.3 local...
/edit ow wait I am testing on an external server. yes 5.2.9
Comment #43
casey commentedI think I found it...
Comment #44
casey commentedFinally.
For easier reviewing I seperated the actual code changes and the new tests.
Comment #45
rfayI'm afraid that a large, disruptive patch like this won't fly. I skimmed it and came away with the impression that "here's a bunch of code that will fix what ails you". But no clear justification for the things you're doing. I'm sure you have a clear vision, but the community process means that you have to sell the rest of us on your vision.
Also, it's clear that you're changing APIs if you had to change color.module. That's clearly past the code freeze.
Here's what you need to do, IMO, to continue successfully with this:
1. Explain in this issue what problems you're trying to solve.
2. Explain in this issue exactly how you propose to solve them.
3. Explain in this issue how the tests that you've provided can give us adequate confidence that nothing else will break as a result.
4. Explain how we can demonstrate current system failures using the tests that you provide, and map them to open issues.
The most explanation I see is in #8... I think you need a treatise on what you want. You have a big job ahead.
You have to remember that we're at the very conservative *end* of the release cycle, and that CSS aggregation mostly works for most people and has for some time. So people are going to be very reluctant (rightly or wrongly) to take a risk on a huge new redesign. I wish you'd started this initiative 6 months ago - I'd be much more optimistic.
Basically, I agree with mfer. You won't get this whole thing into D7. And you should probably work on one piece at a time. I know it needs a redesign, and that that is probably the correct approach. But it's too late in the release cycle.
I also agree with mfer that your best chance of getting this into D8 is by building a very high quality CSS aggregator module, as you've started to do. If that is high quality and popular, it will both solve the failings of D7 (people can switch to your module when they hit new bugs) and it will also be a very good candidate for integration into D8.
Thanks for the good work on this, and I look forward to good long-term results. Sorry for the pessimism about the short term.
Comment #46
casey commentedYou're most probably right. For now I'll try to use my in-depth experience :p on this subject to provide clear single line solutions in their own issues where possible.
Thanks for the help though!
Comment #47
mfer commented@Casey, please realize we want to help you with this. We want the best system possible and are glad you've come along to try an help improve on that. Sometimes the way to get stuff in past the core committers isn't the way we like to work the best.
Comment #48
casey commented@mfer ow I do. I even kinda knew this patch wasn't going to land. But I am sure this issue is proving there's lot to improve on the current CSS aggregator. And I am also happy with your help. This is just going to improve my community-driven development skills.
Comment #50
casey commentedComment #51
catchMissed this first time around, just found it via the css parsing issue.
Comment #52
xjmI think we need a new, more targeted patch for this issue.
Comment #53
wim leersIt's been pointed out by several people that this patch was unacceptable for several reasons. This issue has been silent for >3.5 years. None of the code applies anymore. Closing. If you still want to work on this, please open new, focused issues.
Thanks!