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
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
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 | tylerromeo@gmail.com
On Tue, Jan 15, 2013 at 9:11 AM, Harsh Kothari harshkothari410@gmail.comwrote:
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
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 tylerromeo@gmail.com 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 | tylerromeo@gmail.com
On Tue, Jan 15, 2013 at 9:11 AM, Harsh Kothari harshkothari410@gmail.comwrote:
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
That is true. Also if it's interwiki.
*--* *Tyler Romeo* Stevens Institute of Technology, Class of 2015 Major in Computer Science www.whizkidztech.com | tylerromeo@gmail.com
On Tue, Jan 15, 2013 at 11:12 AM, bawolff bawolff+wn@gmail.com 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 tylerromeo@gmail.com 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 | tylerromeo@gmail.com
On Tue, Jan 15, 2013 at 9:11 AM, Harsh Kothari <
harshkothari410@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
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@lists.wikimedia.org