[TYPO3-dev] cHash revisited
Elmar Hinz
elmar.DOT.hinz at team.MINUS.red.DOT.net
Wed Apr 5 21:36:41 CEST 2006
Hello typoniks,
while working on a successor for pi_base I am analysing the caching
mechanisms again. We usually have two cases: We want caching or we do not
want it.
To reach caching we do in piBase:
1.) using USER
2.) $pi_checkCHash = TRUE;
3.) configuring each link to produce a cHash
To inhibt caching we do:
1.) using USER_INT
2.) $pi_USER_INT_obj = TRUE;
To me it seems that there is more to configure then would be necessary to
give the information. But unecssary inforamtions are allways confusing and
lead to mistakes.
Ideally I would like to do one step using USER or USER_INT.
Why isn't that enough information?
Answer:
There are situations, where we link from one object USER_INT (search) to
USER (details). We simply could always produce a cHash if necessary or not.
But that is ugly. So we need to inform the link in each case if we wan't a
cHash or not.
Now we have:
1.) using USER or USER_INT
2.) configuering the links
But what are $pi_checkCHash and $pi_USER_INT_obj good for?
---------------------------------------------------------------------------
A) $pi_checkCHash
---------------------------------------------------------------------------
$pi_checkCHash is only used in line 223 of pi_base:
00223 if ($this->pi_checkCHash && count($this->piVars)) {
00224 $GLOBALS['TSFE']->reqCHash();
00225 }
Why dont we discard $pi_checkCHash and say:
00223 if (count($this->piVars)) {
00224 $GLOBALS['TSFE']->reqCHash();
00225 }
If $GLOBALS['TSFE']->reqCHash(); because of absence of cHash nothing is
lost. Is there any problem without, that I don't see?
---------------------------------------------------------------------------
B) $pi_USER_INT_obj
---------------------------------------------------------------------------
The sourcecode comment says: // If set, then links are 1) not using
cHash and 2) not allowing pages to be cached. (Set this for all USER_INT
plugins!)
Why do we need this?
2.) USER_INT are never cached by definition. What is the additional function?
1.) As mentioned above, we often link from USER_INT to USER. We want a
cHash in such links, even on the same page. (pi_linkTP)
Anyway pi_base links don't create a cHash by default, only if specially
requested for each link. So why additionally suppressing them?
$pi_USER_INT_obj is only used in this function (line 308):
function pi_linkTP($str,$urlParameters=array(), $cache=0,$altPageId=0) {
$conf=array();
//-------------------------------------------------------------------
$conf['useCacheHash'] = $this->pi_USER_INT_obj ? 0 : $cache;
$conf['no_cache'] = $this->pi_USER_INT_obj ? 0 : !$cache;
//-------------------------------------------------------------------
$conf['parameter'] = $altPageId ? $altPageId : ($this->pi_tmpPageId ?
$this->pi_tmpPageId : $GLOBALS['TSFE']->id);
$conf['additionalParams'] = $this->conf['parent.']['addParams']
.t3lib_div::implodeArrayForUrl('',$urlParameters,'',1).$this->pi_moreParams;
return $this->cObj->typoLink($str, $conf);
}
Why not plain:
function pi_linkTP($str, $urlParameters=array(), $cache=0, $altPageId=0) {
$conf=array();
//-------------------------------------------------------------------
$conf['useCacheHash'] = $cache;
// Without cHash it's not cached anyway.
//-------------------------------------------------------------------
$conf['parameter'] = $altPageId ? $altPageId : ($this->pi_tmpPageId ?
$this->pi_tmpPageId : $GLOBALS['TSFE']->id);
$conf['additionalParams'] = $this->conf['parent.']['addParams']
.t3lib_div::implodeArrayForUrl('',$urlParameters,'',1).$this->pi_moreParams;
return $this->cObj->typoLink($str, $conf);
}
Regards
Elmar
More information about the TYPO3-dev
mailing list