Less should do its job before Advagg starts his.
http://drupal.org/project/less

Css broken after Advagg enabled.

Comments

Peter Bowey’s picture

Less will need a advagg hook event added. See http://drupal.org/node/1078060#comment-4527560 for how this was done by Mike for css_emimage

mikeytown2’s picture

Quick look at the code and it should work... with advagg enabled, go to admin/settings/advagg/info and under the "Hook Theme Info" fieldset can you paste the contents of it here? Can I also get a ?advagg-debug=1 debug output from you? add ?advagg-debug=1 to a URL and then go to watchdog and under advagg there should be a large debug string. Copy that into a text file and upload it.

mikeytown2’s picture

Version: 6.x-1.0-rc5 » 6.x-1.x-dev
Status: Active » Postponed (maintainer needs more info)

Can't move forward till I get more info. Also, would you mind testing with the latest dev?

nbchip’s picture

Hook Theme Info:

jquery_ui_dialog_pre_preprocess_page
template_preprocess
template_preprocess_page
i18nmenu_preprocess_page
less_preprocess_page
jquery_ui_dialog_preprocess_page
i18n_preprocess_page
phptemplate_preprocess_page
ctools_preprocess_page
advagg_processor

It seems that with new dev smth is broken, at first everything seemed fine, but after adding ?advagg-debug=1 I started getting all kinds of errors when in "my Theme", which actually uses .less

user warning: Table 'tehnopoi_drupal.cache_advagg_js_compress_inline' doesn't exist query: SELECT data, created, headers, expire, serialized FROM cache_advagg_js_compress_inline WHERE cid = '8b8a229af9bb83e377c5997903228a490' in /home/tehnopoi/public_html/company/includes/cache.inc on line 26.
user warning: Table 'tehnopoi_drupal.cache_advagg_js_compress_inline' doesn't exist query: UPDATE cache_advagg_js_compress_inline SET data = 'hs.graphicsDir=Drupal.settings.basePath+\"sites/all/themes/atck/highslide/graphics/\"', created = 1306893823, expire = -1, headers = '', serialized = 0 WHERE cid = '8b8a229af9bb83e377c5997903228a490' in /home/tehnopoi/public_html/company/includes/cache.inc on line 109.
user warning: Table 'tehnopoi_drupal.cache_advagg_js_compress_inline' doesn't exist query: SELECT data, created, headers, expire, serialized FROM cache_advagg_js_compress_inline WHERE cid = 'c0f9240886dca6f1c0be51d78029ca560' in /home/tehnopoi/public_html/company/includes/cache.inc on line 26.
user warning: Table 'tehnopoi_drupal.cache_advagg_js_compress_inline' doesn't exist query: UPDATE cache_advagg_js_compress_inline SET data = 'var _gaq=_gaq||[];_gaq.push([\"_setAccount\",\"UA-xxxxxxx-1\"]);_gaq.push([\"_trackPageview\"]);(function(){var ga=document.createElement(\"script\");ga.type=\"text/javascript\";ga.async=true;ga.src=(\"https:\"==document.location.protocol?\"https://ssl\":\"http://www\")+\".google-analytics.com/ga.js\";var s=document.getElementsByTagName(\"script\")[0];s.parentNode.insertBefore(ga,s)})()', created = 1306893823, expire = -1, headers = '', serialized = 0 WHERE cid = 'c0f9240886dca6f1c0be51d78029ca560' in /home/tehnopoi/public_html/company/includes/cache.inc on line 109.
nbchip’s picture

Status: Postponed (maintainer needs more info) » Active
mikeytown2’s picture

run update.php; the above errors should disappear. I've added a new cache table in the latest dev. I still need the output from ?advagg-debug=1

nbchip’s picture

StatusFileSize
new31.65 KB

I needed to reiinstall module, running update was giving me errors.
Also strangely but everything seems to work in Chrome (13 dev version) . Its like it knows how to parse .LESS files... Could this be?

Attached debug

mikeytown2’s picture

Component: CSS Compression » Code

Top of the debug shows me whats wrong

    [css_before_vars] => Array     // $variables['css'];
        (
            [all] => Array
                (
                    [module] => Array
                        (
                            [modules/book/book.css] => 1
                            [modules/node/node.css] => 1
                            [modules/system/defaults.css] => 1
                            [modules/system/system.css] => 1
                            [modules/system/system-menus.css] => 1
                            [modules/user/user.css] => 1
                            [sites/all/modules/admin_menu/admin_menu.css] => 
                            [sites/all/modules/cck/theme/content-module.css] => 1
                            [sites/all/modules/ctools/css/ctools.css] => 1
                            [sites/all/modules/filefield/filefield.css] => 1
                            [sites/all/modules/google_analytics_reports/google_analytics_reports/google_analytics_reports.css] => 1
                            [sites/all/modules/wysiwyg_imageupload/plugins/imgupload/imgupload.css] => 1
                            [sites/all/modules/views/css/views.css] => 1
                            [sites/all/modules/tablefield/tablefield.css] => 1
                        )
                    [theme] => Array
                        (
                            [sites/all/themes/atck/css/page-layout.css] => 1
                            [sites/all/themes/atck/style.css] => 1
                            [sites/default/files/less/sites/all/themes/atck/mainstyle.css] => 1
                            [sites/default/files/less/sites/all/themes/atck/content.css] => 1
                            [sites/all/themes/atck/highslide/highslide.css] => 1
                        )
                )
        )
    [css_before_function] => Array     // drupal_add_css();
        (
            [all] => Array
                (
                    [module] => Array
                        (
                            [modules/book/book.css] => 1
                            [modules/node/node.css] => 1
                            [modules/system/defaults.css] => 1
                            [modules/system/system.css] => 1
                            [modules/system/system-menus.css] => 1
                            [modules/user/user.css] => 1
                            [sites/all/modules/admin_menu/admin_menu.css] => 
                            [sites/all/modules/cck/theme/content-module.css] => 1
                            [sites/all/modules/ctools/css/ctools.css] => 1
                            [sites/all/modules/filefield/filefield.css] => 1
                            [sites/all/modules/google_analytics_reports/google_analytics_reports/google_analytics_reports.css] => 1
                            [sites/all/modules/wysiwyg_imageupload/plugins/imgupload/imgupload.css] => 1
                            [sites/all/modules/views/css/views.css] => 1
                            [sites/all/modules/tablefield/tablefield.css] => 1
                        )
                    [theme] => Array
                        (
                            [sites/all/themes/atck/css/page-layout.css] => 1
                            [sites/all/themes/atck/style.css] => 1
                            [sites/all/themes/atck/mainstyle.css.less] => 1
                            [sites/all/themes/atck/content.css.less] => 1
                            [sites/all/themes/atck/highslide/highslide.css] => 1
                        )
                )
        )

What I grab from $variables['css'] is correct; what drupal_add_css() gives me is wrong. Thanks for the debug output; I should be able to fix this today, if everything works out.

mikeytown2’s picture

Status: Active » Fixed
StatusFileSize
new3.92 KB

This should be fixed with this patch; let me know if it's not as this code hasn't been thoroughly tested. Patch has been committed.

Status: Fixed » Closed (fixed)

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

corey.aufang’s picture

Status: Closed (fixed) » Needs work

Sorry for opening this again, just the end of string check was bothering me.

Wouldn't it be simpler to check for the end of the string like this?

if (drupal_substr($file, -5) == '.less') {
...
}

To me it seems to be a cleaner solution rather than conditionally defining a function.

mikeytown2’s picture

Status: Needs work » Fixed
StatusFileSize
new471 bytes

Function gets defined only if your using php 4; nonetheless being able to do this with one native php function instead of 4 is probably quicker.

Patch here has been committed.

corey.aufang’s picture

Status: Fixed » Needs work

The start value for substr has to be a negative value if you want to check from the end ;)

Also I would suggest only checking for -5 and '.less' as a file doesnt have to end with .css.less, only .less.

mikeytown2’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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

corey.aufang’s picture

Version: 6.x-1.x-dev » 6.x-1.6
Priority: Normal » Critical
Status: Closed (fixed) » Active

Sorry to resurrect this issue but I found a critical problem with the CSS aggregation.

$css_var = $variables['css'];
$css_orig = $css_var;
$css_func = drupal_add_css();
advagg_css_array_fixer($css_func);
$css = advagg_merge_css($css_func, $css_var);

This causes a reordering of CSS files by moving any processed less file to the end of the type, being either module or theme. This breaks style overriding, which is sort of a big thing in CSS.

Example:

This

 [theme] => Array
                        (
                            [sites/all/themes/blotter/css/html5boilerplate.css] => 1
                            [sites/all/themes/blotter/css/layout.css] => 1
                            [sites/default/files/less/sites/all/themes/blotter/css/style.css] => 1
                            [sites/all/themes/blotter/css/nav.css] => 1
                            [sites/all/themes/blotter/css/article.css] => 1
                            [sites/all/themes/blotter/css/slideshow.css] => 1
                            [sites/all/themes/blotter/css/featured-artists.css] => 1
                            [sites/all/themes/blotter/css/store.css] => 1
                            [sites/all/themes/blotter/css/krumo.css] => 1
                            [sites/all/themes/blotter/css/blotter.lightbox_alt.css] => 1
                            [sites/all/themes/blotter/css/connecttowin.css] => 1
                            [sites/all/themes/blotter/css/artist_page.css] => 1
                            [sites/all/themes/blotter/system-menus.css] => 1
                        )

becomes this

[theme] => Array
                        (
                            [sites/all/themes/blotter/css/html5boilerplate.css] => 1
                            [sites/all/themes/blotter/css/layout.css] => 1
                            [sites/all/themes/blotter/css/nav.css] => 1
                            [sites/all/themes/blotter/css/article.css] => 1
                            [sites/all/themes/blotter/css/slideshow.css] => 1
                            [sites/all/themes/blotter/css/featured-artists.css] => 1
                            [sites/all/themes/blotter/css/store.css] => 1
                            [sites/all/themes/blotter/css/krumo.css] => 1
                            [sites/all/themes/blotter/css/blotter.lightbox_alt.css] => 1
                            [sites/all/themes/blotter/css/connecttowin.css] => 1
                            [sites/all/themes/blotter/css/artist_page.css] => 1
                            [sites/all/themes/blotter/system-menus.css] => 1
                            [sites/default/files/less/sites/all/themes/blotter/css/style.css] => 1
                        )

This is caused by grabbing the CSS from drupal_add_css and filtering out .less files then merging with the CSS from the $variables array, where the CSS from drupal_add_css is the primary.

Is there any reason why we should be grabbing the info from drupal_add_css at all? The only thing I can see us gaining from that is if anyone used drupal_add_css in a previous preprocess funciton, since template_preprocess_page already sets $variables['css'] from drupal_add_css.

If we still need to pull the files from drupal_add_css and merge, we should have the CSS from $variables be the primary on the merge.

corey.aufang’s picture

This change fixes the issue:

$css = advagg_merge_css($css_var, $css_func);

I still recommend using just $variables['css'], as that will ensure that other modules/themes changes will carry through in the correct order, like so:

$css = $variables['css'];
mikeytown2’s picture

Status: Active » Needs review
StatusFileSize
new1.7 KB

Here's a patch that fixes the order and allows one to only use $variables['css'] if desired by doing this in your settings.php file

global $conf;
$conf['advagg_only_css_from_variables'] = TRUE;
corey.aufang’s picture

Looks perfect to me.

mikeytown2’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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