You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I refresh page in broser I get following string: /symfony/web/assetic/d05ce4a.jpg
But when I execute command assetic:dump, I get following assets intalled: 11:17:23 [file+] D:\www\testphp.local\symfony\app/../web/assetic/b3aed8d.jpg
Why this happens:
When page is refreshed, next functions calls happens:
if (!isset($options['output'])) {
$options['output'] = $this->output;
}
...
if (!isset($options['debug'])) {
$options['debug'] = $this->debug;
}
...
if (!isset($options['root'])) {
$options['root'] = array($this->root);
} else {
if (!is_array($options['root'])) {
$options['root'] = array($options['root']);
}
$options['root'][] = $this->root;
}
so basically, $options['debug'], $options['root'] keys are always set to something, then in AssetFactory : generateAssetName function filters $options keys not in 'output', 'debug', 'root', and then creates name based on $inputs, $filters (this 2 doesn't matter for this issue) and $options: return substr(sha1(serialize($inputs).serialize($filters).serialize($options)), 0, 7);
But when i ussue command: assetic:dump, then next functions calls happens:
in AsseticNodeVisitor : checkNode there is not setting for $options['output'], $options['debug'], $options['root'] like in AssetFactory : createAsset, so in AssetFactory : generateAssetName$options becomes empty array (AsseticNodeVisitor : checkNode even doesn't send $options to AssetFactory : generateAssetName).
Then next functions calls happens:
TwigFormulaLoader : loadNode (here - } elseif ($node instanceof AsseticFilterNode) { - branch will be execute),
AssetFactory : generateAssetName
again, there is no settings for $options['debug'], $options['root'] and so on (but in this case $options is passed to AssetFactory : generateAssetName, but it is different array then in web request because of ['debug'] and ['root'] settings in AssetFactory : createAsset in web request).
Because of this - result assets names are different, and it is impossible to use jpegoptim in production mode (use_controller: false).
May be I'm doing something wrong?
The text was updated successfully, but these errors were encountered:
PeterZhukov
changed the title
Wrong asset name when use function jpegoptim
Different assets names when use function jpegoptim in web request and assetic:dump command
Apr 20, 2017
PeterZhukov
changed the title
Different assets names when use function jpegoptim in web request and assetic:dump command
Different (wrong) assets names when use function jpegoptim in web request and assetic:dump command
Apr 20, 2017
My config:
Template:
{{ jpegoptim('@AppBundle/Resources/public/images/example2.jpg') }}
When I refresh page in broser I get following string:
/symfony/web/assetic/d05ce4a.jpg
But when I execute command assetic:dump, I get following assets intalled:
11:17:23 [file+] D:\www\testphp.local\symfony\app/../web/assetic/b3aed8d.jpg
Why this happens:
When page is refreshed, next functions calls happens:
in AssetFactory : createAsset this happens:
so basically,
$options['debug']
,$options['root']
keys are always set to something, then inAssetFactory : generateAssetName
function filters $options keys not in'output'
,'debug'
,'root'
, and then creates name based on$inputs
,$filters
(this 2 doesn't matter for this issue) and$options
:return substr(sha1(serialize($inputs).serialize($filters).serialize($options)), 0, 7);
But when i ussue command: assetic:dump, then next functions calls happens:
in
AsseticNodeVisitor : checkNode
there is not setting for$options['output']
,$options['debug']
,$options['root']
like inAssetFactory : createAsset
, so inAssetFactory : generateAssetName
$options
becomes empty array (AsseticNodeVisitor : checkNode
even doesn't send $options to AssetFactory : generateAssetName).Then next functions calls happens:
again, there is no settings for
$options['debug']
,$options['root']
and so on (but in this case$options
is passed toAssetFactory : generateAssetName
, but it is different array then in web request because of['debug']
and['root']
settings inAssetFactory : createAsset
in web request).Because of this - result assets names are different, and it is impossible to use jpegoptim in production mode (use_controller: false).
May be I'm doing something wrong?
The text was updated successfully, but these errors were encountered: