Re: [Wikitech-l] Problem to get an article's content in MW 1.20.2

2013-01-21 Thread Andreas Plank
Hi,

thanks for your suggestions, at the end I found it :-)

It was a closed data base connection, that prevented
Title::newFrom...-methods to get articleId etc.
--- the eval part ---
$dbReadOnly2 = wfGetDB(DB_SLAVE);
# do some stuff
$dbReadOnly2->close();

# use another method that needs data base access will fail
---

It is because wfGetDB(...); will get the database object as
*reference* not as copy (see PHP code of wfGetDB() in file
includes/GlobalFunctions.php) and as it is a reference and some other
function closes the dabta base connection then there is "silence" ...
at least for the db connection

Andreas

2013/1/16 Andreas Plank :
> 2013/1/16 Krenair :
>> You could try RequestContext::getMain() to get the context source object.
>>
>> Alex Monk
>>
>> On 16/01/13 16:56, Andreas Plank wrote:
>
> I tried many functions in various classes:
> RequestContext
> WikiPage
> Title
> Article
> ... but it is always the same I do not get the raw page content. I
> believe these functions should work but somehow they do not get the
> right incoming data. In an earlier post I printed the Title object and
> it is almost empty, I wonder about that too, might be related?
>
> Maybe it has nothing to do with these functions but with the database?
> However browsing and editing those pages runs smoothly but my
> application does not get the related page data. I wonder too, because
> with MW 1.18 it did work fine.
>
> If I switch on $wgDebugDumpSql there are a lot of queries and also a page 
> query
> SELECT page_id, page_namespace, page_title, page_restrictions,
> page_counter, page_is_redirect, page_is_new, page_random,
> page_touched, page_latest, page_len FROM `page` WHERE page_namespace =
> 'X' LIMIT N
> ... So it seems the right query from a quick look.
>
> Has anybody an idea how I can trace and debug the data flow until my
> app asserts “the page does not exist”?
>
> Andreas

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Problem to get an article's content in MW 1.20.2

2013-01-16 Thread Andreas Plank
2013/1/16 Krenair :
> You could try RequestContext::getMain() to get the context source object.
>
> Alex Monk
>
> On 16/01/13 16:56, Andreas Plank wrote:

I tried many functions in various classes:
RequestContext
WikiPage
Title
Article
... but it is always the same I do not get the raw page content. I
believe these functions should work but somehow they do not get the
right incoming data. In an earlier post I printed the Title object and
it is almost empty, I wonder about that too, might be related?

Maybe it has nothing to do with these functions but with the database?
However browsing and editing those pages runs smoothly but my
application does not get the related page data. I wonder too, because
with MW 1.18 it did work fine.

If I switch on $wgDebugDumpSql there are a lot of queries and also a page query
SELECT page_id, page_namespace, page_title, page_restrictions,
page_counter, page_is_redirect, page_is_new, page_random,
page_touched, page_latest, page_len FROM `page` WHERE page_namespace =
'X' LIMIT N
... So it seems the right query from a quick look.

Has anybody an idea how I can trace and debug the data flow until my
app asserts “the page does not exist”?

Andreas

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Problem to get an article's content in MW 1.20.2

2013-01-16 Thread Krenair

You could try RequestContext::getMain() to get the context source object.

Alex Monk
On 16/01/13 16:56, Andreas Plank wrote:

Hi,

One of Tyler Romeo's suggested approach is to use

Article::newFromTitle($titleObj)

... but it does need a second argument of type IContextSource. I do
not know how to get it or how to instantiate it yet. At the moment it
does not retrieve the page content as well because of the missing
IContextSource ...



___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Problem to get an article's content in MW 1.20.2

2013-01-16 Thread Andreas Plank
Hi,

One of Tyler Romeo's suggested approach is to use

Article::newFromTitle($titleObj)

... but it does need a second argument of type IContextSource. I do
not know how to get it or how to instantiate it yet. At the moment it
does not retrieve the page content as well because of the missing
IContextSource ...

Can somebody Maybe Article::newFromTitle($titleObj,
IContextSource-something) would

