[Mediawiki-l] Common php code included more than once from two extensions

Michael Daly mikedaly at magma.ca
Thu Apr 19 23:17:58 UTC 2007


I have a special page that I'm writing that uses a common php file that 
I used in an extension I previously developed.  Since I want these two 
to be independent, I have the common file in each of the extension 
directories.

I use require_once() to load the file (it's not a class but a few 
functions) but, since the two files are in two different directories, 
the require_once() doesn't detect that it's already loaded (it checks 
both path and file to determine a match).  Hence, I get a redefinition 
error.

Since it's not a class, I don't use $wgAutoloadClasses.  I'm avoiding 
making the functions part of an otherwise empty class, since I don't 
want to use the class::function() syntax.  I could put them in a class 
file that contains an empty class and instantiate it just to load the 
file, but I was wondering if there is another, commonly accepted way to 
avoid this problem?

Mike



More information about the MediaWiki-l mailing list