Merlijn van Deen | 4 Aug 19:44 2009
Picon

'' -> 'Main Page' title substitution

Hello all,

An empty page title is a non-normalized name for 'Main Page' in
mediawiki (except for 'delete' actions). This is most notable in the
interwiki links from 'Main Page':

http://en.wikipedia.org/w/api.php?action=query&prop=langlinks&titles=Main%20Page
returns
(...)
      <page pageid="15580374" ns="0" title="Main Page">
        <langlinks>
          <ll lang="ar" xml:space="preserve" />
          <ll lang="bg" xml:space="preserve" />
          <ll lang="ca" xml:space="preserve" />
          <ll lang="cs" xml:space="preserve" />

These links give the correct page when used as interwiki link
([[ar:$1]] resolves to http://ar.wikipedia.org/wiki/$1).
Resolving these pages using the API is impossible, however. It is
possible to ask for an empty title, but this yields

http://en.wikipedia.org/w/api.php?action=query&prop=langlinks&titles=|
(...)
    <pages>
      <page title="" invalid="" />
    </pages>

There are three possible solutions for this:
 1) Changing the interwiki links to link to the correct main page
 2) Letting the API resolve empty titles
(Continue reading)

Kalan | 4 Aug 20:42 2009
Picon

Re: '' -> 'Main Page' title substitution

On Tue, Aug 4, 2009 at 21:44, Merlijn van Deen<valhallasw <at> gmail.com> wrote:
> An empty page title is a non-normalized name for 'Main Page' in
> mediawiki (except for 'delete' actions).
[citation needed]. Is it used anywhere else but URL conversions?

> This is most notable in the
> interwiki links from 'Main Page':
As it seems to me, they (ab)use the fact that “” redirects to the main
page. Nothing more, nothing less.

> 3) Brr. 'Main Page' language tables.
It is the most obvious solution that doesn’t require unclear
implications to be made. Query MediaWiki:Mainpage, then query the page
title you get from there.

Or… did I get your point wrong?

— Kalan

_______________________________________________
Mediawiki-api mailing list
Mediawiki-api <at> lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Merlijn van Deen | 4 Aug 20:54 2009
Picon

Re: '' -> 'Main Page' title substitution

On Tue, Aug 4, 2009 at 8:42 PM, Kalan<kalan.001 <at> gmail.com> wrote:
> On Tue, Aug 4, 2009 at 21:44, Merlijn van Deen<valhallasw <at> gmail.com> wrote:
>> An empty page title is a non-normalized name for 'Main Page' in
>> mediawiki (except for 'delete' actions).
> [citation needed]. Is it used anywhere else but URL conversions?
includes/Wiki.php:113
113 :	} elseif( '' == $title && 'delete' != $action ) {
114 :		$ret = Title::newMainPage();

for example: http://en.wikisource.org/w/index.php?title=&action=edit

>> 3) Brr. 'Main Page' language tables.
> It is the most obvious solution that doesn’t require unclear
> implications to be made. Query MediaWiki:Mainpage, then query the page
> title you get from there.
I hadn't noticed before, but action=query&meta=siteinfo looks about
right. Does require two lookups, though.

-Merlijn

_______________________________________________
Mediawiki-api mailing list
Mediawiki-api <at> lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Alex | 4 Aug 21:11 2009
Picon

Re: '' -> 'Main Page' title substitution

Merlijn van Deen wrote:

> There are three possible solutions for this:
>  1) Changing the interwiki links to link to the correct main page
>  2) Letting the API resolve empty titles
>  3) Resolving it client-side
> 
> All three have their disadvantages:
>  1) Community outrage; additionally it needs more maintenance. The
> current system is pretty fool-proof.

Why would this cause outrage? I know some communities like drama, but I
don't see why changing "[[de:]]" to "[[de:Wikipedia:Hauptseite]]" would
cause problems, and I don't think most projects change the location of
their main page very often (even if they do, there should still be a
redirect)

>  2) The API consistently uses Title:newFromText to resolve the title.
> This function is used all over mediawiki, however, so changing it
> makes {{}} a valid construct. This changes parser behaviour, which is
> (iirc) not acceptable. The alternative would be to add a conditional
> for every call to newFromText. Mediawiki normally uses
> Wiki::checkInitialQueries to resolve '', but it's not possible to use
> that function.

This would probably be the easiest, I don't really see any problems,
unless we're worried about it being a breaking change for people who
might rely on an empty string being an invalid title. Changing it in the
API rather than Title would make more sense (since we only want the
behavior change for the API).
(Continue reading)

Kalan | 4 Aug 21:35 2009
Picon

Re: '' -> 'Main Page' title substitution

On Tue, Aug 4, 2009 at 22:54, Merlijn van Deen<valhallasw <at> gmail.com> wrote:
> On Tue, Aug 4, 2009 at 8:42 PM, Kalan<kalan.001 <at> gmail.com> wrote:
>> On Tue, Aug 4, 2009 at 21:44, Merlijn van Deen<valhallasw <at> gmail.com> wrote:
>>> An empty page title is a non-normalized name for 'Main Page' in
>>> mediawiki (except for 'delete' actions).
>> [citation needed]. Is it used anywhere else but URL conversions?
> includes/Wiki.php:113
> 113 :   } elseif( '' == $title && 'delete' != $action ) {
> 114 :           $ret = Title::newMainPage();
Yes, this is about requests handling, not title handling.

>>> 3) Brr. 'Main Page' language tables.
>> It is the most obvious solution that doesn’t require unclear
>> implications to be made. Query MediaWiki:Mainpage, then query the page
>> title you get from there.
> I hadn't noticed before, but action=query&meta=siteinfo looks about
> right. Does require two lookups, though.
At least it’s obvious _what_ two lookups you have to make :)

— Kalan

_______________________________________________
Mediawiki-api mailing list
Mediawiki-api <at> lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Brion Vibber | 6 Aug 23:32 2009
Picon

Re: '' -> 'Main Page' title substitution

On 8/4/09 12:11 PM, Alex wrote:
>>   2) The API consistently uses Title:newFromText to resolve the title.
>> This function is used all over mediawiki, however, so changing it
>> makes {{}} a valid construct. This changes parser behaviour, which is
>> (iirc) not acceptable. The alternative would be to add a conditional
>> for every call to newFromText. Mediawiki normally uses
>> Wiki::checkInitialQueries to resolve '', but it's not possible to use
>> that function.
>
> This would probably be the easiest, I don't really see any problems,
> unless we're worried about it being a breaking change for people who
> might rely on an empty string being an invalid title. Changing it in the
> API rather than Title would make more sense (since we only want the
> behavior change for the API).

"" does not ever mean "Main Page".

When a visitor reaches the web site, but no title is specified, we have 
nothing to display -- so we send them to the locally defined main entry 
page.

This is a user interface activity.

There is no time or place that we would or should ever interpret "empty 
title" to mean "Main Page" in any other kind of interaction or i/o. To 
do so would be egregiously wrong and would be very likely to cause 
strange, mysterious, hard to track down breakage.

-- brion vibber (brion  <at>  wikimedia.org)
(Continue reading)

Kathleen Borja | 7 Aug 09:29 2009
Picon

Re: Creating an Extension for my thesaurus

Here are the files I've created for SpecialThesaurus extension:
>SpecialThesaurus.php
>SpecialThesaurus_body.php
>SpecialThesaurus.alias.php
>SpecialThesaurus.i18n.php

The SpecialThesaurus_body.php file I've sent to Roan Kattouw this day consists
of the major form elements. The contents are too long to be displayed here
that's why I just sent it to Roan Kattouw's email. For now, this file allows
user to search for keyword in the given sentence "The
quick brown fox jumps over the lazy dog near the bank of the river." If a given
keyword is found, it makes a link to that searched keyword and a form including
a input box for tag, select tag for origins, etc. Still, the form is not yet
functioning... But, this is how it's gonna be...

