getting pat template caching to work

A general technical discussion area for patTemplate.
Locked
User avatar
Geraint
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Fri Aug 19, 2005 5:23 pm
Location: Gogledd Cymru

getting pat template caching to work

Post by Geraint » Sun Nov 06, 2005 3:41 pm

Am I right in saying that patTemplate caching doesn't work for the frontend (in 1.0.3 or 1.1alpha)? This appears to be the case for one of my test setups (Windows XP, PHP 4.4.0).

I found, though, with a couple of easy changes that I could get it to work, specifically:

In _getCachfileName within patTemplate\Stat\File.php
$this->_options['root'] is an array and so the runction should include:

Code: Select all

$fullPath	=	$this->_options['root']['__default'] . '/' . $input;
In the write function in patTemplate\TemplateCache setting $filemode via $this->getParam('filemode') doesn't return null - but false.  If I change this line to read

Code: Select all

		$filemode==null;
		if (array_key_exists('filemode',$this->_params)) $filemode = $this->_params['filemode'];
Otherwise chmod is called with a filemode of false (which creates a readonly cache file in windows leading to all sorts of problems later!).  You could of course use a default value for filemode other than null and continue to use the existing write code.

Caching then appears to work.

Anyone else have any insights.

Geraint

alwarren
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Fri Aug 19, 2005 9:27 am

Re: getting pat template caching to work

Post by alwarren » Sun Nov 06, 2005 11:35 pm

I have a frontend component that uses patTemplate caching just fine with the following code:

Code: Select all

		$tmpl->useTemplateCache( 'File', array(
						'cacheFolder' => dirname(__FILE__) . '/tmpl/tmplCache',
						'lifetime' => 'auto' )
					);
I made no changes to the patTemplate core. My cache folder is in /components/com_mycomponent/tmpl/tmplCache.
Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW

User avatar
Geraint
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Fri Aug 19, 2005 5:23 pm
Location: Gogledd Cymru

Re: getting pat template caching to work

Post by Geraint » Mon Nov 07, 2005 10:13 am

It was only when I single stepped through the code that I realised that my cache was being written but never being read.

Do you not get problems from

$fullPath = $this->_options['root']. '/' . $input;

returning 

Array/page.html  (or something similar)?

Geraint

p.s. The filemode issue is probably a Windows chmod related problem

alwarren
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Fri Aug 19, 2005 9:27 am

Re: getting pat template caching to work

Post by alwarren » Mon Nov 07, 2005 1:34 pm

I've not had any problems at all. Cache files are created and read normally.
Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW

User avatar
Geraint
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Fri Aug 19, 2005 5:23 pm
Location: Gogledd Cymru

Re: getting pat template caching to work

Post by Geraint » Mon Nov 07, 2005 2:28 pm

Ok I think I see part of what's going on.  You are using have 'lifetime' => 'auto' which means that the failing Stat file is not relevant in your setup.

The chmod problem I don't understand though (unless you are setting 'filemode'=>0755 or the likes somewhere).  If I don't specify the filemode value explicitly I get my file created with filemode 0000 - which is completely unreadable.  NB In case its relevant "I have Dont CHMOD new files (use server defaults) " set in my config file.

Geraint

alwarren
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Fri Aug 19, 2005 9:27 am

Re: getting pat template caching to work

Post by alwarren » Tue Nov 08, 2005 7:14 am

Geraint wrote: In case its relevant "I have Dont CHMOD new files (use server defaults) " set in my config file.
patTemplate is a third party script. I don't know if it's been modified to use J! server CHMOD settings.
Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW


Locked

Return to “patTemplate”