Harris, Mike wrote:
I am trying to create a new article eventually from a form you would fill out. The contents of the form would then be part of the article which you could edit.
You are aware of [[m:Help:Inputbox]] http://meta.wikimedia.org/wiki/Help:Inputbox, correct?
At this point all I want to do is create a new article with the name I specify. I am trying to use the Article and Title classes and use the function insertNewArticle(***) to accomplish this, but I keep getting database insert errors:
Here is my sample code:
$myTitle = new Title("Change Control Test"); $myArticle = new Article($myTitle); $myArticle->onArticleCreate($myTitle); $myArticle->insertNewArticle( "A test article", "Just Testing", FALSE, FALSE );
Do you have code to check that the user is actually allowed to create the article? Article::insertNewArticle() doesn't do this (in 1.5 or 1.4).
And the error:
A database error has occurred Query: INSERT INTO `cur` (cur_id,cur_namespace,cur_title,cur_text,cur_comment,cur_user,cur_timest amp,cur_minor_edit,cur_counter,cur_restrictions,cur_user_text,cur_is_red irect,cur_is_new,cur_random,cur_touched,inverse_timestamp) VALUES (NULL,'0','','A test article','Just Testing','1','20051013212242','0','0','','Mharris','0','1','0.0116757728 88','20051013212242','79948986787757') Function: Article::insertNewArticle Error: 1062 Duplicate entry '0-' for key 2 (localhost)
The sound of the error would indicate that you already have an article by that name (ie, your extension should check if the article exists before working). I also noticed that the cur_title is '' (empty string), so the article will likely be inaccessable.
Backtrace:
- GlobalFunctions.php line 524 calls wfBacktrace()
- Database.php line 383 calls wfDebugDieBacktrace()
- Database.php line 333 calls Database::reportQueryError()
- Database.php line 911 calls Database::query()
- Article.php line 885 calls Database::insert()
- ChangeControlExtension.php line 30 calls
Article::insertNewArticle()
- ChangeControlExtension.php line 45 calls
ChangeControlPage::ChangeControlPage()
- Setup.php line 381 calls wfChangeControlExtension()
- index.php line 26 calls require_once()
Is ChangeControlExtension.php your thing?
What is the best way to create a new article from an extension? I am using mediaiwiki 1.4.10.
The EditPage class if you really feel like having kludges and hacks around.
-- Jamie ------------------------------------------------------------------- http://endeavour.zapto.org/astro73/ Thank you to JosephM for inviting me to Gmail! Have lots of invites. Gmail now has 2GB.