Florianschmidtwelzow has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/266767

Change subject: Special:Version: Don't linkSVN repo to svn.wikimedia.org anymore
......................................................................

Special:Version: Don't linkSVN repo to svn.wikimedia.org anymore

The Wikimedia SVN repository was deprecated a long time ago and currently
redirects to Diffusion only. Furthermore, there shouldn't be any extensions
using Wikimedia svn anymore, which is compatible or used with MediaWiki 1.27.0.

Added a new hook (SpecialVersion::getSvnUrlLinkMap) to allow developers and
wiki sysadmins to add their own SVN repo-url => viewvc-url map.

Change-Id: I18e5b10652713e6ff689c81da5c74faec8e9a6d0
---
M RELEASE-NOTES-1.27
M docs/hooks.txt
M includes/specials/SpecialVersion.php
3 files changed, 42 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/67/266767/1

diff --git a/RELEASE-NOTES-1.27 b/RELEASE-NOTES-1.27
index 50d40a6..2650dde 100644
--- a/RELEASE-NOTES-1.27
+++ b/RELEASE-NOTES-1.27
@@ -294,6 +294,9 @@
   together but instead pick the final one, similar to image syntax.
 * XML-like parser tags (such as <gallery>), when unclosed, will be left 
unparsed
   rather than consume everything until the end of the page.
+* Special:Version does not link SVN revisions to svn.wikimedia.org anymore. 
You can
+  workaround this by using the new SpecialVersion::getSvnUrlLinkMap, however, 
there
+  shouldn't be any extensions using Wikimedia SVN anymore.
 
 == Compatibility ==
 
diff --git a/docs/hooks.txt b/docs/hooks.txt
index 2b5e1e0..aaa6c17 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -2975,6 +2975,15 @@
 $wgVersion: Current $wgVersion for you to use
 &$versionUrl: Raw url to link to (eg: release notes)
 
+'SpecialVersion::getSvnUrlLinkMap': Called when Special:Version tries to get a 
View VC
+url for a svn repo-url the first time. Can be used to add a map of svn 
repo-urls to svn
+View VC urls (e.g.
+array(
+       'svn+ssh://svn.wikimedia.org/svnroot/mediawiki' =>
+               'http://svn.wikimedia.org/viewvc/mediawiki' )
+).
+&$urls array Already added URLs.
+
 'SpecialWatchlistFilters': DEPRECATED! Use ChangesListSpecialPageFilters
 instead.
 Called after building form options at Watchlist.
diff --git a/includes/specials/SpecialVersion.php 
b/includes/specials/SpecialVersion.php
index 43228fa..66ecdcb 100644
--- a/includes/specials/SpecialVersion.php
+++ b/includes/specials/SpecialVersion.php
@@ -38,11 +38,11 @@
 
        protected static $extensionTypes = false;
 
-       protected static $viewvcUrls = array(
-               'svn+ssh://svn.wikimedia.org/svnroot/mediawiki' => 
'http://svn.wikimedia.org/viewvc/mediawiki',
-               'http://svn.wikimedia.org/svnroot/mediawiki' => 
'http://svn.wikimedia.org/viewvc/mediawiki',
-               'https://svn.wikimedia.org/svnroot/mediawiki' => 
'https://svn.wikimedia.org/viewvc/mediawiki',
-       );
+       /**
+        * @var array|boolean Holds an array of SVN url to webviewer links 
mapping, or false
+        *  if the hook SpecialVersion::getSvnUrlLinkMap wasn't called so far.
+        */
+       protected $viewvcUrls = false;
 
        public function __construct() {
                parent::__construct( 'Version' );
@@ -1222,19 +1222,41 @@
                        'directory-rev' => intval( trim( $lines[10] ) )
                );
 
-               if ( isset( self::$viewvcUrls[$info['repo-url']] ) ) {
+               // try to get a viewvc url
+               $this->transformLinkableSvnUrl( $info );
+
+               return $info;
+       }
+
+       /**
+        * Tries to transform the svn url (given in the repo-url part of the 
given info array)
+        * into an url, where Special:Version can link to, which will be put 
into the
+        * viewvc-url part of the given info array. Otherwise this does nothing.
+        *
+        * @param array &$info The array that holds information about the svn 
repo
+        * @return boolean True, if a viewvc-url was set, false otherwise
+        */
+       protected function transformLinkableSvnUrl( &$info ) {
+               if ( $this->viewvcUrls === false ) {
+                       $urls = array();
+                       Hooks::run( 'SpecialVersion::getSvnUrlLinkMap', array( 
$urls ) );
+                       $this->viewvcUrls = $urls;
+               }
+               if ( isset( $this->viewvcUrls[$info['repo-url']] ) ) {
                        $viewvc = str_replace(
                                $info['repo-url'],
-                               self::$viewvcUrls[$info['repo-url']],
+                               $this->$viewvcUrls[$info['repo-url']],
                                $info['url']
                        );
 
                        $viewvc .= '/?pathrev=';
                        $viewvc .= urlencode( $info['checkout-rev'] );
                        $info['viewvc-url'] = $viewvc;
+
+                       return true;
                }
 
-               return $info;
+               return false;
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/266767
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I18e5b10652713e6ff689c81da5c74faec8e9a6d0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to