Do I need that IContextSource? I read at Manual:Article.php to use the
WikiPage class instead, so maybe at this point I don't have to use
IContextSource(?). WikiPage::factory($titleObj) prints the same Title
Object structure as Title::newFromText("Existing page but not existing
for Title object class");

Does it may have to do with data base update, some of the maintenance
scripts? Maybe data in the data base are not entirely correct after
upgrading from MW 1.18 to MW 1.20.2? How do I ensure that the data
base has correct page data? When I run php ./update.php --conf
/path/to/LocalSettings.php all is fine ... any further idea?

Thanks,
Andreas

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Problem to get an article's content in MW 1.20.2

2013-01-16 Thread Andreas Plank
Hi Platonides

(sorry I posted from a wrong Email address, I try again with a proper
subject line to get the thread line correct on
http://news.gmane.org/gmane.science.linguistics.wikipedia.technical)

2013/1/15 Platonides :
>> I tried to get the content via getArticleID() ...
>> $titleObj=Title::newFromText("Existing page");
>> $articleID=$titleObj->getArticleID();
>> Article::newFromID($articleID)->fetchContent();
>> etc.
>> ... but it returns $articleID=0 although the page exits. With MW 1.18
>> this approach worked fine, but after upgrade to MW 1.20.2 it does not
>> any more.
>
>
> It should be working, and it works for me on 1.20.2
> Can you provide more details on that $title->getArticleID(); which is
> not working?

On the http://offene-naturfuehrer.de/web/Spezial:MobileKeyV1
I want to generate a MobileKey for "Lamium (Deutschland)" (the page
exists) and the PHP code wants to get the content of page "Unterlippe
(Lamiaceae)" (the page exists too) but the PHP code above stops at the
step retrieving the articleID. The strange thing is, when I want to
generate a MobileKey for "Lamium (Deutschland)" and just print out
(1) Title::newFromText("Unterlippe (Lamiaceae)")  and
(2) Title::newFromText("Lamium (Deutschland)")
... I get only an articleID for (2) not for (1)

WikiPage::factory ($titleObj) prints the same articleID data as
Title::newFromText(...)

Andreas

--- printout of title object for page (1) "Unterlippe (Lamiaceae)"

Title Object
(
[mTextform] => Unterlippe (Lamiaceae)
[mUrlform] => Unterlippe_(Lamiaceae)
[mDbkeyform] => Unterlippe_(Lamiaceae)
[mUserCaseDBKey] => Unterlippe_(Lamiaceae)
[mNamespace] => 0
[mInterwiki] =>
[mFragment] =>
[mArticleID] => 0
[mLatestID] =>
[mEstimateRevisions:Title:private] =>
[mRestrictions] => Array
(
)

[mOldRestrictions] =>
[mCascadeRestriction] =>
[mCascadingRestrictions] =>
[mRestrictionsExpiry] => Array
(
)

[mHasCascadingRestrictions] =>
[mCascadeSources] =>
[mRestrictionsLoaded] =>
[mPrefixedText] =>
[mTitleProtection] =>
[mDefaultNamespace] => 0
[mWatched] =>
[mLength] => -1
[mRedirect] =>
[mNotificationTimestamp] => Array
(
)

[mHasSubpage] =>
)

--- printout of title object for page (2) "Lamium (Deutschland)"
Title Object
(
[mTextform] => Lamium (Deutschland)
[mUrlform] => Lamium_(Deutschland)
[mDbkeyform] => Lamium_(Deutschland)
[mUserCaseDBKey] => Lamium_(Deutschland)
[mNamespace] => 0
[mInterwiki] =>
[mFragment] =>
[mArticleID] => 36
[mLatestID] =>
[mEstimateRevisions:Title:private] =>
[mRestrictions] => Array
(
)

[mOldRestrictions] =>
[mCascadeRestriction] =>
[mCascadingRestrictions] =>
[mRestrictionsExpiry] => Array
(
)

[mHasCascadingRestrictions] =>
[mCascadeSources] =>
[mRestrictionsLoaded] =>
[mPrefixedText] =>
[mTitleProtection] =>
[mDefaultNamespace] => 0
[mWatched] =>
[mLength] => -1
[mRedirect] =>
[mNotificationTimestamp] => Array
(
)

[mHasSubpage] =>
)

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Problem to get an article's content in MW 1.20.2

2013-01-15 Thread Platonides
On 15/01/13 14:44, Andreas Plank wrote:
> Hi,
> 
> I'm using MW 1.20.2  and I want to get the content of a page for
> further parsing in a PHP application. The PHP application is triggered
> via a special page (Special:MobileKeyV1) and parses nature guides for
> mobile devices.
> 
> I tried to get the content via getArticleID() ...
> $titleObj=Title::newFromText("Existing page");
> $articleID=$titleObj->getArticleID();
> Article::newFromID($articleID)->fetchContent();
> etc.
> ... but it returns $articleID=0 although the page exits. With MW 1.18
> this approach worked fine, but after upgrade to MW 1.20.2 it does not
> any more.


It should be working, and it works for me on 1.20.2
Can you provide more details on that $title->getArticleID(); which is
not working?


___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Re: [Wikitech-l] Problem to get an article's content in MW 1.20.2

2013-01-15 Thread Tyler Romeo
That is true. Also if it's interwiki.

*--*
*Tyler Romeo*
Stevens Institute of Technology, Class of 2015
Major in Computer Science
www.whizkidztech.com | tylerro...@gmail.com


On Tue, Jan 15, 2013 at 11:12 AM, bawolff  wrote:

> While it may be true that there are better methods to call for this
> purpose, an article's id should be 0 if and only if it does not exist
> (or perhaps if its in a fake namespace like special).
>
> -bawolff
>
> On Tue, Jan 15, 2013 at 10:15 AM, Tyler Romeo 
> wrote:
> > I think the best thing to do would be to just avoid getting the article
> ID
> > in the first place. If you have a Title object, you can just pass that
> > object directly to either Article::newFromTitle or to WikiPage::factory.
> >
> > *--*
> > *Tyler Romeo*
> > Stevens Institute of Technology, Class of 2015
> > Major in Computer Science
> > www.whizkidztech.com | tylerro...@gmail.com
> >
> >
> > On Tue, Jan 15, 2013 at 9:11 AM, Harsh Kothari <
> harshkothari...@gmail.com>wrote:
> >
> >> Hi Andreas
> >>
> >> Try this
> >>
> >> $someobj = WikiPage::newFromId(  $ID );
> >>
> >> if(is_object( $someobj ) ){
> >> $text = $someobj->getRawText(); or you can use $text =
> >> $someobj->getText();
> >>
> >> }
> >> else{
> >>
> >> return true;
> >> }
> >>
> >> Thanks
> >> Harsh
> >> ---
> >> Harsh Kothari
> >> Research Fellow,
> >> Physical Research Laboratory(PRL).
> >> Ahmedabad.
> >>
> >>
> >> On 15-Jan-2013, at 7:14 PM, Andreas Plank wrote:
> >>
> >> > Hi,
> >> >
> >> > I'm using MW 1.20.2  and I want to get the content of a page for
> >> > further parsing in a PHP application. The PHP application is triggered
> >> > via a special page (Special:MobileKeyV1) and parses nature guides for
> >> > mobile devices.
> >> >
> >> > I tried to get the content via getArticleID() ...
> >> > $titleObj=Title::newFromText("Existing page");
> >> > $articleID=$titleObj->getArticleID();
> >> > Article::newFromID($articleID)->fetchContent();
> >> > etc.
> >> > ... but it returns $articleID=0 although the page exits. With MW 1.18
> >> > this approach worked fine, but after upgrade to MW 1.20.2 it does not
> >> > any more.
> >> >
> >> > How do I get the page content correctly?
> >> > Article::newFromID($titleObj->getArticleID())->fetchContent(); does
> >> > not work because getArticleID() returns 0 or -1 although the page
> >> > exits
> >> > Or can sombody post a hint, what I'm doing wrong? Is there any context
> >> > class needed?
> >> > Or where there some big changes (MW 1.18 → 1.20) that are not
> >> > described yet on http://www.mediawiki.org/wiki/Manual:Title.php ?
> >> >
> >> > I did also a
> >> > sudo php ./maintenance/rebuildall.php --conf ./LocalSettings.php
> >> > But it did not help either
> >> >
> >> > Thanks for your help!
> >> >
> >> > Kind regards
> >> > Andreas
> >> >
> >> > ___
> >> > Wikitech-l mailing list
> >> > Wikitech-l@lists.wikimedia.org
> >> > https://lists.wikimedia.org/mailman/listinfo/wikitech-l
> >>
> >> ___
> >> Wikitech-l mailing list
> >> Wikitech-l@lists.wikimedia.org
> >> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
> >>
> > ___
> > Wikitech-l mailing list
> > Wikitech-l@lists.wikimedia.org
> > https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
> ___
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Problem to get an article's content in MW 1.20.2

2013-01-15 Thread bawolff
While it may be true that there are better methods to call for this
purpose, an article's id should be 0 if and only if it does not exist
(or perhaps if its in a fake namespace like special).

-bawolff

On Tue, Jan 15, 2013 at 10:15 AM, Tyler Romeo  wrote:
> I think the best thing to do would be to just avoid getting the article ID
> in the first place. If you have a Title object, you can just pass that
> object directly to either Article::newFromTitle or to WikiPage::factory.
>
> *--*
> *Tyler Romeo*
> Stevens Institute of Technology, Class of 2015
> Major in Computer Science
> www.whizkidztech.com | tylerro...@gmail.com
>
>
> On Tue, Jan 15, 2013 at 9:11 AM, Harsh Kothari 
> wrote:
>
>> Hi Andreas
>>
>> Try this
>>
>> $someobj = WikiPage::newFromId(  $ID );
>>
>> if(is_object( $someobj ) ){
>> $text = $someobj->getRawText(); or you can use $text =
>> $someobj->getText();
>>
>> }
>> else{
>>
>> return true;
>> }
>>
>> Thanks
>> Harsh
>> ---
>> Harsh Kothari
>> Research Fellow,
>> Physical Research Laboratory(PRL).
>> Ahmedabad.
>>
>>
>> On 15-Jan-2013, at 7:14 PM, Andreas Plank wrote:
>>
>> > Hi,
>> >
>> > I'm using MW 1.20.2  and I want to get the content of a page for
>> > further parsing in a PHP application. The PHP application is triggered
>> > via a special page (Special:MobileKeyV1) and parses nature guides for
>> > mobile devices.
>> >
>> > I tried to get the content via getArticleID() ...
>> > $titleObj=Title::newFromText("Existing page");
>> > $articleID=$titleObj->getArticleID();
>> > Article::newFromID($articleID)->fetchContent();
>> > etc.
>> > ... but it returns $articleID=0 although the page exits. With MW 1.18
>> > this approach worked fine, but after upgrade to MW 1.20.2 it does not
>> > any more.
>> >
>> > How do I get the page content correctly?
>> > Article::newFromID($titleObj->getArticleID())->fetchContent(); does
>> > not work because getArticleID() returns 0 or -1 although the page
>> > exits
>> > Or can sombody post a hint, what I'm doing wrong? Is there any context
>> > class needed?
>> > Or where there some big changes (MW 1.18 → 1.20) that are not
>> > described yet on http://www.mediawiki.org/wiki/Manual:Title.php ?
>> >
>> > I did also a
>> > sudo php ./maintenance/rebuildall.php --conf ./LocalSettings.php
>> > But it did not help either
>> >
>> > Thanks for your help!
>> >
>> > Kind regards
>> > Andreas
>> >
>> > ___
>> > Wikitech-l mailing list
>> > Wikitech-l@lists.wikimedia.org
>> > https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>>
>> ___
>> Wikitech-l mailing list
>> Wikitech-l@lists.wikimedia.org
>> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>>
> ___
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Problem to get an article's content in MW 1.20.2

2013-01-15 Thread Tyler Romeo
I think the best thing to do would be to just avoid getting the article ID
in the first place. If you have a Title object, you can just pass that
object directly to either Article::newFromTitle or to WikiPage::factory.

*--*
*Tyler Romeo*
Stevens Institute of Technology, Class of 2015
Major in Computer Science
www.whizkidztech.com | tylerro...@gmail.com


On Tue, Jan 15, 2013 at 9:11 AM, Harsh Kothari wrote:

> Hi Andreas
>
> Try this
>
> $someobj = WikiPage::newFromId(  $ID );
>
> if(is_object( $someobj ) ){
> $text = $someobj->getRawText(); or you can use $text =
> $someobj->getText();
>
> }
> else{
>
> return true;
> }
>
> Thanks
> Harsh
> ---
> Harsh Kothari
> Research Fellow,
> Physical Research Laboratory(PRL).
> Ahmedabad.
>
>
> On 15-Jan-2013, at 7:14 PM, Andreas Plank wrote:
>
> > Hi,
> >
> > I'm using MW 1.20.2  and I want to get the content of a page for
> > further parsing in a PHP application. The PHP application is triggered
> > via a special page (Special:MobileKeyV1) and parses nature guides for
> > mobile devices.
> >
> > I tried to get the content via getArticleID() ...
> > $titleObj=Title::newFromText("Existing page");
> > $articleID=$titleObj->getArticleID();
> > Article::newFromID($articleID)->fetchContent();
> > etc.
> > ... but it returns $articleID=0 although the page exits. With MW 1.18
> > this approach worked fine, but after upgrade to MW 1.20.2 it does not
> > any more.
> >
> > How do I get the page content correctly?
> > Article::newFromID($titleObj->getArticleID())->fetchContent(); does
> > not work because getArticleID() returns 0 or -1 although the page
> > exits
> > Or can sombody post a hint, what I'm doing wrong? Is there any context
> > class needed?
> > Or where there some big changes (MW 1.18 → 1.20) that are not
> > described yet on http://www.mediawiki.org/wiki/Manual:Title.php ?
> >
> > I did also a
> > sudo php ./maintenance/rebuildall.php --conf ./LocalSettings.php
> > But it did not help either
> >
> > Thanks for your help!
> >
> > Kind regards
> > Andreas
> >
> > ___
> > Wikitech-l mailing list
> > Wikitech-l@lists.wikimedia.org
> > https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
> ___
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Re: [Wikitech-l] Problem to get an article's content in MW 1.20.2

2013-01-15 Thread Harsh Kothari
Hi Andreas

Try this

$someobj = WikiPage::newFromId(  $ID );

if(is_object( $someobj ) ){
$text = $someobj->getRawText(); or you can use $text = 
$someobj->getText();

}   
else{

return true;
}

Thanks
Harsh
---
Harsh Kothari
Research Fellow, 
Physical Research Laboratory(PRL).
Ahmedabad.


On 15-Jan-2013, at 7:14 PM, Andreas Plank wrote:

> Hi,
> 
> I'm using MW 1.20.2  and I want to get the content of a page for
> further parsing in a PHP application. The PHP application is triggered
> via a special page (Special:MobileKeyV1) and parses nature guides for
> mobile devices.
> 
> I tried to get the content via getArticleID() ...
> $titleObj=Title::newFromText("Existing page");
> $articleID=$titleObj->getArticleID();
> Article::newFromID($articleID)->fetchContent();
> etc.
> ... but it returns $articleID=0 although the page exits. With MW 1.18
> this approach worked fine, but after upgrade to MW 1.20.2 it does not
> any more.
> 
> How do I get the page content correctly?
> Article::newFromID($titleObj->getArticleID())->fetchContent(); does
> not work because getArticleID() returns 0 or -1 although the page
> exits
> Or can sombody post a hint, what I'm doing wrong? Is there any context
> class needed?
> Or where there some big changes (MW 1.18 → 1.20) that are not
> described yet on http://www.mediawiki.org/wiki/Manual:Title.php ?
> 
> I did also a
> sudo php ./maintenance/rebuildall.php --conf ./LocalSettings.php
> But it did not help either
> 
> Thanks for your help!
> 
> Kind regards
> Andreas
> 
> ___
> Wikitech-l mailing list
> Wikitech-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

[Wikitech-l] Problem to get an article's content in MW 1.20.2

2013-01-15 Thread Andreas Plank
Hi,

I'm using MW 1.20.2  and I want to get the content of a page for
further parsing in a PHP application. The PHP application is triggered
via a special page (Special:MobileKeyV1) and parses nature guides for
mobile devices.

I tried to get the content via getArticleID() ...
$titleObj=Title::newFromText("Existing page");
$articleID=$titleObj->getArticleID();
Article::newFromID($articleID)->fetchContent();
etc.
... but it returns $articleID=0 although the page exits. With MW 1.18
this approach worked fine, but after upgrade to MW 1.20.2 it does not
any more.

How do I get the page content correctly?
Article::newFromID($titleObj->getArticleID())->fetchContent(); does
not work because getArticleID() returns 0 or -1 although the page
exits
Or can sombody post a hint, what I'm doing wrong? Is there any context
class needed?
Or where there some big changes (MW 1.18 → 1.20) that are not
described yet on http://www.mediawiki.org/wiki/Manual:Title.php ?

I did also a
sudo php ./maintenance/rebuildall.php --conf ./LocalSettings.php
But it did not help either

Thanks for your help!

Kind regards
Andreas

___
Wikitech-l mailing list
Wikitech-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l