http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96139
Revision: 96139
Author: catrope
Date: 2011-09-02 18:28:28 +0000 (Fri, 02 Sep 2011)
Log Message:
-----------
Merge r96132 from 1.17wmf1: support protocol-relative URLs in dumpInterwiki.php
Modified Paths:
--------------
trunk/phase3/maintenance/Site.php
trunk/phase3/maintenance/dumpInterwiki.php
Modified: trunk/phase3/maintenance/Site.php
===================================================================
--- trunk/phase3/maintenance/Site.php 2011-09-02 18:18:18 UTC (rev 96138)
+++ trunk/phase3/maintenance/Site.php 2011-09-02 18:28:28 UTC (rev 96139)
@@ -12,8 +12,8 @@
$this->url = $u;
}
- function getURL( $lang ) {
+ function getURL( $lang, $urlprotocol ) {
$xlang = str_replace( '_', '-', $lang );
- return "http://$xlang.{$this->url}/wiki/\$1";
+ return "$urlprotocol//$xlang.{$this->url}/wiki/\$1";
}
-}
\ No newline at end of file
+}
Modified: trunk/phase3/maintenance/dumpInterwiki.php
===================================================================
--- trunk/phase3/maintenance/dumpInterwiki.php 2011-09-02 18:18:18 UTC (rev
96138)
+++ trunk/phase3/maintenance/dumpInterwiki.php 2011-09-02 18:28:28 UTC (rev
96139)
@@ -37,6 +37,7 @@
$this->addOption( 'dblist', 'File with one db per line', false,
true );
$this->addOption( 'specialdbs', "File with one 'special' db per
line", false, true );
$this->addOption( 'o', 'Cdb output file', false, true );
+ $this->addOption( 'protocolrelative', 'Output wikimedia
interwiki urls as protocol relative', false, false );
}
function execute() {
@@ -55,6 +56,12 @@
$this->dbFile = false;
}
+ if ( $this->hasOption( 'protocolrelative' ) ) {
+ $this->urlprotocol = '';
+ } else {
+ $this->urlprotocol = 'http:';
+ }
+
$this->getRebuildInterwikiDump();
}
@@ -76,9 +83,9 @@
# Extra interwiki links that can't be in the intermap for some
reason
$extraLinks = array(
- array( 'm', 'http://meta.wikimedia.org/wiki/$1', 1 ),
- array( 'meta', 'http://meta.wikimedia.org/wiki/$1', 1 ),
- array( 'sep11', 'http://sep11.wikipedia.org/wiki/$1', 1
),
+ array( 'm', $this->urlprotocol .
'//meta.wikimedia.org/wiki/$1', 1 ),
+ array( 'meta', $this->urlprotocol .
'//meta.wikimedia.org/wiki/$1', 1 ),
+ array( 'sep11', $this->urlprotocol .
'//sep11.wikipedia.org/wiki/$1', 1 ),
);
# Language aliases, usually configured as redirects to the real
wiki in apache
@@ -126,6 +133,13 @@
$url = $matches[2];
if ( preg_match(
'/(wikipedia|wiktionary|wikisource|wikiquote|wikibooks|wikimedia)\.org/', $url
) ) {
+ if ( $this->hasOption(
'protocolrelative' ) ) {
+ if ( substr( $url, 0, 5 ) ==
'http:' ) {
+ $url = substr( $url, 5
);
+ } else if ( substr( $url, 0, 6
) == 'https:' ) {
+ $url = substr( $url, 6
);
+ }
+ }
$local = 1;
} else {
$local = 0;
@@ -155,7 +169,7 @@
# Links to multilanguage sites
foreach ( $sites as $targetSite ) {
$this->makeLink( array( 'iw_prefix' =>
$targetSite->lateral,
- 'iw_url' =>
$targetSite->getURL( 'en' ),
+ 'iw_url' =>
$targetSite->getURL( 'en', $this->urlprotocol ),
'iw_local' => 1 ), $db );
}
} else {
@@ -179,14 +193,14 @@
foreach ( $sites as $targetSite ) {
if ( $targetSite->suffix !=
$site->suffix ) {
$this->makeLink( array(
'iw_prefix' => $targetSite->lateral,
- 'iw_url' =>
$targetSite->getURL( $lang ),
+ 'iw_url' =>
$targetSite->getURL( $lang, $this->urlprotocol ),
'iw_local' => 1 ), $db
);
}
}
if ( $site->suffix == "wiki" ) {
$this->makeLink( array( 'iw_prefix' =>
'w',
- 'iw_url' =>
"http://en.wikipedia.org/wiki/$1",
+ 'iw_url' => $this->urlprotocol
. "//en.wikipedia.org/wiki/$1",
'iw_local' => 1 ), $db );
}
@@ -214,12 +228,12 @@
function makeLanguageLinks( &$site, $source ) {
# Actual languages with their own databases
foreach ( $this->langlist as $targetLang ) {
- $this->makeLink( array( $targetLang, $site->getURL(
$targetLang ), 1 ), $source );
+ $this->makeLink( array( $targetLang, $site->getURL(
$targetLang, $this->urlprotocol ), 1 ), $source );
}
# Language aliases
foreach ( $this->languageAliases as $alias => $lang ) {
- $this->makeLink( array( $alias, $site->getURL( $lang ),
1 ), $source );
+ $this->makeLink( array( $alias, $site->getURL( $lang,
$this->urlprotocol ), 1 ), $source );
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs