From: Bryan Tong Minh Date: Sun, 3 Jan 2010 22:45:34 +0000 (+0000) Subject: (bug 18885) Red links for media files do not support shared repositories X-Git-Tag: 1.31.0-rc.0~38424 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=1f12cbc8ed12eb7c1ba923aa724d5825f532aac4;p=lhc%2Fweb%2Fwiklou.git (bug 18885) Red links for media files do not support shared repositories $wgUploadNavigationUrl now also affects images inline images that do not exist. In that case the URL will get (?|&)wpDestFile= appended to it as appropriate. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 551e2fb6eb..c45bd6d822 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -81,7 +81,10 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN similarly to the category namespace. * $wgEnableSorbs renamed to $wgDnsBlacklistUrls ($wgEnableSorbs kept for backward compatibility) - +* $wgUploadNavigationUrl now also affects images inline images that do not + exist. In that case the URL will get (?|&)wpDestFile= appended to + it as appropriate. + === New features in 1.16 === * Add CSS defintion of the 'wikitable' class to shared.css @@ -279,6 +282,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 21826) Subsections of Special:Version now also have anchors * (bug 19791) Add URL of file source as comment to thumbs (for ImageMagick) * (bug 21946) Sorted wikitables do not properly handle minus signs +* (bug 18885) Red links for media files do not support shared repositories === Bug fixes in 1.16 === diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 51cccfdb16..ed4f047051 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -472,6 +472,9 @@ $wgMaxUploadSize = 1024*1024*100; # 100MB * Useful if you want to use a shared repository by default * without disabling local uploads (use $wgEnableUploads = false for that) * e.g. $wgUploadNavigationUrl = 'http://commons.wikimedia.org/wiki/Special:Upload'; + * + * This also affects images inline images that do not exist. In that case the URL will get + * (?|&)wpDestFile= appended to it as appropriate. */ $wgUploadNavigationUrl = false; diff --git a/includes/Linker.php b/includes/Linker.php index 2c16db4d80..17a6ceada7 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -666,26 +666,39 @@ class Linker { * @return string */ public function makeBrokenImageLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '', $time = false ) { - global $wgEnableUploads; + global $wgEnableUploads, $wgUploadNavigationUrl; if( $title instanceof Title ) { wfProfileIn( __METHOD__ ); $currentExists = $time ? ( wfFindFile( $title ) != false ) : false; - if( $wgEnableUploads && !$currentExists ) { - $upload = SpecialPage::getTitleFor( 'Upload' ); + if( ( $wgUploadNavigationUrl || $wgEnableUploads ) && !$currentExists ) { if( $text == '' ) $text = htmlspecialchars( $title->getPrefixedText() ); + $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title ); if( $redir ) { + wfProfileOut( __METHOD__ ); return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix ); } + $q = 'wpDestFile=' . $title->getPartialUrl(); if( $query != '' ) $q .= '&' . $query; + + if( $wgUploadNavigationUrl ) { + $href = wfAppendQuery( $wgUploadNavigationUrl, $q ); + } else { + $upload = SpecialPage::getTitleFor( 'Upload' ); + $href = $upload->getLocalUrl( $q ); + } + list( $inside, $trail ) = self::splitTrail( $trail ); - $style = $this->getInternalLinkAttributesObj( $title, $text, 'new' ); + wfProfileOut( __METHOD__ ); - return '' . $prefix . $text . $inside . '' . $trail; + return Html::element( 'a', array( + 'href' => $href, + 'class' => 'new', + 'title' => $title->getPrefixedText() + ), $prefix . $text . $inside ) . $trail; } else { wfProfileOut( __METHOD__ ); return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix ); @@ -716,9 +729,7 @@ class Linker { $url = $img->getURL(); $class = 'internal'; } else { - $upload = SpecialPage::getTitleFor( 'Upload' ); - $url = $upload->getLocalUrl( 'wpDestFile=' . urlencode( $title->getDBkey() ) ); - $class = 'new'; + return $this->makeBrokenImageLinkObj( $title, $text, '', '', '', '', $time==true ); } $alt = htmlspecialchars( $title->getText() ); if( $text == '' ) {