Index: trunk/tools/mwmultiversion/multiversion/MWMultiVersion.php |
— | — | @@ -1,7 +1,9 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | 4 | * 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. |
6 | 8 | */ |
7 | 9 | class MWMultiVersion { |
8 | 10 | |
— | — | @@ -36,9 +38,20 @@ |
37 | 39 | private function __clone() {} |
38 | 40 | |
39 | 41 | /** |
40 | | - * Create the version instance |
| 42 | + * Create a multiversion object based on a dbname |
| 43 | + * @param $dbName string |
41 | 44 | * @return MWMultiVersion object for this wiki |
42 | 45 | */ |
| 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 | + */ |
43 | 56 | private static function createInstance() { |
44 | 57 | if ( isset( self::$instance ) ) { |
45 | 58 | self::error( "MWMultiVersion instance already set!\n" ); |
— | — | @@ -48,8 +61,8 @@ |
49 | 62 | } |
50 | 63 | |
51 | 64 | /** |
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. |
54 | 67 | * @param $serverName the ServerName for this wiki -- $_SERVER['SERVER_NAME'] |
55 | 68 | * @param $docRoot the DocumentRoot for this wiki -- $_SERVER['DOCUMENT_ROOT'] |
56 | 69 | * @return MWMultiVersion object for this wiki |
— | — | @@ -61,8 +74,8 @@ |
62 | 75 | } |
63 | 76 | |
64 | 77 | /** |
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. |
67 | 80 | * @param $pathInfo the PathInfo -- $_SERVER['PATH_INFO'] |
68 | 81 | * @return MWMultiVersion object for the wiki derived from the pathinfo |
69 | 82 | */ |
— | — | @@ -73,8 +86,8 @@ |
74 | 87 | } |
75 | 88 | |
76 | 89 | /** |
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. |
79 | 92 | * @return MWMultiVersion object for the wiki derived from --wiki CLI parameter |
80 | 93 | */ |
81 | 94 | public static function initializeForMaintenance() { |
— | — | @@ -84,7 +97,7 @@ |
85 | 98 | } |
86 | 99 | |
87 | 100 | /** |
88 | | - * Get the instance of MWMultiVersion that was previously initialized |
| 101 | + * Get the singleton instance of MWMultiVersion that was previously initialized |
89 | 102 | * @return MWMultiVersion|null version object for the wiki |
90 | 103 | */ |
91 | 104 | public static function getInstance() { |