[Mediawiki-l] How to get around a kludge for external access to MW objects

Jim Hu jimhu at tamu.edu
Tue Nov 30 22:26:50 UTC 2010


For the past couple of years, I've been using various scripts to mine data out of my wikis from other sites/services on the same server (but sometimes on different virtual hosts).  To do this, I've been doing something that is probably really bad coding practice - I fool maintenance/commandLine.inc into thinking it's being invoked by the command line instead of from a webserver.  

Typically, I'm doing something like:

unset($_SERVER);
$argv = array('foo');
require_once("$wikipath/maintenance/commandLine.inc");

# need MW stuff to create $dbr
$dbr =& wfGetDB( DB_SLAVE );
$result =  $dbr->select ( <some query>);

# do something with the result
...

but we are often also using Title, Article, and/or Revision objects, Categories etc.  My approach seems to fail in MW versions post 1.14.  I'm reviewing a bunch of this code now to see if I can clean some other things up/make it easier to maintain/make it forward compatible, so I thought I'd ask the list: is there a better way to do this?  

Thanks!

Jim

=====================================
Jim Hu
Associate Professor
Dept. of Biochemistry and Biophysics
2128 TAMU
Texas A&M Univ.
College Station, TX 77843-2128
979-862-4054




More information about the MediaWiki-l mailing list