r98254 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98253‎ | r98254 | r98255 >
Date:21:11, 27 September 2011
Author:aaron
Status:ok
Tags:
Comment:
* Added newFromDBName() function to allow non-singleton use.
* Minor doc tweaks and updates
Modified paths:
  • /trunk/tools/mwmultiversion/multiversion/MWMultiVersion.php (modified) (history)

Diff [purge]

Index: trunk/tools/mwmultiversion/multiversion/MWMultiVersion.php
@@ -1,7 +1,9 @@
22 <?php
33 /**
44 * Class to handle basic information related to what
5 - * version of MediaWiki is running on a wiki installation
 5+ * version of MediaWiki is running on a wiki installation.
 6+ *
 7+ * Avoid setting environmental or globals variables here for OOP.
68 */
79 class MWMultiVersion {
810
@@ -36,9 +38,20 @@
3739 private function __clone() {}
3840
3941 /**
40 - * Create the version instance
 42+ * Create a multiversion object based on a dbname
 43+ * @param $dbName string
4144 * @return MWMultiVersion object for this wiki
4245 */
 46+ public static function newFromDBName( $dbName ) {
 47+ $m = new self();
 48+ $m->db = $dbName;
 49+ return $m;
 50+ }
 51+
 52+ /**
 53+ * Create the singleton version instance
 54+ * @return MWMultiVersion object for this wiki
 55+ */
4356 private static function createInstance() {
4457 if ( isset( self::$instance ) ) {
4558 self::error( "MWMultiVersion instance already set!\n" );
@@ -48,8 +61,8 @@
4962 }
5063
5164 /**
52 - * Factory method to get an instance of MWMultiVersion.
53 - * Use this for all wikis except calls to /w/thumb.php on upload.wikmedia.org.
 65+ * Initialize and get the singleton instance of MWMultiVersion.
 66+ * Use this for all web hits except to /w/thumb.php on upload.wikmedia.org.
5467 * @param $serverName the ServerName for this wiki -- $_SERVER['SERVER_NAME']
5568 * @param $docRoot the DocumentRoot for this wiki -- $_SERVER['DOCUMENT_ROOT']
5669 * @return MWMultiVersion object for this wiki
@@ -61,8 +74,8 @@
6275 }
6376
6477 /**
65 - * Factory method to get an instance of MWMultiVersion used
66 - * for calls to /w/thumb.php on upload.wikmedia.org.
 78+ * Initialize and get the singleton instance of MWMultiVersion.
 79+ * Use this for web hits to /w/thumb.php on upload.wikmedia.org.
6780 * @param $pathInfo the PathInfo -- $_SERVER['PATH_INFO']
6881 * @return MWMultiVersion object for the wiki derived from the pathinfo
6982 */
@@ -73,8 +86,8 @@
7487 }
7588
7689 /**
77 - * Factory method to get an instance of MWMultiVersion
78 - * via maintenance scripts since they need to set site and lang.
 90+ * Initialize and get the singleton instance of MWMultiVersion.
 91+ * Use this for PHP CLI hits to maintenance scripts.
7992 * @return MWMultiVersion object for the wiki derived from --wiki CLI parameter
8093 */
8194 public static function initializeForMaintenance() {
@@ -84,7 +97,7 @@
8598 }
8699
87100 /**
88 - * Get the instance of MWMultiVersion that was previously initialized
 101+ * Get the singleton instance of MWMultiVersion that was previously initialized
89102 * @return MWMultiVersion|null version object for the wiki
90103 */
91104 public static function getInstance() {

Status & tagging log