[Mediawiki-l] Problem with wiki database editing

edward edward at confirmat.nl
Fri Jan 6 14:42:13 UTC 2006


I am trying to auto-create pages by editing the database directly but I 
don't get that to work. I use vs. 1.5.4 of mediawiki


First let me explain the reason I want to do this:
I created a 'special page' with a form that people can fill in. When the 
form is submitted a page needs to be created with that info (in nice 
table layout).
Also a link need to be created in the main page to that new page 
(otherwise it would be an orphan). I want to automate this, so the user 
doesn't have to do that him/herself.

So I made an extension for the special page. The post of the form is 
directed to a php-page where I want to create the new page and also add 
the link to the main page (so open that page and alter it). From there 
the user gets redirected to the main page, so it can click on the newly 
made link.

Now I performed the following sql-statements (Did it by hand in mysql to 
see if it works like this/ beware this is not proper php):

$newtitle = "dive-entry-12";
$text = "dit is een blob hoop ik!!";

$sql1 = "insert into text (old_text, old_flags) values ($text, \"utf-8\")";
$sql2 = "select max(old_id) from text"; // result = $page_latest
$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) ";
$sql4="select page_latest from page where page_id=$page_id";
// answer $pagewithlink
$sql5="select old_text from text where old_id=$page_id"; // answer= $blob

THE PROBLEM
===========

The problem is that in table page the page_latest column is out of sink 
with old_id column in text table.

I could create all entries just fine, the new page was created but it 
was empty !!

Page_latest and old_id should be the same. Via page_latest the blog at 
old_text (in table text) can be reached. The blog with my text was there 
but it was not shown (page_latest = 1407, text at old_id=1407 not 
shown). Instead when I edited the page (so old_id=1408 was made) and the 
page showed the info at old_is=1408  correctly.
CONCLUSION: Although page_latest = 1407 the info at old_id=1408 is shown !!

Who has experience with the database and could help me create new pages?

Greetings, Edward Hage




More information about the MediaWiki-l mailing list