Questions:
> About the contents on the SpecialThesaurus_body.php, am I on the right track?

> About connecting to db, I used $dbr = wfGetDb(DB_SLAVE) command. How can I
check if it was really connected to the db? How can I fetch arrays from db? Are
there db functions specially made for mediawiki that I can use?

> What kind of Hook shall I use if I wanted the elements in SpecialThesaurus
(form including input boxes, etc.) be included some part of an article page?
Let's say I wanted to put the form and other elements on the right part of the
page.. How will I do it? 

> With the three other files, what kind of contents shall I add to them?

I badly needed your help, guys. Thanks (^_^)
(Continue reading)

Max Semenik | 7 Aug 12:51 2009
Picon

Re: '' -> 'Main Page' title substitution

On 07.08.2009, 1:32 Brion wrote:

> There is no time or place that we would or should ever interpret "empty
> title" to mean "Main Page" in any other kind of interaction or i/o. To
> do so would be egregiously wrong and would be very likely to cause 
> strange, mysterious, hard to track down breakage.

O RLY? http://en.wikipedia.org/wiki/?action=edit&oldid=-1
Apparently, the "I don't know the title" situation is still handled as
"what the hell, let's assign just soooomething useful to it, 'Main
Page' looks just fine" in some places.

--

-- 
Best regards,
  Max Semenik (formerly [[User:MaxSem]])
Merlijn van Deen | 7 Aug 15:57 2009
Picon

Re: '' -> 'Main Page' title substitution

On Fri, Aug 7, 2009 at 12:51 PM, Max Semenik<maxsem.wiki <at> gmail.com> wrote:
> O RLY? http://en.wikipedia.org/wiki/?action=edit&oldid=-1
> Apparently, the "I don't know the title" situation is still handled as
> "what the hell, let's assign just soooomething useful to it, 'Main
> Page' looks just fine" in some places.

Different strategies for different actions:
  action=view: redirect to /wiki/Main Page
  action=delete: bad title
  action=(anything else): assume 'Main Page' without redirect

According to brions story, I would think the logical system would be to
   action=view: redirect to /wiki/Main Page
   action=(anything else): bad title

And, if I understand correctly, the fix should be changing all 'empty'
interlanguage links to 'main page' or their local equivalent.

-Merlijn
Roan Kattouw | 8 Aug 11:58 2009
Picon

Re: Creating an Extension for my thesaurus

2009/8/7 Kathleen Borja <jane88borj <at> yahoo.com>:
> Here are the files I've created for SpecialThesaurus extension:
>>SpecialThesaurus.php
>>SpecialThesaurus_body.php
>>SpecialThesaurus.alias.php
>>SpecialThesaurus.i18n.php
>
> The SpecialThesaurus_body.php file I've sent to Roan Kattouw this day consists
> of the major form elements. The contents are too long to be displayed here
> that's why I just sent it to Roan Kattouw's email.
I never got it. Please verify you've got the right address.

> Questions:
>> About the contents on the SpecialThesaurus_body.php, am I on the right track?
>
>> About connecting to db, I used $dbr = wfGetDb(DB_SLAVE) command. How can I
> check if it was really connected to the db? How can I fetch arrays from db? Are
> there db functions specially made for mediawiki that I can use?
>
If connecting with the DB fails, an error page will be displayed with
your user and your code won't run past the wfGetDb statement, so you
don't have to worry about that. Methods of the $dbr object are
documented at http://svn.wikimedia.org/doc/classDatabaseBase.html . A
simple example would be:

$res = $dbr->select( 'tablename', array( 'field1', 'field2' ), array(
'field1' => 'foo', 'field3=field1' ), __METHOD__ );
foreach ( $res as $row ) {
    // Do something with $row->field1, $row->field2
}
(Continue reading)


Gmane