From: Brion Vibber Date: Thu, 16 Jun 2005 05:36:10 +0000 (+0000) Subject: * (bug 1702) Display a handy upload link instead of a useless blank link X-Git-Tag: 1.5.0beta1~183 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=6f7c6cee267303bcf650110b24cc113826effb13;p=lhc%2Fweb%2Fwiklou.git * (bug 1702) Display a handy upload link instead of a useless blank link for [[media:]] links to nonexistent files. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index bba2660d19..f93fbbfa33 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -291,7 +291,8 @@ Various bugfixes, small features, and a few experimental things: * Added wfMsgHtml() function for escaping messages and leaving params intact * Fix ordering of Special:Listusers; fix groups list so it shows all groups when searching for a specific group and can't be split across pages - +* (bug 1702) Display a handy upload link instead of a useless blank link + for [[media:]] links to nonexistent files. === Caveats === diff --git a/includes/Linker.php b/includes/Linker.php index 3bdbab9e90..ed7c6c9cfd 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -577,16 +577,23 @@ class Linker { } else { $name = $title->getDBKey(); $img = new Image( $title ); - $url = $img->getURL(); - if( $nourl ) { - $url = str_replace( "http://", "http-noparse://", $url ); + if( $img->exists() ) { + $url = $img->getURL(); + if( $nourl ) { + $url = str_replace( "http://", "http-noparse://", $url ); + } + $class = 'internal'; + } else { + $upload = Title::makeTitle( NS_SPECIAL, 'Upload' ); + $url = $upload->getLocalUrl( 'wpDestFile=' . urlencode( $img->getName() ) ); + $class = 'new'; } $alt = htmlspecialchars( $title->getText() ); if( $text == '' ) { $text = $alt; } $u = htmlspecialchars( $url ); - return "{$text}"; + return "{$text}"; } } diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index f644fe2b6d..a842a5bec7 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -2272,6 +2272,16 @@ Media link with nasty text

!! end +!! test +Media link to nonexistent file (bug 1702) +!! input +[[Media:No such.jpg]] +!! result +

Media:No such.jpg +

+!! end + + !! test Character reference normalization in link text (bug 1938)