[Mediawiki-l] Creating a new article from a from

Harris, Mike mharris at visionbankcard.net
Thu Oct 13 21:23:13 UTC 2005


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.  

 

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 );



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)

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()

 

 

What is the best way to create a new article from an extension?  I am
using mediaiwiki 1.4.10.  

 

Thanks,

Mike




More information about the MediaWiki-l mailing list