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
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | smartytemplate.compiledir.patch | 590 bytes | sun |
| smarty-cache-isolation.patch.txt | 794 bytes | dgtlmoon |
Comments
Comment #1
tclineks commentedThanks dgtlmoon, that was an oversight on my part, I'll get it committed.
Comment #2
dgtlmoon commentedJust a thought - this could also be a security issue
Comment #3
sun-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)Comment #4
tclineks commentedI 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).
Comment #5
dgtlmoon commentedmy 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]/
Comment #6
sunseems 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.Comment #7
dgtlmoon commentedSitename?
Comment #8
tclineks commenteddgtlmoon,
see http://api.drupal.org/api/4.7/function/conf_path and http://api.drupal.org/api/4.7/file/sites/default/settings.php
Comment #9
sunYes, 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.
Comment #10
tclineks commentedThanks 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.
Comment #11
sunAttached 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.
Comment #12
sunPatch stills works like a breeze.
Comment #13
sunTravis, is it possible to commit this one-liner?
Comment #14
recidive commented+1. I've tested this patch and it worked well in a multisite environment.
Comment #15
sunCommitted to HEAD and DRUPAL-4-7.
Comment #16
(not verified) commented