[Mediawiki-l] PHP code to create/edit pages/sections

Platonides Platonides at gmail.com
Mon Jul 23 10:41:50 UTC 2007


Kelly Jones wrote:
> I want to write PHP code for a MediaWiki I own (I have command-line +
> admin access) that:
> 
> % Checks if a given article exists, and creates it if not.
> 
> % Checks if a given section exists in an article, and creates it if not.
> 
> % Edits a given section in a given article.
> 
> I want the edit to be done just as if a user had gone in and edited
> the page: it should create a history entry, update all the appropriate
> tables, update the page in the cache, etc.
> 
> Can I use MediaWiki's PHP functions/libraries to do this?

I think using a mediawiki bot framework like pywikipedia would be easier.

> I realize I can use wget/curl/lynx/elinks to do this, but was looking
> for something more "internal".
> 
> On a related note, does MediaWiki come w/ any maintenance tools? Examples:
> 
> % Auto-fix all double redirects (if X -> Y -> Z, just edit X to
> redirect directly to Z).
There's a pywikipedia script to do that.

> % Find all instances of certain words (eg, spam), and revert to the
> previous version of each page that contains those words (crude
> anti-vandalism tool). Delete pages where there is no previous version.

run maintenance/cleanupSpam.php

> % For commonly misspelled articles, find all instances of [[wrong
> spelling]] and change them to [[correct spelling]] (redirecting "wrong
> spelling" to "right spelling" sort of works, but it still leaves the
> link misspelled on many pages)
run pywikipedia to change the links.

> I realize SQL queries can do some of this, but they won't update the
> history, won't handle caching issues properly, etc. I'm looking for
> something that works within MediaWiki's framework, not an outside
> hack.





More information about the MediaWiki-l mailing list