I noticed the CSS body doesn't properly load in the Rule Edit section if your files directory is symlinked from a different location than your drupal root.

The offending code is in css_injector.module on line 229 -> function _css_injector_rule_path($crid)

You are getting the $localpath from your function and then replacing a portion of it based on the length of DRUPAL_ROOT in a following line. But in the case of a symlinked files directory, the DRUPAL_ROOT will be a different url (and length) from the $local_path path. So you end up chopping an arbitrary string out of the path rather than what you intend to be cutting out.

A developer on our team found a solution by replacing all code in this function with this:

return variable_get('file_public_path', conf_path() . '/files') . '/css_injector/css_injector_' . $crid . '.css';

I haven't dug into this too much, so I'm not sure if this is the best solution, but I'm hoping this will at least give context to the issue.

I might also suggest a drupal_set_message($path.' not found so I'm loading blank text for the CSS body!'); or something to that effect on line 115 of css_injector.admin.inc rather than just loading nothing. You might even want to disable the body or somehow make it very obvious that a save will overwrite whatever was there before the path wasn't found with "" (and potentially wipe out someone's work).

Comments

rfay’s picture

Status: Active » Closed (duplicate)

I think this is probably a duplicate of #1044670: Fix file handling resulting in Incorrect path to css file on Windows - see the patch in #12. If not, please set it back to active.