[Typo3-dev] Hooks and caching

Suman Debnath suman at srijan.co.in
Tue Mar 1 12:02:53 CET 2005


Hi Everybody,

I have created a hook in an extension of mine. The relevant code portion:
if 
(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3conf/ext/safe_password/class.passwordChecker.php']['user_passcheck']))
  {
   foreach 
($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3conf/ext/safe_password/class.passwordChecker.php']['user_passcheck'] 
as $classRef)
   {
    $obj = &t3lib_div::getUserObj($classRef);
    $output = $obj->user_passcheck($output, $pass, $name, &$this);
   }
  }

In another test extension I am using that hook. Created a file called 
class.tx_passwordtest_pchecker.php. Its code:
class tx_passwordtest_pchecker
{
 function user_passcheck($output, $pass, $name, $obj)
 {
  $obj->err_code = "Modified By User Function";
  return true;
 }
}

Edited ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3conf/ext/safe_password/class.passwordChecker.php']['user_passcheck'][] 
= 'tx_passwordtest_pchecker';

Edited ext_tables.php:
require_once("typo3conf/ext/password_test/class.tx_passwordtest_pchecker.php");

After all this, when I go to the output page (plugin), the following error 
comes:
|<strong>ERROR:</strong> No class named: tx_passwordtest_pchecker|
Fatal error: Call to a member function on a non-object in 
X:\XXXXXX\XXXX\typo3conf\ext\safe_password\class.passwordChecker.php on line 
85

I try going to the BE and the following error comes:
Warning: 
main(typo3conf/ext/password_test/class.tx_passwordtest_pchecker.php): failed 
to open stream: No such file or directory in 
X:\XXXXXX\XXXX\typo3conf\temp_CACHED_ps3e46_ext_tables.php on line 1478
Fatal error: main(): Failed opening required 
'typo3conf/ext/password_test/class.tx_passwordtest_pchecker.php' 
(include_path='.;c:\php\pear') in 
X:\XXXXXX\XXXX\typo3conf\temp_CACHED_ps3e46_ext_tables.php on line 1478

So I manually delete the two offending cache files. I refresh the page and 
and the whole thing works! But during the process the cache got created once 
more and on next refresh the cycle starts again.:-)

Now, I have no control on whoever will create the client script to use this 
library (the 2nd extension was a test) so I cannot just clear the cache 
inside the code using the hook. Then how do I prevent this from happening in 
the hook creation process itself?
-- 
Thanks in advance,
Suman Debnath 






More information about the TYPO3-dev mailing list