[Mediawiki-l] create new pages by accessing the database directly FAILS

edward edward at confirmat.nl
Fri Jan 6 17:25:46 UTC 2006


I try to directly access the wiki-database to create new pages. I can 
create new pages, but the content is missing.

I use mediawiki 1.5.4.

The reason I directly want to use the database is to automate the 
following process:
I wrote an extension for a special page in which a form can be filled in 
by a user. The form is posted to a php-page in which I want to create a 
new page with a nicely formatted table with all the info the user gave 
me. Also the script must add a link to that newly created page in the 
main page (otherwise it will be an orphan).

The following php-script describes the sql-statements. I performed them 
manually in mysql to see what is happening. This is just to give an idea 
of what I did manually.

$newtitle = "dive-entry-12";
$text = "this is the text on the new page, but is NOT displayed!";

$sql1 = "insert into text (old_text, old_flags) values ($text, \"utf-8\")";

$sql2 = "select max(old_id) from text"; // returns $page_latest (it is 
old_id to be used as page_latest entry in page table)

$page_len = count($text);
$randomnr = rand(1000000)/1000000;
$currenttime= "20060103232541";

$sql3 = "insert into page (page_title, page_latest, page_len, 
page_random, page_touched) values ($newtitle, $page_latest, $page_len, 
$randomnr, $currenttime) ";


PROBLEM
=======
I can create the new entries in the page and the text tables. Now the 
entry in column page_latetest is the same as the entry old_id in text. 
So the page should get the correct contents. But I do not. The page is 
accessible via mediawiki but it is empty !!

Later I edited the page (using the wiki) and then the wiki adds the 
entry old_id=1408 with the new text. The page_latest is NOT altered 
(still 1407), but the new text with old_id=1408 is shown.

So the entry in table text I made (with old_id=1407) is not used at all. 
It is simply skipped and the content at old_id=1408 is shown although 
page_latest=1407!

Editing the page again changes page_latest to 1408 and old_id 1409 !!


QUESTION
========
What mechanism determines which text to show for a given requested page?

or (actually the main question)

How can I make good queries in the dbase to manually make (and alter) 
new pages?






More information about the MediaWiki-l mailing list