[geeklog-devel] Replacing/Extending Core Functions.

Tom Willett tomw at pigstye.net
Sat Jun 5 12:43:52 EDT 2004

While working on the Comment Spam plugin, I encountered an issue that I have 
encountered several times.  I was wondering if there is an easier way, I do 
not have a good suggestion.

The Comment Spam plugin intercepts the SaveComment function call to examine 
the comment and take appropriate action.  I did this by renaming the core 
savecomment function to savecomment1 and creating a new savecomment function 
in the functions.inc of the plugin.  This allows me to process the comment 
and pass it on to the savecomment function if needed.  Inelegant because it 
requires patching comment.php.  

I have encountered this issue several times and have resorted to disabling 
the core function and writing my own or extending the core function.

GL2 being OO should allow for easy extension or replacement of core 
functions -- its easy to write a class that extends another.  But in GL2 how 
could this modified class be installed as the core class and what about 
multiple dueling extensions to a class?  Like I said I do not have an easy 
suggestion, but better to think of it now than latter.  

Thinking about it I do have a partial suggestion, but I am not sure how it 
would effect performance -- have each class in its own seperate file.  Then 
all you have to do is replace the file -- this just magnifies the multiple 
dueling extensions problem though.

If anyone is interested, I built the spam plugin with extensibility in mind 
so that to add another filter or action or admin section all you have to do 
is place the class file with the extension in the plugin directory.  The 
plugin automatically uses it.  If you want I will post it here.

Tom Willett
tomw at pigstye.net

More information about the geeklog-devel mailing list