1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-28 14:30:51 +00:00

XOMW: Add Globals and refine XomwMediaWikiServices [#632]

This commit is contained in:
gnosygnu 2020-05-14 08:58:45 -04:00
parent a2fe75f402
commit ba1d4e0b7c
10 changed files with 3231 additions and 2343 deletions

View File

@ -0,0 +1,68 @@
change XophpCallbackOwner from Object... to Object
add XomwHookMsg / XomwHookWkr
convert Database classes: https://github.com/wikimedia/mediawiki/tree/master/includes/libs/rdbms/database
convert Loadbalances classes
## XomwHookMsg / XomwHookWkr:
strongly-typed hook b/c run can pass variables by reference and contract should be enforced
// cur
ObjectWrapperRef pageWrapper = new ObjectWrapperRef();
if (!XomwHooks.run("WikiPageFactory", XophpArray.New(title, pageWrapper))) {
return (XomwWikiPage)pageWrapper.Val();
}
else {
page = (XomwWikiPage)pageWrapper.Val();
}
// new XO way
WikiPageFactoryHookMsg msg = new WikiPageFactoryHookMsg(title);
if (!XomwHooks.run(msg) {
return msg.Page();
}
else {
page = msg.Page();
}
interface XomwHookMsg {
String Key();
XophpArray Array();
String Deprecation();
}
class WikiPageFactoryHookMsg implements XomwHookMsg {
String Key() {return WikiPageFactoryHookWkr.KEY;}
public XophpArray Array();
String Deprecation();
public WikiPageFactoryHookMsg(XomwTitle title) {
}
public XomwTitle Title();
public XomwPage Page();
}
interface XomwHookMsg extends CallbackOwner {
String Key();
}
class WikiPageFactoryHookWkr implements XomwHookWkr {
public WikiPageFactoryHookData() {}
String Key() {return "WikiPageFactory";}
public Object Call(Object arg) {
XomwPageFactoryHookMsg msg = (XomwPageFactoryHookMsg)arg;
// do stuff
msg.Page = "value";
return true;
}
}
public static boolean run(XomwHookMsg msg) {
return run(msg.Key(), msg.Array(), msg.Deprecation());
}
public static void register(XomwHookWkr wkr) {
handlers.Xet_by_ary(wkr.Name()).Add(wkr);
}
// new WM way
interface WikiPageFactoryHook {
bool onWikiPageFactory(title, page)
}

View File

@ -18,10 +18,17 @@ package gplx.xowa.mediawiki.includes;
import gplx.Hash_adp; import gplx.Hash_adp;
import gplx.Hash_adp_; import gplx.Hash_adp_;
import gplx.xowa.mediawiki.XophpArray; import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpCallback;
// MW.SRC:1.33.1 // MW.SRC:1.33.1
// XO.NOTE:MW has these as individual global variables // XO.NOTE:MW has these as individual global variables
public class XomwDefaultSettings { public class XomwDefaultSettings {
// XO:infrastructure for globals
public static XomwDefaultSettings Instance = new XomwDefaultSettings();
public XomwDefaultSettings() {
// NOTE: all "wg..." variables must be registered here!
XomwGlobals.Instance.Add("wgServiceWiringFiles", wgServiceWiringFiles);
}
// /** // /**
// * Default values for MediaWiki configuration settings. // * Default values for MediaWiki configuration settings.
// * // *
@ -7516,21 +7523,21 @@ public class XomwDefaultSettings {
*/ */
public static XophpArray wgHooks = XophpArray.New(); public static XophpArray wgHooks = XophpArray.New();
// //
///** /**
// * List of service wiring files to be loaded by the default instance of MediaWikiServices. * List of service wiring files to be loaded by the default instance of MediaWikiServices.
// * Each file listed here is expected to return an associative array mapping service names * Each file listed here is expected to return an associative array mapping service names
// * to instantiator functions. Extensions may add wiring files to define their own services. * to instantiator functions. Extensions may add wiring files to define their own services.
// * However, this cannot be used to replace existing services - use the MediaWikiServices * However, this cannot be used to replace existing services - use the MediaWikiServices
// * hook for that. * hook for that.
// * *
// * @see MediaWikiServices * @see MediaWikiServices
// * @see ServiceContainer::loadWiringFiles() for details on loading service instantiator functions. * @see ServiceContainer::loadWiringFiles() for details on loading service instantiator functions.
// * @see docs/injection.txt for an overview of dependency injection in MediaWiki. * @see docs/injection.txt for an overview of dependency injection in MediaWiki.
// */ */
// $wgServiceWiringFiles = [ public XophpArray<XophpArray<XophpCallback>> wgServiceWiringFiles = XophpArray.New(
// __DIR__ . '/ServiceWiring.php' new XomwServiceWiring().GetCallbacks()
// ]; );
//
///** ///**
// * Maps jobs to their handlers; extensions // * Maps jobs to their handlers; extensions
// * can add to this to provide custom jobs. // * can add to this to provide custom jobs.

View File

@ -0,0 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes;
import gplx.xowa.mediawiki.XophpArray;
// Any MW-specific globals which aren't specific to a class go here
// For now, just use it for PHP $GLOBALS
public class XomwGlobals {
public static final XomwGlobals Instance = new XomwGlobals();
public XophpArray<Object> GLOBALS = new XophpArray<>();
public void Add(String key, Object val) {
GLOBALS.Add(key, val);
}
}

View File

@ -16,7 +16,13 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
package gplx.xowa.mediawiki.includes; package gplx.xowa.mediawiki.includes;
import gplx.xowa.mediawiki.XomwEnv; import gplx.xowa.mediawiki.XomwEnv;
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpCallback;
import gplx.xowa.mediawiki.XophpString_;
import gplx.xowa.mediawiki.includes.config.XomwConfig;
import gplx.xowa.mediawiki.includes.config.XomwGlobalVarConfig;
import gplx.xowa.mediawiki.includes.interwiki.XomwInterwikiLookup; import gplx.xowa.mediawiki.includes.interwiki.XomwInterwikiLookup;
import gplx.xowa.mediawiki.includes.libs.services.XomwServiceContainer;
import gplx.xowa.mediawiki.includes.title.XomwMediaWikiTitleCodec; import gplx.xowa.mediawiki.includes.title.XomwMediaWikiTitleCodec;
import gplx.xowa.mediawiki.languages.XomwLanguage; import gplx.xowa.mediawiki.languages.XomwLanguage;
@ -25,8 +31,8 @@ import gplx.xowa.mediawiki.languages.XomwLanguage;
* MediaWikiServices is the service locator for the application scope of MediaWiki. * MediaWikiServices is the service locator for the application scope of MediaWiki.
* Its implemented as a simple configurable DI container. * Its implemented as a simple configurable DI container.
* MediaWikiServices acts as a top level factory/registry for top level services, and builds * MediaWikiServices acts as a top level factory/registry for top level services, and builds
* the network of service objects that defines MediaWiki's application logic. * the network of service objects that defines MediaWiki"s application logic.
* It acts as an entry point to MediaWiki's dependency injection mechanism. * It acts as an entry point to MediaWiki"s dependency injection mechanism.
* *
* Services are defined in the "wiring" array passed to the constructor, * Services are defined in the "wiring" array passed to the constructor,
* or by calling defineService(). * or by calling defineService().
@ -34,10 +40,10 @@ import gplx.xowa.mediawiki.languages.XomwLanguage;
* @see docs/injection.txt for an overview of using dependency injection in the * @see docs/injection.txt for an overview of using dependency injection in the
* MediaWiki code base. * MediaWiki code base.
*/ */
public class XomwMediaWikiServices { // extends ServiceContainer public class XomwMediaWikiServices extends XomwServiceContainer {
// XO.MW.SKIP:remove global getInstance(). See XomwEnv // XO.MW.SKIP:remove global getInstance(). See XomwEnv
private final XomwMediaWikiTitleCodec titleParser; private XomwMediaWikiTitleCodec titleParser;
private final XomwInterwikiLookup interwikiLookup; private XomwInterwikiLookup interwikiLookup;
public XomwEnv env; public XomwEnv env;
public XomwMediaWikiServices(XomwEnv env, XomwInterwikiLookup interwikiLookup, XomwLanguage language, byte[][] localInterwikis) { public XomwMediaWikiServices(XomwEnv env, XomwInterwikiLookup interwikiLookup, XomwLanguage language, byte[][] localInterwikis) {
@ -46,37 +52,37 @@ public class XomwMediaWikiServices { // extends ServiceContainer
this.titleParser = new XomwMediaWikiTitleCodec(this, language, localInterwikis); this.titleParser = new XomwMediaWikiTitleCodec(this, language, localInterwikis);
} }
// /** /**
// * @var MediaWikiServices|null * @var MediaWikiServices|null
// */ */
// private static $instance = null; private static XomwMediaWikiServices instance = null;
//
// /** /**
// * Returns the global default instance of the top level service locator. * Returns the global default instance of the top level service locator.
// * *
// * @since 1.27 * @since 1.27
// * *
// * The default instance is initialized using the service instantiator functions * The default instance is initialized using the service instantiator functions
// * defined in ServiceWiring.php. * defined in ServiceWiring.php.
// * *
// * @note This should only be called by static functions! The instance returned here * @note This should only be called by static functions! The instance returned here
// * should not be passed around! Objects that need access to a service should have * should not be passed around! Objects that need access to a service should have
// * that service injected into the constructor, never a service locator! * that service injected into the constructor, never a service locator!
// * *
// * @return MediaWikiServices * @return MediaWikiServices
// */ */
// public static function getInstance() { public static XomwMediaWikiServices getInstance() {
// if ( self::$instance === null ) { if (instance == null) {
// // NOTE: constructing GlobalVarConfig here is not particularly pretty, // NOTE: constructing GlobalVarConfig here is not particularly pretty,
// // but some information from the global scope has to be injected here, // but some information from the global scope has to be injected here,
// // even if it's just a file name or database credentials to load // even if it"s just a file name or database credentials to load
// // configuration from. // configuration from.
// $bootstrapConfig = new GlobalVarConfig(); XomwGlobalVarConfig bootstrapConfig = new XomwGlobalVarConfig();
// self::$instance = self::newInstance( $bootstrapConfig, 'load' ); instance = newInstance(bootstrapConfig, "load");
// } }
//
// return self::$instance; return instance;
// } }
// //
// /** // /**
// * Replaces the global MediaWikiServices instance. // * Replaces the global MediaWikiServices instance.
@ -87,19 +93,19 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * // *
// * @throws MWException if called outside of PHPUnit tests. // * @throws MWException if called outside of PHPUnit tests.
// * // *
// * @param MediaWikiServices $services The new MediaWikiServices object. // * @param MediaWikiServices services The new MediaWikiServices object.
// * // *
// * @return MediaWikiServices The old MediaWikiServices object, so it can be restored later. // * @return MediaWikiServices The old MediaWikiServices object, so it can be restored later.
// */ // */
// public static function forceGlobalInstance( MediaWikiServices $services ) { // public static function forceGlobalInstance(MediaWikiServices services) {
// if ( !defined( 'MW_PHPUNIT_TEST' ) ) { // if (!defined("MW_PHPUNIT_TEST")) {
// throw new MWException( __METHOD__ . ' must not be used outside unit tests.' ); // throw new MWException(__METHOD__ . " must not be used outside unit tests.");
// } // }
// //
// $old = self::getInstance(); // old = getInstance();
// self::$instance = $services; // instance = services;
// //
// return $old; // return old;
// } // }
// //
// /** // /**
@ -127,102 +133,103 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @see resetGlobalInstance() // * @see resetGlobalInstance()
// * @see resetBetweenTest() // * @see resetBetweenTest()
// * // *
// * @param Config|null $bootstrapConfig The Config object to be registered as the // * @param Config|null bootstrapConfig The Config object to be registered as the
// * 'BootstrapConfig' service. This has to contain at least the information // * "BootstrapConfig" service. This has to contain at least the information
// * needed to set up the 'ConfigFactory' service. If not given, the bootstrap // * needed to set up the "ConfigFactory" service. If not given, the bootstrap
// * config of the old instance of MediaWikiServices will be re-used. If there // * config of the old instance of MediaWikiServices will be re-used. If there
// * was no previous instance, a new GlobalVarConfig object will be used to // * was no previous instance, a new GlobalVarConfig object will be used to
// * bootstrap the services. // * bootstrap the services.
// * // *
// * @param string $quick Set this to "quick" to allow expensive resources to be re-used. // * @param string quick Set this to "quick" to allow expensive resources to be re-used.
// * See SalvageableService for details. // * See SalvageableService for details.
// * // *
// * @throws MWException If called after MW_SERVICE_BOOTSTRAP_COMPLETE has been defined in // * @throws MWException If called after MW_SERVICE_BOOTSTRAP_COMPLETE has been defined in
// * Setup.php (unless MW_PHPUNIT_TEST or MEDIAWIKI_INSTALL or RUN_MAINTENANCE_IF_MAIN // * Setup.php (unless MW_PHPUNIT_TEST or MEDIAWIKI_INSTALL or RUN_MAINTENANCE_IF_MAIN
// * is defined). // * is defined).
// */ // */
// public static function resetGlobalInstance( Config $bootstrapConfig = null, $quick = '' ) { // public static function resetGlobalInstance(Config bootstrapConfig = null, quick = "") {
// if ( self::$instance === null ) { // if (instance === null) {
// // no global instance yet, nothing to reset // // no global instance yet, nothing to reset
// return; // return;
// } // }
// //
// self::failIfResetNotAllowed( __METHOD__ ); // failIfResetNotAllowed(__METHOD__);
// //
// if ( $bootstrapConfig === null ) { // if (bootstrapConfig === null) {
// $bootstrapConfig = self::$instance->getBootstrapConfig(); // bootstrapConfig = instance.getBootstrapConfig();
// } // }
// //
// $oldInstance = self::$instance; // oldInstance = instance;
// //
// self::$instance = self::newInstance( $bootstrapConfig, 'load' ); // instance = newInstance(bootstrapConfig, "load");
// self::$instance->importWiring( $oldInstance, [ 'BootstrapConfig' ] ); // instance.importWiring(oldInstance, [ "BootstrapConfig" ]);
// //
// if ( $quick === 'quick' ) { // if (quick === "quick") {
// self::$instance->salvage( $oldInstance ); // instance.salvage(oldInstance);
// } else { // } else {
// $oldInstance->destroy(); // oldInstance.destroy();
// } // }
// } // }
// //
// /** // /**
// * Salvages the state of any salvageable service instances in $other. // * Salvages the state of any salvageable service instances in other.
// * // *
// * @note $other will have been destroyed when salvage() returns. // * @note other will have been destroyed when salvage() returns.
// * // *
// * @param MediaWikiServices $other // * @param MediaWikiServices other
// */ // */
// private function salvage( self $other ) { // private function salvage(self other) {
// foreach ( this.getServiceNames() as $name ) { // foreach (this.getServiceNames() as name) {
// // The service could be new in the new instance and not registered in the // // The service could be new in the new instance and not registered in the
// // other instance (e.g. an extension that was loaded after the instantiation of // // other instance (e.g. an extension that was loaded after the instantiation of
// // the other instance. Skip this service in this case. See T143974 // // the other instance. Skip this service in this case. See T143974
// try { // try {
// $oldService = $other->peekService( $name ); // oldService = other.peekService(name);
// } catch ( NoSuchServiceException $e ) { // } catch (NoSuchServiceException e) {
// continue; // continue;
// } // }
// //
// if ( $oldService instanceof SalvageableService ) { // if (oldService instanceof SalvageableService) {
// /** @var SalvageableService $newService */ // /** @var SalvageableService newService */
// $newService = this.getService( $name ); // newService = this.getService(name);
// $newService->salvage( $oldService ); // newService.salvage(oldService);
// } // }
// } // }
// //
// $other->destroy(); // other.destroy();
// } // }
//
// /** /**
// * Creates a new MediaWikiServices instance and initializes it according to the * Creates a new MediaWikiServices instance and initializes it according to the
// * given $bootstrapConfig. In particular, all wiring files defined in the * given bootstrapConfig. In particular, all wiring files defined in the
// * ServiceWiringFiles setting are loaded, and the MediaWikiServices hook is called. * ServiceWiringFiles setting are loaded, and the MediaWikiServices hook is called.
// * *
// * @param Config|null $bootstrapConfig The Config object to be registered as the * @param Config|null bootstrapConfig The Config object to be registered as the
// * 'BootstrapConfig' service. * "BootstrapConfig" service.
// * *
// * @param string $loadWiring set this to 'load' to load the wiring files specified * @param string loadWiring set this to "load" to load the wiring files specified
// * in the 'ServiceWiringFiles' setting in $bootstrapConfig. * in the "ServiceWiringFiles" setting in bootstrapConfig.
// * *
// * @return MediaWikiServices * @return MediaWikiServices
// * @throws MWException * @throws MWException
// * @throws \FatalError * @throws \FatalError
// */ */
// private static function newInstance( Config $bootstrapConfig, $loadWiring = '' ) { private static XomwMediaWikiServices newInstance(XomwConfig bootstrapConfig) {return newInstance(bootstrapConfig, "");}
// $instance = new self( $bootstrapConfig ); private static XomwMediaWikiServices newInstance(XomwConfig bootstrapConfig, String loadWiring) {
// instance = new XomwMediaWikiServices(bootstrapConfig);
// // Load the default wiring from the specified files.
// if ( $loadWiring === 'load' ) { // Load the default wiring from the specified files.
// $wiringFiles = $bootstrapConfig->get( 'ServiceWiringFiles' ); if (XophpString_.eq(loadWiring, "load")) {
// $instance->loadWiringFiles( $wiringFiles ); XophpArray<XophpArray<XophpCallback>> wiringFiles = (XophpArray<XophpArray<XophpCallback>>)bootstrapConfig.get("ServiceWiringFiles");
// } instance.loadWiringFiles(wiringFiles);
// }
// // Provide a traditional hook point to allow extensions to configure services.
// Hooks::run( 'MediaWikiServices', [ $instance ] ); // Provide a traditional hook point to allow extensions to configure services.
// XomwHooks.run("MediaWikiServices", XophpArray.New(instance));
// return $instance;
// } return instance;
// }
// /** // /**
// * Disables all storage layer services. After calling this, any attempt to access the // * Disables all storage layer services. After calling this, any attempt to access the
// * storage layer will result in an error. Use resetGlobalInstance() to restore normal // * storage layer will result in an error. Use resetGlobalInstance() to restore normal
@ -240,11 +247,11 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// */ // */
// public static function disableStorageBackend() { // public static function disableStorageBackend() {
// // TODO: also disable some Caches, JobQueues, etc // // TODO: also disable some Caches, JobQueues, etc
// $destroy = [ 'DBLoadBalancer', 'DBLoadBalancerFactory' ]; // destroy = [ "DBLoadBalancer", "DBLoadBalancerFactory" ];
// $services = self::getInstance(); // services = getInstance();
// //
// foreach ( $destroy as $name ) { // foreach (destroy as name) {
// $services->disableService( $name ); // services.disableService(name);
// } // }
// //
// ObjectCache::clear(); // ObjectCache::clear();
@ -252,7 +259,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// //
// /** // /**
// * Resets any services that may have become stale after a child process // * Resets any services that may have become stale after a child process
// * returns from after pcntl_fork(). It's also safe, but generally unnecessary, // * returns from after pcntl_fork(). It"s also safe, but generally unnecessary,
// * to call this method from the parent process. // * to call this method from the parent process.
// * // *
// * @since 1.28 // * @since 1.28
@ -263,13 +270,13 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @see disableStorageBackend() // * @see disableStorageBackend()
// */ // */
// public static function resetChildProcessServices() { // public static function resetChildProcessServices() {
// // NOTE: for now, just reset everything. Since we don't know the interdependencies // // NOTE: for now, just reset everything. Since we don"t know the interdependencies
// // between services, we can't do this more selectively at this time. // // between services, we can"t do this more selectively at this time.
// self::resetGlobalInstance(); // resetGlobalInstance();
// //
// // Child, reseed because there is no bug in PHP: // // Child, reseed because there is no bug in PHP:
// // https://bugs.php.net/bug.php?id=42465 // // https://bugs.php.net/bug.php?id=42465
// mt_srand( getmypid() ); // mt_srand(getmypid());
// } // }
// //
// /** // /**
@ -286,19 +293,19 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * should not be needed. It is provided to allow tests that pollute global service // * should not be needed. It is provided to allow tests that pollute global service
// * instances to clean up. // * instances to clean up.
// * // *
// * @param string $name // * @param string name
// * @param bool $destroy Whether the service instance should be destroyed if it exists. // * @param bool destroy Whether the service instance should be destroyed if it exists.
// * When set to false, any existing service instance will effectively be detached // * When set to false, any existing service instance will effectively be detached
// * from the container. // * from the container.
// * // *
// * @throws MWException if called outside of PHPUnit tests. // * @throws MWException if called outside of PHPUnit tests.
// */ // */
// public function resetServiceForTesting( $name, $destroy = true ) { // public function resetServiceForTesting(name, destroy = true) {
// if ( !defined( 'MW_PHPUNIT_TEST' ) && !defined( 'MW_PARSER_TEST' ) ) { // if (!defined("MW_PHPUNIT_TEST") && !defined("MW_PARSER_TEST")) {
// throw new MWException( 'resetServiceForTesting() must not be used outside unit tests.' ); // throw new MWException("resetServiceForTesting() must not be used outside unit tests.");
// } // }
// //
// this.resetService( $name, $destroy ); // this.resetService(name, destroy);
// } // }
// //
// /** // /**
@ -310,7 +317,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * // *
// * This method will throw an exception if: // * This method will throw an exception if:
// * // *
// * - self::$resetInProgress is false (to allow all services to be reset together // * - resetInProgress is false (to allow all services to be reset together
// * via resetGlobalInstance) // * via resetGlobalInstance)
// * - and MEDIAWIKI_INSTALL is not defined (to allow services to be reset during installation) // * - and MEDIAWIKI_INSTALL is not defined (to allow services to be reset during installation)
// * - and MW_PHPUNIT_TEST is not defined (to allow services to be reset during testing) // * - and MW_PHPUNIT_TEST is not defined (to allow services to be reset during testing)
@ -320,7 +327,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * defined here in the MediaWikiServices services class to have a central place // * defined here in the MediaWikiServices services class to have a central place
// * for managing service bootstrapping and resetting. // * for managing service bootstrapping and resetting.
// * // *
// * @param string $method the name of the caller method, as given by __METHOD__. // * @param string method the name of the caller method, as given by __METHOD__.
// * // *
// * @throws MWException if called outside bootstrap mode. // * @throws MWException if called outside bootstrap mode.
// * // *
@ -328,30 +335,30 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @see forceGlobalInstance() // * @see forceGlobalInstance()
// * @see disableStorageBackend() // * @see disableStorageBackend()
// */ // */
// public static function failIfResetNotAllowed( $method ) { // public static function failIfResetNotAllowed(method) {
// if ( !defined( 'MW_PHPUNIT_TEST' ) // if (!defined("MW_PHPUNIT_TEST")
// && !defined( 'MW_PARSER_TEST' ) // && !defined("MW_PARSER_TEST")
// && !defined( 'MEDIAWIKI_INSTALL' ) // && !defined("MEDIAWIKI_INSTALL")
// && !defined( 'RUN_MAINTENANCE_IF_MAIN' ) // && !defined("RUN_MAINTENANCE_IF_MAIN")
// && defined( 'MW_SERVICE_BOOTSTRAP_COMPLETE' ) // && defined("MW_SERVICE_BOOTSTRAP_COMPLETE")
// ) { // ) {
// throw new MWException( $method . ' may only be called during bootstrapping and unit tests!' ); // throw new MWException(method . " may only be called during bootstrapping and unit tests!");
// } // }
// } // }
// //
// /** /**
// * @param Config $config The Config object to be registered as the 'BootstrapConfig' service. * @param Config config The Config object to be registered as the "BootstrapConfig" service.
// * This has to contain at least the information needed to set up the 'ConfigFactory' * This has to contain at least the information needed to set up the "ConfigFactory"
// * service. * service.
// */ */
// public function __construct( Config $config ) { public XomwMediaWikiServices(XomwConfig config) {
// parent::__construct(); super();
//
// // Register the given Config object as the bootstrap config service. // // Register the given Config object as the bootstrap config service.
// this.defineService( 'BootstrapConfig', function () use ( $config ) { // this.defineService("BootstrapConfig", function () use (config) {
// return $config; // return config;
// } ); // });
// } }
// //
// // CONVENIENCE GETTERS //////////////////////////////////////////////////// // // CONVENIENCE GETTERS ////////////////////////////////////////////////////
// //
@ -360,7 +367,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return ActorMigration // * @return ActorMigration
// */ // */
// public function getActorMigration() { // public function getActorMigration() {
// return this.getService( 'ActorMigration' ); // return this.getService("ActorMigration");
// } // }
// //
// /** // /**
@ -368,7 +375,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return BlobStore // * @return BlobStore
// */ // */
// public function getBlobStore() { // public function getBlobStore() {
// return this.getService( '_SqlBlobStore' ); // return this.getService("_SqlBlobStore");
// } // }
// //
// /** // /**
@ -376,7 +383,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return BlobStoreFactory // * @return BlobStoreFactory
// */ // */
// public function getBlobStoreFactory() { // public function getBlobStoreFactory() {
// return this.getService( 'BlobStoreFactory' ); // return this.getService("BlobStoreFactory");
// } // }
// //
// /** // /**
@ -384,7 +391,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return BlockRestrictionStore // * @return BlockRestrictionStore
// */ // */
// public function getBlockRestrictionStore() : BlockRestrictionStore { // public function getBlockRestrictionStore() : BlockRestrictionStore {
// return this.getService( 'BlockRestrictionStore' ); // return this.getService("BlockRestrictionStore");
// } // }
// //
// /** // /**
@ -401,7 +408,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return Config // * @return Config
// */ // */
// public function getBootstrapConfig() { // public function getBootstrapConfig() {
// return this.getService( 'BootstrapConfig' ); // return this.getService("BootstrapConfig");
// } // }
// //
// /** // /**
@ -409,7 +416,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return NameTableStore // * @return NameTableStore
// */ // */
// public function getChangeTagDefStore() { // public function getChangeTagDefStore() {
// return this.getService( 'NameTableStoreFactory' )->getChangeTagDef(); // return this.getService("NameTableStoreFactory").getChangeTagDef();
// } // }
// //
// /** // /**
@ -417,7 +424,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return CommentStore // * @return CommentStore
// */ // */
// public function getCommentStore() { // public function getCommentStore() {
// return this.getService( 'CommentStore' ); // return this.getService("CommentStore");
// } // }
// //
// /** // /**
@ -425,7 +432,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return ConfigFactory // * @return ConfigFactory
// */ // */
// public function getConfigFactory() { // public function getConfigFactory() {
// return this.getService( 'ConfigFactory' ); // return this.getService("ConfigFactory");
// } // }
// //
// /** // /**
@ -433,7 +440,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return ConfigRepository // * @return ConfigRepository
// */ // */
// public function getConfigRepository() { // public function getConfigRepository() {
// return this.getService( 'ConfigRepository' ); // return this.getService("ConfigRepository");
// } // }
// //
// /** // /**
@ -441,7 +448,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return \ConfiguredReadOnlyMode // * @return \ConfiguredReadOnlyMode
// */ // */
// public function getConfiguredReadOnlyMode() { // public function getConfiguredReadOnlyMode() {
// return this.getService( 'ConfiguredReadOnlyMode' ); // return this.getService("ConfiguredReadOnlyMode");
// } // }
// //
// /** // /**
@ -449,7 +456,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return \Language // * @return \Language
// */ // */
// public function getContentLanguage() { // public function getContentLanguage() {
// return this.getService( 'ContentLanguage' ); // return this.getService("ContentLanguage");
// } // }
// //
// /** // /**
@ -457,7 +464,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return NameTableStore // * @return NameTableStore
// */ // */
// public function getContentModelStore() { // public function getContentModelStore() {
// return this.getService( 'NameTableStoreFactory' )->getContentModels(); // return this.getService("NameTableStoreFactory").getContentModels();
// } // }
// //
// /** // /**
@ -465,7 +472,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return CryptHKDF // * @return CryptHKDF
// */ // */
// public function getCryptHKDF() { // public function getCryptHKDF() {
// return this.getService( 'CryptHKDF' ); // return this.getService("CryptHKDF");
// } // }
// //
// /** // /**
@ -474,8 +481,8 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return CryptRand // * @return CryptRand
// */ // */
// public function getCryptRand() { // public function getCryptRand() {
// wfDeprecated( __METHOD__, '1.32' ); // wfDeprecated(__METHOD__, "1.32");
// return this.getService( 'CryptRand' ); // return this.getService("CryptRand");
// } // }
// //
// /** // /**
@ -483,7 +490,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return LoadBalancer The main DB load balancer for the local wiki. // * @return LoadBalancer The main DB load balancer for the local wiki.
// */ // */
// public function getDBLoadBalancer() { // public function getDBLoadBalancer() {
// return this.getService( 'DBLoadBalancer' ); // return this.getService("DBLoadBalancer");
// } // }
// //
// /** // /**
@ -491,7 +498,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return LBFactory // * @return LBFactory
// */ // */
// public function getDBLoadBalancerFactory() { // public function getDBLoadBalancerFactory() {
// return this.getService( 'DBLoadBalancerFactory' ); // return this.getService("DBLoadBalancerFactory");
// } // }
// //
// /** // /**
@ -499,7 +506,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return EventRelayerGroup // * @return EventRelayerGroup
// */ // */
// public function getEventRelayerGroup() { // public function getEventRelayerGroup() {
// return this.getService( 'EventRelayerGroup' ); // return this.getService("EventRelayerGroup");
// } // }
// //
// /** // /**
@ -507,7 +514,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return \ExternalStoreFactory // * @return \ExternalStoreFactory
// */ // */
// public function getExternalStoreFactory() { // public function getExternalStoreFactory() {
// return this.getService( 'ExternalStoreFactory' ); // return this.getService("ExternalStoreFactory");
// } // }
// //
// /** // /**
@ -515,7 +522,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return GenderCache // * @return GenderCache
// */ // */
// public function getGenderCache() { // public function getGenderCache() {
// return this.getService( 'GenderCache' ); // return this.getService("GenderCache");
// } // }
// //
// /** // /**
@ -523,7 +530,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return HttpRequestFactory // * @return HttpRequestFactory
// */ // */
// public function getHttpRequestFactory() { // public function getHttpRequestFactory() {
// return this.getService( 'HttpRequestFactory' ); // return this.getService("HttpRequestFactory");
// } // }
/** /**
@ -531,7 +538,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
* @return InterwikiLookup * @return InterwikiLookup
*/ */
public XomwInterwikiLookup getInterwikiLookup() { public XomwInterwikiLookup getInterwikiLookup() {
// return this.getService( 'InterwikiLookup' ); // return this.getService("InterwikiLookup");
return interwikiLookup; return interwikiLookup;
} }
@ -540,7 +547,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return LinkCache // * @return LinkCache
// */ // */
// public function getLinkCache() { // public function getLinkCache() {
// return this.getService( 'LinkCache' ); // return this.getService("LinkCache");
// } // }
// //
// /** // /**
@ -551,7 +558,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return LinkRenderer // * @return LinkRenderer
// */ // */
// public function getLinkRenderer() { // public function getLinkRenderer() {
// return this.getService( 'LinkRenderer' ); // return this.getService("LinkRenderer");
// } // }
// //
// /** // /**
@ -559,7 +566,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return LinkRendererFactory // * @return LinkRendererFactory
// */ // */
// public function getLinkRendererFactory() { // public function getLinkRendererFactory() {
// return this.getService( 'LinkRendererFactory' ); // return this.getService("LinkRendererFactory");
// } // }
// //
// /** // /**
@ -567,7 +574,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return \BagOStuff // * @return \BagOStuff
// */ // */
// public function getLocalServerObjectCache() { // public function getLocalServerObjectCache() {
// return this.getService( 'LocalServerObjectCache' ); // return this.getService("LocalServerObjectCache");
// } // }
// //
// /** // /**
@ -575,7 +582,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return MagicWordFactory // * @return MagicWordFactory
// */ // */
// public function getMagicWordFactory() { // public function getMagicWordFactory() {
// return this.getService( 'MagicWordFactory' ); // return this.getService("MagicWordFactory");
// } // }
// //
// /** // /**
@ -586,7 +593,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return Config // * @return Config
// */ // */
// public function getMainConfig() { // public function getMainConfig() {
// return this.getService( 'MainConfig' ); // return this.getService("MainConfig");
// } // }
// //
// /** // /**
@ -594,7 +601,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return \BagOStuff // * @return \BagOStuff
// */ // */
// public function getMainObjectStash() { // public function getMainObjectStash() {
// return this.getService( 'MainObjectStash' ); // return this.getService("MainObjectStash");
// } // }
// //
// /** // /**
@ -602,7 +609,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return \WANObjectCache // * @return \WANObjectCache
// */ // */
// public function getMainWANObjectCache() { // public function getMainWANObjectCache() {
// return this.getService( 'MainWANObjectCache' ); // return this.getService("MainWANObjectCache");
// } // }
// //
// /** // /**
@ -610,7 +617,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return MediaHandlerFactory // * @return MediaHandlerFactory
// */ // */
// public function getMediaHandlerFactory() { // public function getMediaHandlerFactory() {
// return this.getService( 'MediaHandlerFactory' ); // return this.getService("MediaHandlerFactory");
// } // }
// //
// /** // /**
@ -618,7 +625,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return MimeAnalyzer // * @return MimeAnalyzer
// */ // */
// public function getMimeAnalyzer() { // public function getMimeAnalyzer() {
// return this.getService( 'MimeAnalyzer' ); // return this.getService("MimeAnalyzer");
// } // }
// //
// /** // /**
@ -626,14 +633,14 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return NameTableStoreFactory // * @return NameTableStoreFactory
// */ // */
// public function getNameTableStoreFactory() { // public function getNameTableStoreFactory() {
// return this.getService( 'NameTableStoreFactory' ); // return this.getService("NameTableStoreFactory");
// } // }
// //
// /** // /**
// * @return OldRevisionImporter // * @return OldRevisionImporter
// */ // */
// public function getOldRevisionImporter() { // public function getOldRevisionImporter() {
// return this.getService( 'OldRevisionImporter' ); // return this.getService("OldRevisionImporter");
// } // }
// //
// /** // /**
@ -641,7 +648,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return Parser // * @return Parser
// */ // */
// public function getParser() { // public function getParser() {
// return this.getService( 'Parser' ); // return this.getService("Parser");
// } // }
// //
// /** // /**
@ -649,7 +656,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return ParserCache // * @return ParserCache
// */ // */
// public function getParserCache() { // public function getParserCache() {
// return this.getService( 'ParserCache' ); // return this.getService("ParserCache");
// } // }
// //
// /** // /**
@ -657,7 +664,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return ParserFactory // * @return ParserFactory
// */ // */
// public function getParserFactory() { // public function getParserFactory() {
// return this.getService( 'ParserFactory' ); // return this.getService("ParserFactory");
// } // }
// //
// /** // /**
@ -665,7 +672,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return PasswordFactory // * @return PasswordFactory
// */ // */
// public function getPasswordFactory() { // public function getPasswordFactory() {
// return this.getService( 'PasswordFactory' ); // return this.getService("PasswordFactory");
// } // }
// //
// /** // /**
@ -673,7 +680,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return StatsdDataFactoryInterface // * @return StatsdDataFactoryInterface
// */ // */
// public function getPerDbNameStatsdDataFactory() { // public function getPerDbNameStatsdDataFactory() {
// return this.getService( 'PerDbNameStatsdDataFactory' ); // return this.getService("PerDbNameStatsdDataFactory");
// } // }
// //
// /** // /**
@ -681,7 +688,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return PermissionManager // * @return PermissionManager
// */ // */
// public function getPermissionManager() { // public function getPermissionManager() {
// return this.getService( 'PermissionManager' ); // return this.getService("PermissionManager");
// } // }
// //
// /** // /**
@ -689,7 +696,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return PreferencesFactory // * @return PreferencesFactory
// */ // */
// public function getPreferencesFactory() { // public function getPreferencesFactory() {
// return this.getService( 'PreferencesFactory' ); // return this.getService("PreferencesFactory");
// } // }
// //
// /** // /**
@ -697,7 +704,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return ProxyLookup // * @return ProxyLookup
// */ // */
// public function getProxyLookup() { // public function getProxyLookup() {
// return this.getService( 'ProxyLookup' ); // return this.getService("ProxyLookup");
// } // }
// //
// /** // /**
@ -705,7 +712,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return \ReadOnlyMode // * @return \ReadOnlyMode
// */ // */
// public function getReadOnlyMode() { // public function getReadOnlyMode() {
// return this.getService( 'ReadOnlyMode' ); // return this.getService("ReadOnlyMode");
// } // }
// //
// /** // /**
@ -713,7 +720,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return ResourceLoader // * @return ResourceLoader
// */ // */
// public function getResourceLoader() { // public function getResourceLoader() {
// return this.getService( 'ResourceLoader' ); // return this.getService("ResourceLoader");
// } // }
// //
// /** // /**
@ -721,7 +728,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return RevisionFactory // * @return RevisionFactory
// */ // */
// public function getRevisionFactory() { // public function getRevisionFactory() {
// return this.getService( 'RevisionFactory' ); // return this.getService("RevisionFactory");
// } // }
// //
// /** // /**
@ -729,7 +736,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return RevisionLookup // * @return RevisionLookup
// */ // */
// public function getRevisionLookup() { // public function getRevisionLookup() {
// return this.getService( 'RevisionLookup' ); // return this.getService("RevisionLookup");
// } // }
// //
// /** // /**
@ -737,7 +744,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return RevisionRenderer // * @return RevisionRenderer
// */ // */
// public function getRevisionRenderer() { // public function getRevisionRenderer() {
// return this.getService( 'RevisionRenderer' ); // return this.getService("RevisionRenderer");
// } // }
// //
// /** // /**
@ -745,7 +752,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return RevisionStore // * @return RevisionStore
// */ // */
// public function getRevisionStore() { // public function getRevisionStore() {
// return this.getService( 'RevisionStore' ); // return this.getService("RevisionStore");
// } // }
// //
// /** // /**
@ -753,7 +760,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return RevisionStoreFactory // * @return RevisionStoreFactory
// */ // */
// public function getRevisionStoreFactory() { // public function getRevisionStoreFactory() {
// return this.getService( 'RevisionStoreFactory' ); // return this.getService("RevisionStoreFactory");
// } // }
// //
// /** // /**
@ -762,7 +769,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// */ // */
// public function newSearchEngine() { // public function newSearchEngine() {
// // New engine object every time, since they keep state // // New engine object every time, since they keep state
// return this.getService( 'SearchEngineFactory' )->create(); // return this.getService("SearchEngineFactory").create();
// } // }
// //
// /** // /**
@ -770,7 +777,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return SearchEngineConfig // * @return SearchEngineConfig
// */ // */
// public function getSearchEngineConfig() { // public function getSearchEngineConfig() {
// return this.getService( 'SearchEngineConfig' ); // return this.getService("SearchEngineConfig");
// } // }
// //
// /** // /**
@ -778,7 +785,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return SearchEngineFactory // * @return SearchEngineFactory
// */ // */
// public function getSearchEngineFactory() { // public function getSearchEngineFactory() {
// return this.getService( 'SearchEngineFactory' ); // return this.getService("SearchEngineFactory");
// } // }
// //
// /** // /**
@ -786,7 +793,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return CommandFactory // * @return CommandFactory
// */ // */
// public function getShellCommandFactory() { // public function getShellCommandFactory() {
// return this.getService( 'ShellCommandFactory' ); // return this.getService("ShellCommandFactory");
// } // }
// //
// /** // /**
@ -794,7 +801,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return SiteLookup // * @return SiteLookup
// */ // */
// public function getSiteLookup() { // public function getSiteLookup() {
// return this.getService( 'SiteLookup' ); // return this.getService("SiteLookup");
// } // }
// //
// /** // /**
@ -802,7 +809,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return SiteStore // * @return SiteStore
// */ // */
// public function getSiteStore() { // public function getSiteStore() {
// return this.getService( 'SiteStore' ); // return this.getService("SiteStore");
// } // }
// //
// /** // /**
@ -810,7 +817,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return SkinFactory // * @return SkinFactory
// */ // */
// public function getSkinFactory() { // public function getSkinFactory() {
// return this.getService( 'SkinFactory' ); // return this.getService("SkinFactory");
// } // }
// //
// /** // /**
@ -818,7 +825,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return SlotRoleRegistry // * @return SlotRoleRegistry
// */ // */
// public function getSlotRoleRegistry() { // public function getSlotRoleRegistry() {
// return this.getService( 'SlotRoleRegistry' ); // return this.getService("SlotRoleRegistry");
// } // }
// //
// /** // /**
@ -826,7 +833,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return NameTableStore // * @return NameTableStore
// */ // */
// public function getSlotRoleStore() { // public function getSlotRoleStore() {
// return this.getService( 'NameTableStoreFactory' )->getSlotRoles(); // return this.getService("NameTableStoreFactory").getSlotRoles();
// } // }
// //
// /** // /**
@ -834,7 +841,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return SpecialPageFactory // * @return SpecialPageFactory
// */ // */
// public function getSpecialPageFactory() : SpecialPageFactory { // public function getSpecialPageFactory() : SpecialPageFactory {
// return this.getService( 'SpecialPageFactory' ); // return this.getService("SpecialPageFactory");
// } // }
// //
// /** // /**
@ -842,7 +849,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return IBufferingStatsdDataFactory // * @return IBufferingStatsdDataFactory
// */ // */
// public function getStatsdDataFactory() { // public function getStatsdDataFactory() {
// return this.getService( 'StatsdDataFactory' ); // return this.getService("StatsdDataFactory");
// } // }
/** /**
@ -850,7 +857,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
* @return TitleFormatter * @return TitleFormatter
*/ */
// public XomwTitleFormatter getTitleFormatter() { // public XomwTitleFormatter getTitleFormatter() {
// return this.getService( 'TitleFormatter' ); // return this.getService("TitleFormatter");
public XomwMediaWikiTitleCodec getTitleFormatter() { public XomwMediaWikiTitleCodec getTitleFormatter() {
return titleParser; return titleParser;
} }
@ -860,7 +867,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
* @return TitleParser * @return TitleParser
*/ */
// public XomwTitleParser getTitleParser() { // public XomwTitleParser getTitleParser() {
// return this.getService( 'TitleParser' ); // return this.getService("TitleParser");
public XomwMediaWikiTitleCodec getTitleParser() { public XomwMediaWikiTitleCodec getTitleParser() {
return titleParser; return titleParser;
} }
@ -870,7 +877,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return UploadRevisionImporter // * @return UploadRevisionImporter
// */ // */
// public function getUploadRevisionImporter() { // public function getUploadRevisionImporter() {
// return this.getService( 'UploadRevisionImporter' ); // return this.getService("UploadRevisionImporter");
// } // }
// //
// /** // /**
@ -878,7 +885,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return VirtualRESTServiceClient // * @return VirtualRESTServiceClient
// */ // */
// public function getVirtualRESTServiceClient() { // public function getVirtualRESTServiceClient() {
// return this.getService( 'VirtualRESTServiceClient' ); // return this.getService("VirtualRESTServiceClient");
// } // }
// //
// /** // /**
@ -886,7 +893,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return WatchedItemQueryService // * @return WatchedItemQueryService
// */ // */
// public function getWatchedItemQueryService() { // public function getWatchedItemQueryService() {
// return this.getService( 'WatchedItemQueryService' ); // return this.getService("WatchedItemQueryService");
// } // }
// //
// /** // /**
@ -894,7 +901,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return WatchedItemStoreInterface // * @return WatchedItemStoreInterface
// */ // */
// public function getWatchedItemStore() { // public function getWatchedItemStore() {
// return this.getService( 'WatchedItemStore' ); // return this.getService("WatchedItemStore");
// } // }
// //
// /** // /**
@ -902,7 +909,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return \OldRevisionImporter // * @return \OldRevisionImporter
// */ // */
// public function getWikiRevisionOldRevisionImporter() { // public function getWikiRevisionOldRevisionImporter() {
// return this.getService( 'OldRevisionImporter' ); // return this.getService("OldRevisionImporter");
// } // }
// //
// /** // /**
@ -910,7 +917,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return \OldRevisionImporter // * @return \OldRevisionImporter
// */ // */
// public function getWikiRevisionOldRevisionImporterNoUpdates() { // public function getWikiRevisionOldRevisionImporterNoUpdates() {
// return this.getService( 'WikiRevisionOldRevisionImporterNoUpdates' ); // return this.getService("WikiRevisionOldRevisionImporterNoUpdates");
// } // }
// //
// /** // /**
@ -918,7 +925,7 @@ public class XomwMediaWikiServices { // extends ServiceContainer
// * @return \UploadRevisionImporter // * @return \UploadRevisionImporter
// */ // */
// public function getWikiRevisionUploadImporter() { // public function getWikiRevisionUploadImporter() {
// return this.getService( 'UploadRevisionImporter' ); // return this.getService("UploadRevisionImporter");
// } // }
} }

View File

@ -16,13 +16,41 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
package gplx.xowa.mediawiki.includes; package gplx.xowa.mediawiki.includes;
import gplx.Err_; import gplx.Err_;
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.XophpCallback; import gplx.xowa.mediawiki.XophpCallback;
import gplx.xowa.mediawiki.XophpCallbackOwner; import gplx.xowa.mediawiki.XophpCallbackOwner;
import gplx.xowa.mediawiki.includes.config.XomwConfig;
import gplx.xowa.mediawiki.languages.XomwLanguage; import gplx.xowa.mediawiki.languages.XomwLanguage;
// MW.SRC:1.33.1 // MW.SRC:1.33.1
public class XomwServiceWiring implements XophpCallbackOwner { public class XomwServiceWiring implements XophpCallbackOwner {
// XO:infrastructure to register the multiple wiring methods
interface XomwServiceWiringMethod {
String Key();
Object Call(XomwMediaWikiServices mediaWikiServices);
}
private final XophpArray<XomwServiceWiringMethod> methods = new XophpArray<>();
public XomwServiceWiring() {
InitMethod(new InterwikiLookup());
}
private void InitMethod(XomwServiceWiringMethod method) {
methods.Add(method.Key(), method);
}
public XophpArray<XophpCallback> GetCallbacks() {
XophpArray<XophpCallback> rv = new XophpArray<>();
for (XomwServiceWiringMethod method : methods) {
rv.Add(this.NewCallback(method.Key()));
}
return rv;
}
@Override public Object Call(String methodName, Object... args) {
XomwMediaWikiServices services = (XomwMediaWikiServices)args[0];
XomwServiceWiringMethod method = methods.Get_by(methodName);
if (method == null) {
throw Err_.new_unhandled_default(methodName);
}
return method.Call(services);
};
//return [ //return [
// "ActorMigration" => function (MediaWikiServices services) : ActorMigration { // "ActorMigration" => function (MediaWikiServices services) : ActorMigration {
// return new ActorMigration( // return new ActorMigration(
@ -75,9 +103,12 @@ public class XomwServiceWiring implements XophpCallbackOwner {
// return new ConfiguredReadOnlyMode(services.getMainConfig()); // return new ConfiguredReadOnlyMode(services.getMainConfig());
// }, // },
private XomwLanguage newContentLanguage(XomwMediaWikiServices services) { class ContentLanguage implements XomwServiceWiringMethod {
@Override public String Key() {return "ContentLanguage";}
@Override public Object Call(XomwMediaWikiServices services) {
// return XomwLanguage.factory(services.getMainConfig().get("LanguageCode")); // return XomwLanguage.factory(services.getMainConfig().get("LanguageCode"));
return null; return null;
}
} }
// //
// "CryptHKDF" => function (MediaWikiServices services) : CryptHKDF { // "CryptHKDF" => function (MediaWikiServices services) : CryptHKDF {
@ -151,8 +182,9 @@ public class XomwServiceWiring implements XophpCallbackOwner {
// return new \MediaWiki\Http\HttpRequestFactory(); // return new \MediaWiki\Http\HttpRequestFactory();
// }, // },
class InterwikiLookup implements XomwServiceWiringMethod {
private Object newInterwikiLoopup(XomwMediaWikiServices services) { @Override public String Key() {return "InterwikiLookup";}
@Override public Object Call(XomwMediaWikiServices services) {
// XomwConfig config = services.getMainConfig(); // XomwConfig config = services.getMainConfig();
// return new ClassicInterwikiLookup( // return new ClassicInterwikiLookup(
// services.getContentLanguage(), // services.getContentLanguage(),
@ -162,21 +194,9 @@ public class XomwServiceWiring implements XophpCallbackOwner {
// config.get("InterwikiScopes"), // config.get("InterwikiScopes"),
// config.get("InterwikiFallbackSite") // config.get("InterwikiFallbackSite")
// ); // );
return null; return null;
}
@Override
public Object Call(String method, Object... args) {
XomwMediaWikiServices services = (XomwMediaWikiServices)args[0];
switch (method) {
case "InterwikiLookup":
return newInterwikiLoopup(services);
case "ContentLanguage":
return newContentLanguage(services);
default:
throw Err_.new_unhandled_default(method);
} }
}; }
// "LinkCache" => function (MediaWikiServices services) : LinkCache { // "LinkCache" => function (MediaWikiServices services) : LinkCache {
// return new LinkCache( // return new LinkCache(

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,18 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.config; package gplx.xowa.mediawiki.includes.config;
// MW.SRC:1.33.1 // MW.SRC:1.33.1

View File

@ -0,0 +1,28 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.config;
import gplx.xowa.mediawiki.XophpException;
// MW.SRC:1.33.1
/**
* Accesses configuration settings from GLOBALS
*
* @since 1.23
*/
public class XomwConfigException extends XophpException {
public XomwConfigException(String message) {super(message, 0, null);}
}

View File

@ -0,0 +1,87 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0.
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.mediawiki.includes.config;
import gplx.String_;
import gplx.xowa.mediawiki.XophpArray;
import gplx.xowa.mediawiki.includes.XomwGlobals;
// MW.SRC:1.33.1
/**
* Accesses configuration settings from GLOBALS
*
* @since 1.23
*/
public class XomwGlobalVarConfig implements XomwConfig {
/**
* Prefix to use for configuration variables
* @var string
*/
private String prefix;
/**
* Default builder function
* @return GlobalVarConfig
*/
public static XomwGlobalVarConfig newInstance() {
return new XomwGlobalVarConfig();
}
public XomwGlobalVarConfig() {this("wg");}
public XomwGlobalVarConfig(String prefix) {
this.prefix = prefix;
}
/**
* @inheritDoc
*/
public Object get(String name) {
if (!this.has(name)) {
throw new XomwConfigException(String_.Format("get: undefined option: '{0}'", name));
}
return this.getWithPrefix(this.prefix, name);
}
/**
* @inheritDoc
*/
public boolean has(String name) {
return this.hasWithPrefix(this.prefix, name);
}
/**
* Get a variable with a given prefix, if not the defaults.
*
* @param string prefix Prefix to use on the variable, if one.
* @param string name Variable name without prefix
* @return mixed
*/
protected Object getWithPrefix(String prefix, String name) {
return XomwGlobals.Instance.GLOBALS.Get_by(prefix + name);
}
/**
* Check if a variable with a given prefix is set
*
* @param string prefix Prefix to use on the variable
* @param string name Variable name without prefix
* @return bool
*/
protected boolean hasWithPrefix(String prefix, String name) {
String var = prefix + name;
return XophpArray.array_key_exists(var, XomwGlobals.Instance.GLOBALS);
}
}