core icon indicating copy to clipboard operation
core copied to clipboard

$theme->asset->get_file() create wrong url on windows

Open scruwi opened this issue 9 years ago • 3 comments

<?php echo  \Theme::forge()->asset->get_file('image.png', 'img'); ?>

expected

http://site/theme/default/img/image.png

get

http://site/theme/D:/xampp/site/public/theme/default/img/image.png

because

File: /fuel/core/classes/asset/instance.php Function: find_file() Line: 316 return str_replace(DS, '/', $newfile);

Function: get_file() Line: 339 strpos($file, DOCROOT) = null instead strpos($file, DOCROOT) = 0

scruwi avatar Jul 26 '16 21:07 scruwi

I don't have Windows here to test it.

Could you change line 315 to:

return realpath($newfile);

and see if that solves your problem?

WanWizard avatar Jul 27 '16 08:07 WanWizard

It solve my problem, but make another:

<?php echo  \Theme::forge()->asset->css('bootstrap.min.css'); ?>

get

http://site/D:/xampp/htdocs/site/public/plugins/bootstrap-3.3.6-dist/css/bootstrap.min.css?1468713961

this problem occurs with absolute _asset_paths in $theme->asset instance.

$theme = Theme::forge();
$theme->asset->add_path('plugins/bootstrap-3.3.6-dist');
var_dump($theme->asset)
//  ...
//  protected '_asset_paths' => 
//    array (size=3)
//      'css' => 
//        array (size=2)
//          0 => string 'D:\xampp\htdocs\site\public\theme\default\css\' (length=61)
//          1 => string 'plugins\bootstrap-3.3.6-dist\css\' (length=33)
//  ...

Is it possible to make relative _asset_paths by default? In this case, my problem will be solved.

scruwi avatar Jul 27 '16 10:07 scruwi

Forget that fix, that will have issues on Linux too. For the same reason your solution can't be applied.

I need to setup a WAMP environment to properly test it.

WanWizard avatar Jul 27 '16 11:07 WanWizard