mrclay / minify

Combines. minifies, and serves CSS or Javascript files
BSD 3-Clause "New" or "Revised" License
3k stars 473 forks source link

symlinks ignored? #595

Open walderT opened 7 years ago

walderT commented 7 years ago

Hi there,

I think the config option "$min_symlinks" is ignored.

I use sysmlinks on my project and all paths to e.g. webfonts are broken.

As I can see, the parameter $symlinks is an empty array in \Minify_CSS_UriRewriter::rewrite

When I hardcode my symlink array in \Minify_CSSmin::minify

public static function minify($css, $options = array())
    {
    $realpath = realpath ($_SERVER['DOCUMENT_ROOT']."/");
    $realpath = str_replace ("//", "/", $realpath);
    $min_symlinks = array(
    '//myfiles' => $realpath . '/myfiles',
    );

    $options = array_merge(array(
            'compress' => true,
            'removeCharsets' => true,
            'currentDir' => null,
            'docRoot' => $_SERVER['DOCUMENT_ROOT'],
            'prependRelativePath' => null,
            'symlinks' => $min_symlinks,
        ), $options);

its working as excepted.

Here the output of print_r of $options in \Minify_CSSmin::minify

Array
(
    [currentDir] => /app/web/myfiles/templatesV2/css
)

The latest 3.x is used.

Any Ideas?

Thanks Thomas

mrclay commented 7 years ago

On my machine Minify is at the URL path /local/minify/. In config I set:

$min_symlinks = array('//root' => __DIR__);

I requested /local/minify/?f=root/quick-test.css and it worked correctly:

docRoot    : /Users/steve/Sites
currentDir : /Users/steve/Sites/local/minify
symlinks : array (
  '/Users/steve/Sites/root' => '/Users/steve/Sites/local/minify',
)

file-relative URI  : more.css
path prepended     : /Users/steve/Sites/local/minify/more.css
symlink unresolved : /Users/steve/Sites/root/more.css
docroot stripped   : /root/more.css
traversals removed : /root/more.css

This is 3.x.

walderT commented 7 years ago

I have currently no access to my development machine. Can you set a breakpoint at \Minify_CSSmin::minify and look if there is the symlink in the $options parameter?

I am sure, that this was in my case not set. Maybe because I am using the new "static" feature? Or using a group config?

My request: /min/static/0/g=cssV3&z=.css

I will look tomorrow if its different if I use the "normal" call, as you in your example.

mrclay commented 7 years ago

Yes, my $min_symlinks value was available in Minify_CSSmin::minify. I'll try with static tomorrow, indeed may be a bug there.

walderT commented 7 years ago

Hi, here is my result.

Request: /min/&f=/min/quick-test.css

$options in \Minify_CSSmin::minify

Array
(
    [docRoot] => /app/web
    [symlinks] => Array
        (
            [//myfiles] => /app/web/myfiles
            [//min] => /app/web/min
        )

    [currentDir] => /app/web/min
)

Request: /min/static/0/&f=/min/quick-test.css

Array
(
    [currentDir] => /app/web/min
)

docRoot is also missing, don't know if this is also required?