If a theme in /sites/sitename.com/themes/ is named the same as another theme in /themes/ you may have template_c mashed
| Project: | Smarty theme engine |
| Version: | 4.7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | sun |
| Status: | closed |
If you have say /sites/sitename.com/themes/default and /themes/default , sometimes ive noticed smarty's compiled templates getting "mashed" across both sites, which is a real pain in multi-homed commercial environments.
Attached is a patch that suffix's the MD5 sum of the current sites config_path to the templates_c/ subdirectory, which ensures smarty cache paths dont get mashed across theme names/site installations
I think the ultimate way would be to move the templates_c to under the /sites/sitename.com/templates_c directory so each site carries its own compiled smarty cache
Attached patch is for smartytemplate.php from CVS @ 1.6 2005/12/31 09:24:02 diffed against my patches to smartytemplate.php @ ,v 1.1.1.1 2006-05-04 01:36:11
| Attachment | Size |
|---|---|
| smarty-cache-isolation.patch.txt | 794 bytes |

#1
Thanks dgtlmoon, that was an oversight on my part, I'll get it committed.
#2
Just a thought - this could also be a security issue
#3
-1 for
/sites/<sitename>/themes/templates_c(each templates_c directory must have proper permissions - this wouldn't really be maintainable)
+1 for using
.../templates_c/<themename>_<MD5>(although a bit long)
+2 for using
.../templates_c/sites/default/<themename>and.../templates_c/themes/<themename>(
/themes/smarty/templates_c/and anything below is writable anyway)#4
I should have looked a bit closer at the original solution.
I don't understand your second suggestion there.
I'm inclined to do
smarty/templates_c/site_name/theme_nameI dont think there are very serious security considerations so I'll wait for feedback on this before committing (and repackaging).
#5
my two cents: compiled templates _shouldnt_ be important to the sysop or the browser, so long as they dont overlap and are tucked away somewhere, its one of those things where if its working you really dont have much reason to be looking at it
+1 for leaving it in themes/engines/smarty/templates_c/[someUUID]/
#6
seems to solve this issue, too. My proposal was to add the full path to the theme after
/themes/engines/smarty/templates_c, but I think the proposal ofsite_name/theme_nameis enough to prevent garbled output. We should go for that.#7
Sitename?
#8
dgtlmoon,
see http://api.drupal.org/api/4.7/function/conf_path and http://api.drupal.org/api/4.7/file/sites/default/settings.php
#9
Yes, the name of each site is unique and based on the folder name located in
/sites. With that prefix eachtemplates_cdirectory will also be unique.F.e.
/sites/exampledomain.comwith a theme in/themes/examplewill be compiled in/themes/engines/smarty/templates_c/exampledomain.com/example, whereas/sites/exampledomain.orgwith a theme in/sites/exampledomain.org/themes/examplewill be compiled in/themes/engines/smarty/templates_c/exampledomain.org/exampleand even/sites/exampledomain.comwith a theme in/sites/exampledomain.com/themes/otherwill be compiled in/themes/engines/smarty/templates_c/exampledomain.com/other.The only thing which would not be supported is
/sites/exampledomain.comwith a theme in/themes/examplewhile having also/sites/exampledomain.comwith a theme in/sites/exampledomain.com/themes/example/themes/engines/smarty/templates_c/exampledomain.com/exampleI don't know if we should care about the latter case, too. IMHO, a notice in README.TXT or INSTALL.TXT should be enough.
#10
Thanks for the input sun
As for the latter situtation, I considered this. It's not a problem since a single site can only be using one of the locations at a time.
#11
Attached patch creates a Smarty compile dir in
/themes/engines/smarty/templates_c/$confdir_$themedirfor each site running on one Drupal installation.I've decided to not use subdirectories because mkdir() does not support creation of subdirectories in PHP < 5 - and IMHO there shouldn't be much more needless subdirectories at this point.
#12
Patch stills works like a breeze.
#13
Travis, is it possible to commit this one-liner?
#14
+1. I've tested this patch and it worked well in a multisite environment.
#15
Committed to HEAD and DRUPAL-4-7.
#16