X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fdb%2FLBFactory.php;h=dec6ae16938d52b697ff514598adacbe052911d7;hb=5bfce03820d1e511b1d9e3caca029d2bb6026d24;hp=af2acaa4dcf6a229c306eed8e43b400d07ab9dd8;hpb=01891953bc04749b3567344cc0ba8d4a3785eca6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/db/LBFactory.php b/includes/db/LBFactory.php index af2acaa4dc..dec6ae1693 100644 --- a/includes/db/LBFactory.php +++ b/includes/db/LBFactory.php @@ -28,6 +28,8 @@ abstract class LBFactory { /** * Get an LBFactory instance + * + * @return LBFactory */ static function &singleton() { if ( is_null( self::$instance ) ) { @@ -40,7 +42,6 @@ abstract class LBFactory { /** * Shut down, close connections and destroy the cached instance. - * */ static function destroyInstance() { if ( self::$instance ) { @@ -52,6 +53,8 @@ abstract class LBFactory { /** * Set the instance to be the given object + * + * @param $instance LBFactory */ static function setInstance( $instance ) { self::destroyInstance(); @@ -60,6 +63,7 @@ abstract class LBFactory { /** * Construct a factory based on a configuration array (typically from $wgLBFactoryConf) + * @param $conf */ abstract function __construct( $conf ); @@ -80,21 +84,25 @@ abstract class LBFactory { */ abstract function getMainLB( $wiki = false ); - /* + /** * Create a new load balancer for external storage. The resulting object will be * untracked, not chronology-protected, and the caller is responsible for * cleaning it up. * * @param $cluster String: external storage cluster, or false for core * @param $wiki String: wiki ID, or false for the current wiki + * + * @return LoadBalancer */ abstract function newExternalLB( $cluster, $wiki = false ); - /* + /** * Get a cached (tracked) load balancer for external storage * * @param $cluster String: external storage cluster, or false for core * @param $wiki String: wiki ID, or false for the current wiki + * + * @return LoadBalancer */ abstract function &getExternalLB( $cluster, $wiki = false ); @@ -102,6 +110,8 @@ abstract class LBFactory { * Execute a function for each tracked load balancer * The callback is called with the load balancer as the first parameter, * and $params passed as the subsequent parameters. + * @param $callback string|array + * @param array $params */ abstract function forEachLB( $callback, $params = array() ); @@ -113,6 +123,8 @@ abstract class LBFactory { /** * Call a method of each tracked load balancer + * @param $methodName string + * @param $args array */ function forEachLBCallMethod( $methodName, $args = array() ) { $this->forEachLB( array( $this, 'callMethod' ), array( $methodName, $args ) ); @@ -120,6 +132,9 @@ abstract class LBFactory { /** * Private helper for forEachLBCallMethod + * @param $loadBalancer + * @param $methodName string + * @param $args */ function callMethod( $loadBalancer, $methodName, $args ) { call_user_func_array( array( $loadBalancer, $methodName ), $args ); @@ -151,6 +166,10 @@ class LBFactory_Simple extends LBFactory { $this->chronProt = new ChronologyProtector; } + /** + * @param $wiki + * @return LoadBalancer + */ function newMainLB( $wiki = false ) { global $wgDBservers, $wgMasterWaitTimeout; if ( $wgDBservers ) { @@ -174,6 +193,10 @@ class LBFactory_Simple extends LBFactory { )); } + /** + * @param $wiki + * @return LoadBalancer + */ function getMainLB( $wiki = false ) { if ( !isset( $this->mainLB ) ) { $this->mainLB = $this->newMainLB( $wiki ); @@ -183,6 +206,12 @@ class LBFactory_Simple extends LBFactory { return $this->mainLB; } + /** + * @throws MWException + * @param $cluster + * @param $wiki + * @return LoadBalancer + */ function newExternalLB( $cluster, $wiki = false ) { global $wgExternalServers; if ( !isset( $wgExternalServers[$cluster] ) ) { @@ -193,6 +222,11 @@ class LBFactory_Simple extends LBFactory { )); } + /** + * @param $cluster + * @param $wiki + * @return array + */ function &getExternalLB( $cluster, $wiki = false ) { if ( !isset( $this->extLBs[$cluster] ) ) { $this->extLBs[$cluster] = $this->newExternalLB( $cluster, $wiki ); @@ -205,6 +239,8 @@ class LBFactory_Simple extends LBFactory { * Execute a function for each tracked load balancer * The callback is called with the load balancer as the first parameter, * and $params passed as the subsequent parameters. + * @param $callback + * @param $params array */ function forEachLB( $callback, $params = array() ) { if ( isset( $this->mainLB ) ) {