Nick Stallman wrote:
You can very easily use multiple cache directories by editing the
$cache_dir parameter in includes/acm/acm_file.php.
It's not quite that simple, as a few other things need to be done as well, as
you can see in the patch I've attached.
These changes are working for me, (and have done now for a good few months). I've only just remembered to post them after a manual merge following the
last phpbb3 update (3.0.0 -> 3.0.1). My only concern would be if I'd found all the places required (the forum I run is very low traffic, so it's quite
possible problems wouldn't be noticed quickly, if indeed at all).....and perhaps the quality of the solution. ;)
That said, I run 3 forums off the same install with this, so I believe it to be
good enough.
What would also be nice is a standardised Debian way of managing instances, as a lot Debian packages don't seem to support it very well (mediawiki and
phpbb2/3, I'm looking at you).
- Jamie
diff -ruN phpbb3/www/includes/acm/acm_file.php
phpbb3_custom/www/includes/acm/acm_file.php
--- phpbb3/www/includes/acm/acm_file.php 2008-04-07 18:43:07.000000000
+0100
+++ phpbb3_custom/www/includes/acm/acm_file.php 2008-05-06 00:03:31.000000000
+0100
@@ -36,7 +36,15 @@
function acm()
{
global $phpbb_root_path;
- $this->cache_dir = $phpbb_root_path . 'cache/';
+ global $dbname;
+
+ if( !file_exists( $phpbb_root_path . 'cache/' ) )
+ mkdir( $phpbb_root_path . 'cache/' );
+
+ if( !file_exists( $phpbb_root_path . 'cache/' . $dbname . '/' )
)
+ mkdir( $phpbb_root_path . 'cache/' . $dbname . '/' );
+
+ $this->cache_dir = $phpbb_root_path . 'cache/' . $dbname . '/';
}
/**
diff -ruN phpbb3/www/includes/acp/acp_styles.php
phpbb3_custom/www/includes/acp/acp_styles.php
--- phpbb3/www/includes/acp/acp_styles.php 2008-04-22 00:14:20.000000000
+0100
+++ phpbb3_custom/www/includes/acp/acp_styles.php 2008-05-06
00:12:59.000000000 +0100
@@ -2476,11 +2476,11 @@
*/
function template_cache_filelist($template_path)
{
- global $phpbb_root_path, $phpEx, $user;
+ global $phpbb_root_path, $dbname, $phpEx, $user;
$cache_prefix = 'tpl_' . $template_path;
- if (!($dp = @opendir("{$phpbb_root_path}cache")))
+ if (!($dp = @opendir("{$phpbb_root_path}cache/" . $dbname)))
{
trigger_error($user->lang['TEMPLATE_ERR_CACHE_READ'] .
adm_back_link($this->u_action), E_USER_WARNING);
}
@@ -2493,7 +2493,7 @@
continue;
}
- if (is_file($phpbb_root_path . 'cache/' . $file) &&
(strpos($file, $cache_prefix) === 0))
+ if (is_file($phpbb_root_path . 'cache/' . $dname . '/'
. $file) && (strpos($file, $cache_prefix) === 0))
{
$file_ary[] = str_replace('.', '/',
preg_replace('#^' . preg_quote($cache_prefix, '#') . '_(.*?)\.html\.' . $phpEx
. '$#i', '\1', $file));
}
@@ -2512,7 +2512,7 @@
*/
function clear_template_cache($template_row, $file_ary = false)
{
- global $phpbb_root_path, $phpEx, $user;
+ global $phpbb_root_path, $dbname, $phpEx, $user;
$cache_prefix = 'tpl_' . $template_row['template_path'];
@@ -2530,7 +2530,7 @@
{
$file = str_replace('/', '.', $file);
- $file =
"{$phpbb_root_path}cache/{$cache_prefix}_$file.html.$phpEx";
+ $file =
"{$phpbb_root_path}cache/$dbname/{$cache_prefix}_$file.html.$phpEx";
if (file_exists($file) && is_file($file))
{
@unlink($file);
diff -ruN phpbb3/www/includes/template.php
phpbb3_custom/www/includes/template.php
--- phpbb3/www/includes/template.php 2008-04-07 18:43:09.000000000 +0100
+++ phpbb3_custom/www/includes/template.php 2008-05-05 23:06:35.000000000
+0100
@@ -46,12 +46,12 @@
*/
function set_template()
{
- global $phpbb_root_path, $user;
+ global $phpbb_root_path, $dbname, $user;
if (file_exists($phpbb_root_path . 'styles/' .
$user->theme['template_path'] . '/template'))
{
$this->root = $phpbb_root_path . 'styles/' .
$user->theme['template_path'] . '/template';
- $this->cachepath = $phpbb_root_path . 'cache/tpl_' .
$user->theme['template_path'] . '_';
+ $this->cachepath = $phpbb_root_path . 'cache/' .
$dbname . '/tpl_' . $user->theme['template_path'] . '_';
}
else
{
@@ -69,10 +69,10 @@
*/
function set_custom_template($template_path, $template_name)
{
- global $phpbb_root_path;
+ global $phpbb_root_path, $dbname;
$this->root = $template_path;
- $this->cachepath = $phpbb_root_path . 'cache/ctpl_' .
$template_name . '_';
+ $this->cachepath = $phpbb_root_path . 'cache/' . $dbname .
'/ctpl_' . $template_name . '_';
return true;
}