Hello John, Hendrik,
I also made a SpecialPage, but I did not post back to the page itself. I
did to a new page where I defined some basic stuff by:
define( 'MEDIAWIKI', true );
require_once( '../includes/Defines.php' );
require_once( '../LocalSettings.php' );
require_once( '../includes/Setup.php' );
Basically made a new entry-point. I hope this does not cause a
safety-issue ! (I don't know the do's and dont's about this.)
So now I got all the globals and I can define a database connection like:
$db = new Database($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname);
Now I can make the new entries in the tables page, text and revision (I
was missing that last table, I found that out and also Rob Church
pointed me to the existence of rev_id) .... just installed mediawiki
last week.
After making the new page and altering 'Userpage' (making a link to the
new page) I return to Userpage so I can click on my newly made link to
my new page:
header('Location:
http://server/wiki/index.php/Userpage')39;);
Basically I have everything working, but I have trouble that I don't see
my link when I return to Userpage. Must have to do with caching in
mediawiki itself. When I empty my cache on firefox it is still not
visible. Only workaround now I have is to 'edit' the page, then the link
is shown. Tips to resolve this are welcome.
Also another issue is that I created a race condition with the following
syntax. Hendrik Brummerman pointed me this out. I suspected that
already, because inbetween performing $sql1 and $sql2 old_id may be
changed by insertions of other people in the table. Thanks for the tip.
$sql1 = "insert into text (old_text, old_flags) values ($text,
\"utf-8\")";
$sql2 = "select max(old_id) from text"; // result = $page_latest
This is a [[Race Condition]]. Please use $dbw->insertId() (in MediaWiki)
or mysql_insert_id for MySQL databases outside of MediaWiki.
Thanks, Edward
John McNeil wrote:
Edward,
I don't have the answer to your questions about making new pages
directly in the database, but I accomplished the same thing in a
SpecialPage I wrote by creating the content and a new Article from
within the SpecialPage code itself. The SpecialPage defines the form,
and posts back to itself. That way you are still in context with all
the globals you need to make new pages easily. My only difficulty
with this is that the $newArticle->insertNewArticle method ends by
telling the new Article to display itself, yanking you out of the
SpecialPage code.
My SpecialPage is derived from BoardVote.php, which used to be
referenced as an example. You can find it here:
http://cvs.sourceforge.net/viewcvs.py/wikipedia/extensions/BoardVote/
BoardVote.php?rev=1.3&only_with_tag=MAIN&view=markup
John
_______________________________________________
Wikitech-l mailing list
Wikitech-l(a)wikimedia.org
http://mail.wikipedia.org/mailman/listinfo/wikitech-l
--
CONFIRMAT Mechatronics & product development
Veluwehof 71
5709 KJ Helmond
http://www.confirmat.nl
************************************* Disclaimer ***********************************
De informatie opgenomen in dit bericht kan vertrouwelijk zijn en is uitsluitend bestemd
voor de geadresseerde. Indien u dit bericht onterecht ontvangt, verzoeken wij u de inhoud
niet te gebruiken. Wij verzoeken u de zender direct op de hoogte te stellen door het
bericht te retourneren en alle copieen van dit bericht inclusief enige aangehechte
bestanden te verwijderen.
The information contained in this message may be confidential and is intended to be
exclusively for the addressee. Should you receive this message unintentionally, please do
not use the contents herein. Please notify the sender directly by replying this message
and destroy all copies of this message and any attachments.