Last modified: 2008-12-05 12:02:01 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T18567, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 16567 - Allow getting parsedContent of Pages via API
Allow getting parsedContent of Pages via API
Status: RESOLVED WORKSFORME
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Roan Kattouw
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-12-05 03:48 UTC by Wolfgang Fahl
Modified: 2008-12-05 12:02 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Wolfgang Fahl 2008-12-05 03:48:16 UTC
When trying to get parsedContent of Pages via the API along the lines of:
	  $title    = Title::newFromText($titleText);
	  $article  = new Article($title);
	  $wikitext = $article->getContent();
	  $content = $wgOut->parse($wikitext);

I run into trouble when trying to prepare for being able to use the above code snippet.

The code:
$preIP="/srv/www/intern/mediawiki-1.13.0";
putenv ("MW_INSTALL_PATH=$preIP");
require_once( "$preIP/includes/WebStart.php" );
# Initialize MediaWiki base class
require_once( "$preIP/includes/Wiki.php" );
require_once( "$preIP/includes/Title.php" );
require_once( "$preIP/includes/Article.php" );

only works if no autoloader is running.
E.g. in WebRequest.php
/**
 * Some entry points may use this file without first enabling the
 * autoloader.
 */
if ( !function_exists( '__autoload' ) ) {
	require_once( dirname(__FILE__) . '/normal/UtfNormal.php' );
}

Does check whether __autoload exist - but doesn not check whether it is the autoloader of Mediawiki.
It would be great if there'd be some simple function that allows to retrieve the Mediawiki page content for use in other applications (even if this means some limits on what the page can contain e.g. obviously to follow links would be tricky if no other measures are taken).
Comment 1 Wolfgang Fahl 2008-12-05 04:28:23 UTC
After looking into the details of this I think the handling of global variables should not assume that the initialization 
is done in the global space.

I tried to autoload a Class that does than initialize Wikimedia and it doesn't work since e.g. DefaultSettings.php does not declare
the variables to be global - it is simply assumed that the current scope is global. 
It would be great if on initial declaration of global variable content the 
global $... declaration would be used to avoid this problem.

e.g.
global $wgLegalTitleChars;
$wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";

and so on ...
Comment 2 Roan Kattouw 2008-12-05 11:59:16 UTC
You're probably better off using the /actual/ API, at http://en.wikipedia.org/w/api.php . Docs are at [[mw:API]], you'll be particularly interested in [[mw:API:Expanding_templates_and_rendering]] and [[mw:API:Calling_internally]].
Comment 3 Roan Kattouw 2008-12-05 12:02:01 UTC
(In reply to comment #2)
> You're probably better off using the /actual/ API, at
> http://en.wikipedia.org/w/api.php . Docs are at [[mw:API]], you'll be
> particularly interested in [[mw:API:Expanding_templates_and_rendering]] and
> [[mw:API:Calling_internally]].
> 

Oops, those links don't really work. Try http://www.mediawiki.org/wiki/API

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links