Many thanks for the hints.
It seems (after mailing on wikitech-l) that I can accomplish what I want
in a SpecialPage instead (using $wgOut->disable() and taking control of
output) and will not need an external script, but saving the hints for
future reference.
Samuel
On 06/29/2010 05:35 AM, Tim Starling wrote:
> On 29/06/10 11:30, Samuel Lampa wrote:
>
>> Is it possible to include LocalSettings.php in an external PHP script
>> without just getting as output:
>>
>> "This file is part of MediaWiki and is not a valid entry point"
>>
>> (I would like to avoid duplication of some configurations, like database
>> settings)
>>
> Unfortunately LocalSettings.php mixes MediaWiki-specific setup code
> with configuration data. The easiest way to fix it would be to replace
> this:
>
> require_once( "$IP/includes/DefaultSettings.php" );
>
> With this:
>
> if ( !defined( 'MY_EXTERNAL_SCRIPT' ) ) {
> require_once( "$IP/includes/DefaultSettings.php" );
> }
>
> Then in your external script:
>
> define( 'MY_EXTERNAL_SCRIPT', 1 );
> require( "$wiki/LocalSettings.php" );
>
> This maintains security while skipping most of the setup code,
> including default settings. If you decide you need the default
> settings, or if that method gives you an error due to nonexistent
> classes, then you should probably use WebStart.php instead of
> LocalSettings.php. Then in your external script you would have:
>
> define( 'MW_NO_SETUP', 1 );
> require( "$wiki/includes/WebStart.php" );
>
> This initialises MediaWiki properly, including reading all
> configuration. It's more intrusive than just reading
> LocalSettings.php, it defines functions and classes which could
> potentially conflict with your external script.
>
> -- Tim Starling
>
>
> _______________________________________________
> MediaWiki-l mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
>
>
>
--
Samuel Lampa
---------------------------------------
Biotech Student @ Uppsala University
GSoC Student @ Semantic MediaWiki
---------------------------------------
E-mail: samuel.lampa[at]gmail.com
Mobile: +46 (0)70-2073732
Blog: http://saml.rilspace.org
Twitter: http://twitter.com/samuellampa
---------------------------------------
_______________________________________________
MediaWiki-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l