Re: create new pages by accessing the database directly FAILS

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: create new pages by accessing the database directly FAILS

John McNeil
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
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: create new pages by accessing the database directly FAILS

edward hage
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');

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
> [hidden email]
> 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.

_______________________________________________
Wikitech-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: create new pages by accessing the database directly FAILS

Rob Church
A special page should NEVER define a new entry point, ever. Create it
as a proper special page, and use the proper, built-in classes, member
functions, and where needed, the globals.

Telling us what you're trying to *do* would also be a big step, so we
can give pointers.


Rob Church

On 07/01/06, edward hage <[hidden email]> wrote:

> 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');
>
> 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
> > [hidden email]
> > 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.
>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/wikitech-l
>
_______________________________________________
Wikitech-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: create new pages by accessing the database directly FAILS

edward hage
What I want to make is a site for scuba-divers. When they log in they
get a special Userpage (kind of homepage for every user). On that page
they have the possiblity to make a new dive-entry. If they click on that
link they go to a special page where they can fill in a table about
depth, time in the water, pressure, bla.bla. When they submit that data
a new page is created with a nice layout (I use a template in mediawiki)
with all dive-data. Also on the Userpage a new link to that new page is
automatically created when the dive-entry is submitted. So after a few
logged dives a complete list is created.
Because it is a wiki they can make additional pages about dive-locations
(like travelwiki) and upload underwater-pictures and create pages about
marine biology etc..

Any pointers are welcome.

After I solve the issue of making the new pages flauwless, I have to add
the privilege of the user to protect his own pages (so their own
divedata is not molested by other users). I saw on mediawiki that
already some patches and extenstions were written for that so that issue
is next on my agenda.

Also I am very interested to hear why new enrty points can not be made.

Greetings, Edward


Rob Church wrote:

>A special page should NEVER define a new entry point, ever. Create it
>as a proper special page, and use the proper, built-in classes, member
>functions, and where needed, the globals.
>
>Telling us what you're trying to *do* would also be a big step, so we
>can give pointers.
>
>
>Rob Church
>
>On 07/01/06, edward hage <[hidden email]> wrote:
>  
>
>>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.)
>>
>>    
>>
_______________________________________________
Wikitech-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: create new pages by accessing the database directly FAILS

Rob Church
[a] I suggest moving this thread to the mediawiki-l mailing list.
[b] It sounds to me like you're after a content management system, not
a wiki engine.


Rob Church

On 07/01/06, edward hage <[hidden email]> wrote:

> What I want to make is a site for scuba-divers. When they log in they
> get a special Userpage (kind of homepage for every user). On that page
> they have the possiblity to make a new dive-entry. If they click on that
> link they go to a special page where they can fill in a table about
> depth, time in the water, pressure, bla.bla. When they submit that data
> a new page is created with a nice layout (I use a template in mediawiki)
> with all dive-data. Also on the Userpage a new link to that new page is
> automatically created when the dive-entry is submitted. So after a few
> logged dives a complete list is created.
> Because it is a wiki they can make additional pages about dive-locations
> (like travelwiki) and upload underwater-pictures and create pages about
> marine biology etc..
>
> Any pointers are welcome.
>
> After I solve the issue of making the new pages flauwless, I have to add
> the privilege of the user to protect his own pages (so their own
> divedata is not molested by other users). I saw on mediawiki that
> already some patches and extenstions were written for that so that issue
> is next on my agenda.
>
> Also I am very interested to hear why new enrty points can not be made.
>
> Greetings, Edward
>
>
> Rob Church wrote:
>
> >A special page should NEVER define a new entry point, ever. Create it
> >as a proper special page, and use the proper, built-in classes, member
> >functions, and where needed, the globals.
> >
> >Telling us what you're trying to *do* would also be a big step, so we
> >can give pointers.
> >
> >
> >Rob Church
> >
> >On 07/01/06, edward hage <[hidden email]> wrote:
> >
> >
> >>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.)
> >>
> >>
> >>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> http://mail.wikipedia.org/mailman/listinfo/wikitech-l
>
_______________________________________________
Wikitech-l mailing list
[hidden email]
http://mail.wikipedia.org/mailman/listinfo/wikitech-l