[imp] Filtercode (HEAD) is killing existing filterdefinitions!

Michael M Slusarz slusarz@bigworm.colorado.edu
Tue, 6 Aug 2002 15:58:04 -0600


Quoting Jan Schneider <jan@horde.org>:

| > I found the error - it wasn't in the logic of my code either. IMP_Filter
| > registers a shutdown function to save the filters anytime the filter
| list
| > is changed.  However, for some strange reason, the IMP_Filter shutdown 
| > function only sees the filters list at the time when it was registered.
|  
| > Thus, this is why only 1 filter was ever being saved.
| > 
| > This does not seem to be the correct behavior, at least when reading
| the 
| > register_shutdown_function() documentation.  Anybody have any idea on
| > this 
| > one?
| 
| No, but this already became suspicious to me as I had the feeling that if
| you select multiple messages for blacklisting, only one would have been
| saved. But I never investigated that further.

Final note: it appears that when you register a function for shutdown, PHP 
essentially "compiles" the function at that instant and will use 
that "compiled" function later.  Thus, if there is a class variable inside 
of that function, that variable will be used as it appears at the time the 
function is registered.  This appeared to be the problem in this case.

Workaround: see my latest commit for Filter.php;  Namely, don't use a class 
variable in the called shutdown function - use a "wrapper" function instead.

michael

______________________________________________
Michael Slusarz [slusarz@bigworm.colorado.edu]
The University of Colorado at Boulder