sfImageTransformExtraPlugin icon indicating copy to clipboard operation
sfImageTransformExtraPlugin copied to clipboard

Unable to save thumb if project is installed in subdirectory of web root

Open eoma opened this issue 14 years ago • 2 comments

I have to say, this is a brilliant plugin.

After struggling a bit with why the plugin wouldn't save the generated thumbs, I found out it all lies in the sfRawFileCache.

When the method sfRawFileCache::setCacheKey calls $context->getController()->genUrl($internalUri, false), it will use the full public path, invalidating the internal path when the project is not installed in the document root.

I therefore propose to modify sfRawFileCache::setCacheKey() to look something like:

class sfRawFileCache extends sfFileCache
{
...
  static public function setCacheKey($internalUri, $hostName = '', $vary = '', $contextualPrefix = '', $sfViewCacheManager)
  {
    $context = sfContext::getInstance();
    $internalUri = str_replace('sfImageTransformator/index', '@'.$context->getRouting()->getCurrentRouteName(), $internalUri);

    return str_replace($context->getRequest()->getRelativeUrlRoot(), '', $context->getController()->genUrl($internalUri, false));
  }
...
}

eoma avatar Jan 24 '11 12:01 eoma

Hi eoma,

thanks for that! I just pushed the change to github. can you test and confirm before I tag and release a new version?

Cheers /Christian

caefer avatar Jan 24 '11 16:01 caefer

Well, it works on my server, but the testsuite seems to fail (it failed the same way before the change)

eoma avatar Jan 24 '11 20:01 eoma