[XS Tweak] always recompile template on mtime change

Tutorials for <a href="http://www.phpbbstyles.com/viewtopic.php?t=356">eXtreme Styles mod</a> for phpBB 2.0.

Moderator: Moderators

[XS Tweak] always recompile template on mtime change

Postby PostBot on Sat Jul 02, 2005 8:46 pm

There were few cases when people were having problem with recompiling files. This usually happened when they have restored old template files so file modification time for template was older than file modification time of cache. Because cache is newer xs_mod didn't recompile those files.

This happens very rare and only on some non-standard host configurations.

For those who are experiencing that problem here is solution:

Open includes/template.php, find this:
Code: Select all
   function compile2($code, $handle, $cache_file)
and replace with this:
Code: Select all
   function compile2($code, $handle, $cache_file[highlight], $touch = 0[/highlight])
then find this:
Code: Select all
         $res = $this->write_cache($cache_file, $code);
and replace with this:
Code: Select all
         $res = $this->write_cache($cache_file, $code[highlight], $touch[/highlight]);
then find this:
Code: Select all
   function write_cache($filename, $code)
and replace with this:
Code: Select all
   function write_cache($filename, $code[highlight], $touch = 0[/highlight])
then find this:
Code: Select all
      fputs($file, $code);
      fclose($file);
      @chmod($filename, 0777);
and add after it:
Code: Select all
      if($touch)
      {
         @touch($filename, $touch);
      }
then find this:
Code: Select all
            $this->compiled_code[$handle] = $this->compile2($this->uncompiled_code[$handle], $handle, $this->files_cache2[$handle]);
and replace with this:
Code: Select all
            $this->compiled_code[$handle] = $this->compile2($this->uncompiled_code[$handle], $handle, $this->files_cache2[$handle][highlight], @filemtime($this->files[$handle])[/highlight]);
then find this:
Code: Select all
      $this->compile2($this->uncompiled_code[$handle], $handle, $this->files_cache2[$handle]);
and replace with this:
Code: Select all
      $this->compile2($this->uncompiled_code[$handle], $handle, $this->files_cache2[$handle][highlight], @filemtime($this->files[$handle])[/highlight]);
then find this:
Code: Select all
         if(@filemtime($this->files[$handle]) > $cache_time || $board_config['xs_template_time'] > $cache_time)
and replace with this:
Code: Select all
         if(@filemtime($this->files[$handle]) [highlight]!==[/highlight] $cache_time)

All those modifications will cause xs_mod to change modification time of cache to same time as tpl files, so it will use cache only if cache file modification time is exactly the same as modification time of tpl file.

Hovewer, it might cause problems if you'll be updating xs_mod (assuming this will ever happen because xs_mod is final and there are no updates planned). So if you'll ever be updating mod you'll need to clear cache after update yourself because xs_mod won't clear it automatically.
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby jupro on Mon Jun 12, 2006 10:41 pm

Hi there,

Does this fix work on v 2.0.1?

I have that version installed, and my site is crashed from the cache settings.

Feeling lost... any advice?

anyone?
jupro
Registered User
Registered User
 
Posts: 3
Joined: Mon Jun 12, 2006 10:37 pm

update

Postby jupro on Tue Jun 13, 2006 7:05 pm

hi again,

ok, I updated to the latest version of XS.

I am running phpbb2.0.20.

I even added the tweak on this page.


If I use the cache configuration settings (set to yes), I get the following error:
Code: Select all
Warning: Unknown(/home/MYPATH/public_htmlresources/siteman/siteman.class): failed to open stream: No such file or directory in /home/MYPATH/public_html/forum2/includes/template.php(917) : eval()'d code on line 16


I have no idea where to go from here.

Please lend a hand... I need to get this sorted out ASAP.

Thanks very much.
jupro
Registered User
Registered User
 
Posts: 3
Joined: Mon Jun 12, 2006 10:37 pm


Return to eXtreme Styles mod tutorials

Who is online

Users browsing this forum: No registered users and 1 guest