CAssetManager and version number


protected function hash($path)

	{

		return sprintf('%x',crc32($path.Yii::getVersion()));

	}

I don’t understand why version number is used in this function. If I understand this correctly this means that when I upgrade my Yii version the returned value will be different.

The only reasoning I can find for this is so that when framework code gets updated the new version of widgets etc. will be unique and we won’t be accessing the old code.

The only reason that this is an issue for me is because I have an application with a backend written in Yii and a frontend in CodeIgniter (the front end is legacy and the admin panel is my current project). I am uploading pictures to the assets directory; the CodeIgniter side doesn’t know what version of Yii I am running so I can’t easily construct a URL to the image.

I don’t see the need to publish the image but FWIW that is what I am doing, my gut tells me that I should take a new approach to the uploaded image, that said however, I do foresee complications using the version number this way. Perhaps a flag could be used so that the default behaviour is to use the version number but you can opt out by setting something to false when you call a publishing function.

Your situation is far from being common so I think we’ll not change it. Btw., why are you publishing images with CI to Yii’s assets?

Yes I am sure that my situation is far from common. I am not publishing to Yii with CI but the CI framework generates the frontend of the site. The admin area is programmed in Yii (I wish they were both Yii) so the image is uploaded initially into the protected folder of the admin area.

I used SaveFileBehavoir.php from the extensions to handle the uploading and it originally published the images to /assets/data/etc…

I have since tweaked that file so that images are copied after upload to a web accessible folder.

Probably I shouldn’t have posted this in this area, since this is strictly for feature requests however I think that I have learned that when upgrading Yii versions, you should probably clean out the assets directory to avoid an accumulation of files.

I have encountered a situation where this (version numbering approach) could be a potential problem.

If you have a tinyMCE widget for example and the end user pics a smiley icon to include in their document the url of the image will contain the version (the hash) number of the current framework release #

Example

/assets/fdad71bd/tiny_mce/plugins/emotions/img/smiley-frown.gif

So upgrading the framework would break the webpage if the assets directory was cleaned out.

???

doodle

I’m sure there is an easy fix but I’m not that savy :rolleyes: