The LESS module sets the path for processed CSS to file_default_scheme() . '://less'. If the file_default_scheme() is 'private', then generated files will be unavailable to the anonymous user, and site formatting will be broken.

The attached patch:

  • Adds a less_path variable for storing the directory path for processed CSS files.
  • Adds the less_path setting to the less_settings form.
  • Changes both instances of
    $less_path = file_default_scheme() . '://less';
    

    to

    $less_path = variable_get('less_path', 'public://less');
    
  • Adds a less.install file containing:
    • A hook_requirements() implementation to check writability of the less_path setting.
    • A hook_uninstall() implementation to delete module settings variables when the module is uninstalled.
  • Incorporates overlapping changes from #1241184: Check for directory existence before calling file_unmanaged_delete_recursive().
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pillarsdotnet’s picture

Status: Active » Needs review
FileSize
4.92 KB

Patch.

pillarsdotnet’s picture

Better patch moves existing less_requirements() function from less.module to less.install where it belongs.

pillarsdotnet’s picture

Fixed typos.

psynaptic’s picture

Status: Needs review » Needs work
+++ b/less.installundefined
@@ -0,0 +1,53 @@
+ * Support installation and uninstallation of LESS module.

Missing @file directive above the description.

+++ b/less.installundefined
@@ -0,0 +1,53 @@
+ * @param $phase The phase in which hook_requirements is run: install or runtime.

The description should be on the following line.

+++ b/less.installundefined
@@ -0,0 +1,53 @@
+    $result['less']['severity'] = ¶

Looks like this line should be removed.

pillarsdotnet’s picture

Status: Needs work » Needs review
FileSize
4.08 KB

Corrected patch.

pillarsdotnet’s picture

Title: Generated CSS must be stored under public:// in order to be available to anonymous user. » Compiled CSS files must be stored under public:// for anonymous user access.

Better title.

imp7’s picture

confirmed patch works, great work psynaptic

corey.aufang’s picture

I've changed the path to be public://less, but I think its a bad idea to allow the user to choose the folder location.

That would allow the user to change something that is vital to functionality of the project that could cause problems and also open a security hole.

Granted they would already have to have high permissions to use it, but its better to avoid it completely.

If you can convince me that the administrator should be able to configure the folder for the compiled css, I'll add it back in.

I'm also splitting off the moving of hook_requirements into #1421044: move hook_requirements to .install.

rooby’s picture

In my case, less wasn't working at all in the private file system.

With this patch everything is AOK.

I think corey.aufang has a point in #8, I can't see any reason why I would want to have anything other than public:// on any of my sites.

corey.aufang’s picture

Status: Needs review » Fixed

This should be resolved in 7.x-2.5.

Status: Fixed » Closed (fixed)

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

  • Commit ffb6c1d on 7.x-2.x, 7.x-3.x, 7.x-4.x:
    Issue #1246308 by corey.aufang, pillarsdotnet: Change directory to...