yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

AssetBundle / AssetManager can't have any check "file is readeble" (from web-server / from php) #16658

Closed bscheshirwork closed 2 years ago

bscheshirwork commented 6 years ago

What steps will reproduce the problem?

class TestAsset extends AssetBundle
{
    public $sourcePath = __DIR__ . '/test';
    public $js = [
        'js/code.js',
    ];
}
\backend\assets\TestAsset::register($this);

backend/assets/test rights is drwx------; Owner is not a web server user and is not a php user.

What is the expected result?

throw any error / docs about this case

What do you get instead?

not have access to assets file from nginx. 404. also in this case @filemtime("$basePath/$asset") is false

So... I change rights chmod -R u+rwX,go+rX,go-w backend/assets/test

Additional info

Q A
Yii version

yiisoft/yii2 dev-master ade07cf Yii PHP Framework Version 2 | PHP version | 7.2.8 | Operating system |alpine

samdark commented 6 years ago

Do you mean that Yii silences errors when it's not able to read asset file?

bscheshirwork commented 6 years ago

Yes. Also we can't publish file from asset bundle.

I see the algorithm of publish:

  1. Check "file exist" for check correctly path.
  2. Create symlink to dir
  3. Check the touch time and write <script url='...'> with/without timestamp

If user nginx is right-less we have 404 for this url If user php is right-less we can't get touch time (and publish by "copy dir"?)

may be need additional check 'is_readable'

samdark commented 6 years ago

I'd error explicitly in this case. Not sure why it does not now.