Index: trunk/phase3/maintenance/doMaintenance.php |
— | — | @@ -82,11 +82,9 @@ |
83 | 83 | global $cluster; |
84 | 84 | $cluster = 'pmtpa'; |
85 | 85 | require( MWInit::interpretedPath( '../wmf-config/wgConf.php' ) ); |
86 | | - $maintenance->loadWikimediaSettings(); |
87 | | - require( MWInit::interpretedPath( '../wmf-config/CommonSettings.php' ) ); |
88 | | -} else { |
89 | | - require_once( $maintenance->loadSettings() ); |
90 | 86 | } |
| 87 | +// Require the configuration (probably LocalSettings.php) |
| 88 | +require( MWInit::interpretedPath( $maintenance->loadSettings() ) ); |
91 | 89 | |
92 | 90 | if ( $maintenance->getDbType() === Maintenance::DB_ADMIN && |
93 | 91 | is_readable( "$IP/AdminSettings.php" ) ) |
Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -891,57 +891,6 @@ |
892 | 892 | } |
893 | 893 | |
894 | 894 | /** |
895 | | - * Do setup specific to WMF |
896 | | - */ |
897 | | - public function loadWikimediaSettings() { |
898 | | - global $IP, $wgNoDBParam, $wgUseNormalUser, $wgConf, $site, $lang; |
899 | | - |
900 | | - if ( empty( $wgNoDBParam ) ) { |
901 | | - # Check if we were passed a db name |
902 | | - if ( isset( $this->mOptions['wiki'] ) ) { |
903 | | - $db = $this->mOptions['wiki']; |
904 | | - } else { |
905 | | - $db = array_shift( $this->mArgs ); |
906 | | - } |
907 | | - list( $site, $lang ) = $wgConf->siteFromDB( $db ); |
908 | | - |
909 | | - # If not, work out the language and site the old way |
910 | | - if ( is_null( $site ) || is_null( $lang ) ) { |
911 | | - if ( !$db ) { |
912 | | - $lang = 'aa'; |
913 | | - } else { |
914 | | - $lang = $db; |
915 | | - } |
916 | | - if ( isset( $this->mArgs[0] ) ) { |
917 | | - $site = array_shift( $this->mArgs ); |
918 | | - } else { |
919 | | - $site = 'wikipedia'; |
920 | | - } |
921 | | - } |
922 | | - } else { |
923 | | - $lang = 'aa'; |
924 | | - $site = 'wikipedia'; |
925 | | - } |
926 | | - |
927 | | - # This is for the IRC scripts, which now run as the apache user |
928 | | - # The apache user doesn't have access to the wikiadmin_pass command |
929 | | - if ( $_ENV['USER'] == 'apache' ) { |
930 | | - # if ( posix_geteuid() == 48 ) { |
931 | | - $wgUseNormalUser = true; |
932 | | - } |
933 | | - |
934 | | - putenv( 'wikilang=' . $lang ); |
935 | | - |
936 | | - ini_set( 'include_path', ".:$IP:$IP/includes:$IP/languages:$IP/maintenance" ); |
937 | | - |
938 | | - if ( $lang == 'test' && $site == 'wikipedia' ) { |
939 | | - if ( !defined( 'TESTWIKI' ) ) { |
940 | | - define( 'TESTWIKI', 1 ); |
941 | | - } |
942 | | - } |
943 | | - } |
944 | | - |
945 | | - /** |
946 | 895 | * Generic setup for most installs. Returns the location of LocalSettings |
947 | 896 | * @return String |
948 | 897 | */ |
Index: trunk/extensions/WikimediaMaintenance/Site.php |
— | — | @@ -1,19 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * @todo document |
5 | | - * @ingroup Maintenance |
6 | | - */ |
7 | | -class Site { |
8 | | - var $suffix, $lateral, $url; |
9 | | - |
10 | | - function __construct( $s, $l, $u ) { |
11 | | - $this->suffix = $s; |
12 | | - $this->lateral = $l; |
13 | | - $this->url = $u; |
14 | | - } |
15 | | - |
16 | | - function getURL( $lang, $urlprotocol ) { |
17 | | - $xlang = str_replace( '_', '-', $lang ); |
18 | | - return "$urlprotocol//$xlang.{$this->url}/wiki/\$1"; |
19 | | - } |
20 | | -} |
Index: trunk/extensions/WikimediaMaintenance/dumpInterwiki.php |
— | — | @@ -23,17 +23,10 @@ |
24 | 24 | * @ingroup Maintenance |
25 | 25 | * @ingroup Wikimedia |
26 | 26 | */ |
| 27 | +require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' ); |
27 | 28 | |
28 | | -$IP = getenv( 'MW_INSTALL_PATH' ); |
29 | | -if ( $IP === false ) { |
30 | | - $IP = dirname( __FILE__ ) . '/../..'; |
31 | | -} |
32 | | -require( "$IP/maintenance/Maintenance.php" ); |
| 29 | +class DumpInterwiki extends WikimediaMaintenance { |
33 | 30 | |
34 | | -require_once( dirname( __FILE__ ) . '/Site.php' ); |
35 | | - |
36 | | -class DumpInterwiki extends Maintenance { |
37 | | - |
38 | 31 | public function __construct() { |
39 | 32 | parent::__construct(); |
40 | 33 | $this->mDescription = "Build constant slightly compact database of interwiki prefixes."; |
— | — | @@ -75,14 +68,14 @@ |
76 | 69 | # Multi-language sites |
77 | 70 | # db suffix => db suffix, iw prefix, hostname |
78 | 71 | $sites = array( |
79 | | - 'wiki' => new Site( 'wiki', 'w', 'wikipedia.org' ), |
80 | | - 'wiktionary' => new Site( 'wiktionary', 'wikt', 'wiktionary.org' ), |
81 | | - 'wikiquote' => new Site( 'wikiquote', 'q', 'wikiquote.org' ), |
82 | | - 'wikibooks' => new Site( 'wikibooks', 'b', 'wikibooks.org' ), |
83 | | - 'wikinews' => new Site( 'wikinews', 'n', 'wikinews.org' ), |
84 | | - 'wikisource' => new Site( 'wikisource', 's', 'wikisource.org' ), |
85 | | - 'wikimedia' => new Site( 'wikimedia', 'chapter', 'wikimedia.org' ), |
86 | | - 'wikiversity' => new Site( 'wikiversity', 'v', 'wikiversity.org' ), |
| 72 | + 'wiki' => new WMFSite( 'wiki', 'w', 'wikipedia.org' ), |
| 73 | + 'wiktionary' => new WMFSite( 'wiktionary', 'wikt', 'wiktionary.org' ), |
| 74 | + 'wikiquote' => new WMFSite( 'wikiquote', 'q', 'wikiquote.org' ), |
| 75 | + 'wikibooks' => new WMFSite( 'wikibooks', 'b', 'wikibooks.org' ), |
| 76 | + 'wikinews' => new WMFSite( 'wikinews', 'n', 'wikinews.org' ), |
| 77 | + 'wikisource' => new WMFSite( 'wikisource', 's', 'wikisource.org' ), |
| 78 | + 'wikimedia' => new WMFSite( 'wikimedia', 'chapter', 'wikimedia.org' ), |
| 79 | + 'wikiversity' => new WMFSite( 'wikiversity', 'v', 'wikiversity.org' ), |
87 | 80 | ); |
88 | 81 | |
89 | 82 | # Extra interwiki links that can't be in the intermap for some reason |
Index: trunk/extensions/WikimediaMaintenance/renameWiki.php |
— | — | @@ -22,14 +22,9 @@ |
23 | 23 | * @ingroup Maintenance |
24 | 24 | * @ingroup Wikimedia |
25 | 25 | */ |
| 26 | +require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' ); |
26 | 27 | |
27 | | -$IP = getenv( 'MW_INSTALL_PATH' ); |
28 | | -if ( $IP === false ) { |
29 | | - $IP = dirname( __FILE__ ) . '/../..'; |
30 | | -} |
31 | | -require( "$IP/maintenance/Maintenance.php" ); |
32 | | - |
33 | | -class RenameWiki extends Maintenance { |
| 28 | +class RenameWiki extends WikimediaMaintenance { |
34 | 29 | public function __construct() { |
35 | 30 | parent::__construct(); |
36 | 31 | $this->mDescription = "Rename external storage dbs and leave a new one"; |
Index: trunk/extensions/WikimediaMaintenance/addWiki.php |
— | — | @@ -26,13 +26,8 @@ |
27 | 27 | * @ingroup Maintenance |
28 | 28 | * @ingroup Wikimedia |
29 | 29 | */ |
| 30 | +require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' ); |
30 | 31 | |
31 | | -$IP = getenv( 'MW_INSTALL_PATH' ); |
32 | | -if ( $IP === false ) { |
33 | | - $IP = dirname( __FILE__ ) . '/../..'; |
34 | | -} |
35 | | -require( "$IP/maintenance/Maintenance.php" ); |
36 | | - |
37 | 32 | class AddWiki extends Maintenance { |
38 | 33 | public function __construct() { |
39 | 34 | global $wgNoDBParam; |
Index: trunk/extensions/WikimediaMaintenance/rebuildInterwiki.php |
— | — | @@ -23,22 +23,16 @@ |
24 | 24 | * @ingroup Maintenance |
25 | 25 | * @ingroup Wikimedia |
26 | 26 | */ |
| 27 | +require_once( dirname( __FILE__ ) . '/WikimediaMaintenance.php' ); |
27 | 28 | |
28 | | -$IP = getenv( 'MW_INSTALL_PATH' ); |
29 | | -if ( $IP === false ) { |
30 | | - $IP = dirname( __FILE__ ) . '/../..'; |
31 | | -} |
32 | | -require( "$IP/maintenance/Maintenance.php" ); |
33 | | - |
34 | | -require_once( dirname( __FILE__ ) . '/Site.php' ); |
35 | | - |
36 | | -class RebuildInterwiki extends Maintenance { |
| 29 | +class RebuildInterwiki extends DumpInterwiki { |
37 | 30 | public function __construct() { |
38 | 31 | parent::__construct(); |
39 | 32 | $this->mDescription = "Rebuild the interwiki table using the file on meta and the language list."; |
40 | 33 | $this->addOption( 'langlist', 'File with one language code per line', false, true ); |
41 | 34 | $this->addOption( 'dblist', 'File with one db per line', false, true ); |
42 | 35 | $this->addOption( 'd', 'Output folder', false, true ); |
| 36 | + $this->addOption( 'protocolrelative', 'Output wikimedia interwiki urls as protocol relative', false, false ); |
43 | 37 | } |
44 | 38 | |
45 | 39 | function execute() { |
— | — | @@ -52,6 +46,12 @@ |
53 | 47 | //$this->specials = array_flip( array_map( "trim", file( $this->getOption( 'specialdbs', "/home/wikipedia/common/special.dblist" ) ) ) ); |
54 | 48 | |
55 | 49 | $this->makeInterwikiSQL( $this->getOption( 'd', '/home/wikipedia/conf/interwiki/sql' ) ); |
| 50 | + |
| 51 | + if ( $this->hasOption( 'protocolrelative' ) ) { |
| 52 | + $this->urlprotocol = ''; |
| 53 | + } else { |
| 54 | + $this->urlprotocol = 'http:'; |
| 55 | + } |
56 | 56 | } |
57 | 57 | |
58 | 58 | function makeInterwikiSQL( $destDir ) { |
— | — | @@ -60,14 +60,14 @@ |
61 | 61 | # Multi-language sites |
62 | 62 | # db suffix => db suffix, iw prefix, hostname |
63 | 63 | $sites = array( |
64 | | - 'wiki' => new Site( 'wiki', 'w', 'wikipedia.org' ), |
65 | | - 'wiktionary' => new Site( 'wiktionary', 'wikt', 'wiktionary.org' ), |
66 | | - 'wikiquote' => new Site( 'wikiquote', 'q', 'wikiquote.org' ), |
67 | | - 'wikibooks' => new Site( 'wikibooks', 'b', 'wikibooks.org' ), |
68 | | - 'wikinews' => new Site( 'wikinews', 'n', 'wikinews.org' ), |
69 | | - 'wikisource' => new Site( 'wikisource', 's', 'wikisource.org' ), |
70 | | - 'wikimedia' => new Site( 'wikimedia', 'chapter', 'wikimedia.org' ), |
71 | | - 'wikiversity' => new Site( 'wikiversity', 'v', 'wikiversity.org' ), |
| 64 | + 'wiki' => new WMFSite( 'wiki', 'w', 'wikipedia.org' ), |
| 65 | + 'wiktionary' => new WMFSite( 'wiktionary', 'wikt', 'wiktionary.org' ), |
| 66 | + 'wikiquote' => new WMFSite( 'wikiquote', 'q', 'wikiquote.org' ), |
| 67 | + 'wikibooks' => new WMFSite( 'wikibooks', 'b', 'wikibooks.org' ), |
| 68 | + 'wikinews' => new WMFSite( 'wikinews', 'n', 'wikinews.org' ), |
| 69 | + 'wikisource' => new WMFSite( 'wikisource', 's', 'wikisource.org' ), |
| 70 | + 'wikimedia' => new WMFSite( 'wikimedia', 'chapter', 'wikimedia.org' ), |
| 71 | + 'wikiversity' => new WMFSite( 'wikiversity', 'v', 'wikiversity.org' ), |
72 | 72 | ); |
73 | 73 | |
74 | 74 | # Special-case hostnames |
— | — | @@ -83,9 +83,9 @@ |
84 | 84 | |
85 | 85 | # Extra interwiki links that can't be in the intermap for some reason |
86 | 86 | $extraLinks = array( |
87 | | - array( 'm', 'http://meta.wikimedia.org/wiki/$1', 1 ), |
88 | | - array( 'meta', 'http://meta.wikimedia.org/wiki/$1', 1 ), |
89 | | - array( 'sep11', 'http://sep11.wikipedia.org/wiki/$1', 1 ), |
| 87 | + array( 'm', $this->urlprotocol . '//meta.wikimedia.org/wiki/$1', 1 ), |
| 88 | + array( 'meta', $this->urlprotocol . '//meta.wikimedia.org/wiki/$1', 1 ), |
| 89 | + array( 'sep11', $this->urlprotocol . '//sep11.wikipedia.org/wiki/$1', 1 ), |
90 | 90 | ); |
91 | 91 | |
92 | 92 | # Language aliases, usually configured as redirects to the real wiki in apache |
— | — | @@ -164,7 +164,7 @@ |
165 | 165 | |
166 | 166 | # Links to multilanguage sites |
167 | 167 | foreach ( $sites as $targetSite ) { |
168 | | - $sql .= $this->makeLink( array( $targetSite->lateral, $targetSite->getURL( 'en' ), 1 ), $first, $db ); |
| 168 | + $sql .= $this->makeLink( array( $targetSite->lateral, $targetSite->getURL( 'en', $this->urlprotocol ), 1 ), $first, $db ); |
169 | 169 | } |
170 | 170 | |
171 | 171 | # Interlanguage links to wikipedia |
— | — | @@ -213,7 +213,7 @@ |
214 | 214 | foreach ( $sites as $targetSite ) { |
215 | 215 | # Suppress link to self |
216 | 216 | if ( $targetSite->suffix != $site->suffix ) { |
217 | | - $sql .= $this->makeLink( array( $targetSite->lateral, $targetSite->getURL( $lang ), 1 ), $first, $db ); |
| 217 | + $sql .= $this->makeLink( array( $targetSite->lateral, $targetSite->getURL( $lang, $this->urlprotocol ), 1 ), $first, $db ); |
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
— | — | @@ -223,7 +223,7 @@ |
224 | 224 | # w link within wikipedias |
225 | 225 | # Other sites already have it as a lateral link |
226 | 226 | if ( $site->suffix == "wiki" ) { |
227 | | - $sql .= $this->makeLink( array( "w", "http://en.wikipedia.org/wiki/$1", 1 ), $first, $db ); |
| 227 | + $sql .= $this->makeLink( array( "w", "{$this->urlprotocol}//en.wikipedia.org/wiki/$1", 1 ), $first, $db ); |
228 | 228 | } |
229 | 229 | |
230 | 230 | # Extra links |
— | — | @@ -244,12 +244,12 @@ |
245 | 245 | |
246 | 246 | # Actual languages with their own databases |
247 | 247 | foreach ( $this->langlist as $targetLang ) { |
248 | | - $sql .= $this->makeLink( array( $targetLang, $site->getURL( $targetLang ), 1 ), $first, $source ); |
| 248 | + $sql .= $this->makeLink( array( $targetLang, $site->getURL( $targetLang, $this->urlprotocol ), 1 ), $first, $source ); |
249 | 249 | } |
250 | 250 | |
251 | 251 | # Language aliases |
252 | 252 | foreach ( $this->languageAliases as $alias => $lang ) { |
253 | | - $sql .= $this->makeLink( array( $alias, $site->getURL( $lang ), 1 ), $first, $source ); |
| 253 | + $sql .= $this->makeLink( array( $alias, $site->getURL( $lang, $this->urlprotocol ), 1 ), $first, $source ); |
254 | 254 | } |
255 | 255 | return $sql; |
256 | 256 | } |
Index: trunk/extensions/WikimediaMaintenance/WMFSite.php |
— | — | @@ -0,0 +1,19 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * A simple little class referring to a specific WMF site. |
| 5 | + * @ingroup Maintenance |
| 6 | + */ |
| 7 | +class WMFSite { |
| 8 | + var $suffix, $lateral, $url; |
| 9 | + |
| 10 | + function __construct( $s, $l, $u ) { |
| 11 | + $this->suffix = $s; |
| 12 | + $this->lateral = $l; |
| 13 | + $this->url = $u; |
| 14 | + } |
| 15 | + |
| 16 | + function getURL( $lang, $urlprotocol ) { |
| 17 | + $xlang = str_replace( '_', '-', $lang ); |
| 18 | + return "$urlprotocol//$xlang.{$this->url}/wiki/\$1"; |
| 19 | + } |
| 20 | +} |
Property changes on: trunk/extensions/WikimediaMaintenance/WMFSite.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 21 | + native |
Added: svn:keywords |
2 | 22 | + Author Date Id Revision |