Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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 theless_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.
- A
- Incorporates overlapping changes from #1241184: Check for directory existence before calling file_unmanaged_delete_recursive().
Comments
Comment #1
pillarsdotnet CreditAttribution: pillarsdotnet commentedPatch.
Comment #2
pillarsdotnet CreditAttribution: pillarsdotnet commentedBetter patch moves existing
less_requirements()
function fromless.module
toless.install
where it belongs.Comment #3
pillarsdotnet CreditAttribution: pillarsdotnet commentedFixed typos.
Comment #4
psynaptic CreditAttribution: psynaptic commentedMissing @file directive above the description.
The description should be on the following line.
Looks like this line should be removed.
Comment #5
pillarsdotnet CreditAttribution: pillarsdotnet commentedCorrected patch.
Comment #6
pillarsdotnet CreditAttribution: pillarsdotnet commentedBetter title.
Comment #7
imp7 CreditAttribution: imp7 commentedconfirmed patch works, great work psynaptic
Comment #8
corey.aufang CreditAttribution: corey.aufang commentedI'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.
Comment #9
rooby CreditAttribution: rooby commentedIn 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.
Comment #10
corey.aufang CreditAttribution: corey.aufang commentedThis should be resolved in 7.x-2.5.