r60593 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60592‎ | r60593 | r60594 >
Date:22:45, 3 January 2010
Author:btongminh
Status:resolved (Comments)
Tags:
Comment:
(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=<filename> appended to
it as appropriate.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -666,26 +666,39 @@
667667 * @return string
668668 */
669669 public function makeBrokenImageLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '', $time = false ) {
670 - global $wgEnableUploads;
 670+ global $wgEnableUploads, $wgUploadNavigationUrl;
671671 if( $title instanceof Title ) {
672672 wfProfileIn( __METHOD__ );
673673 $currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
674 - if( $wgEnableUploads && !$currentExists ) {
675 - $upload = SpecialPage::getTitleFor( 'Upload' );
 674+ if( ( $wgUploadNavigationUrl || $wgEnableUploads ) && !$currentExists ) {
676675 if( $text == '' )
677676 $text = htmlspecialchars( $title->getPrefixedText() );
 677+
678678 $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
679679 if( $redir ) {
 680+ wfProfileOut( __METHOD__ );
680681 return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
681682 }
 683+
682684 $q = 'wpDestFile=' . $title->getPartialUrl();
683685 if( $query != '' )
684686 $q .= '&' . $query;
 687+
 688+ if( $wgUploadNavigationUrl ) {
 689+ $href = wfAppendQuery( $wgUploadNavigationUrl, $q );
 690+ } else {
 691+ $upload = SpecialPage::getTitleFor( 'Upload' );
 692+ $href = $upload->getLocalUrl( $q );
 693+ }
 694+
685695 list( $inside, $trail ) = self::splitTrail( $trail );
686 - $style = $this->getInternalLinkAttributesObj( $title, $text, 'new' );
 696+
687697 wfProfileOut( __METHOD__ );
688 - return '<a href="' . $upload->escapeLocalUrl( $q ) . '"'
689 - . $style . '>' . $prefix . $text . $inside . '</a>' . $trail;
 698+ return Html::element( 'a', array(
 699+ 'href' => $href,
 700+ 'class' => 'new',
 701+ 'title' => $title->getPrefixedText()
 702+ ), $prefix . $text . $inside ) . $trail;
690703 } else {
691704 wfProfileOut( __METHOD__ );
692705 return $this->makeKnownLinkObj( $title, $text, $query, $trail, $prefix );
@@ -716,9 +729,7 @@
717730 $url = $img->getURL();
718731 $class = 'internal';
719732 } else {
720 - $upload = SpecialPage::getTitleFor( 'Upload' );
721 - $url = $upload->getLocalUrl( 'wpDestFile=' . urlencode( $title->getDBkey() ) );
722 - $class = 'new';
 733+ return $this->makeBrokenImageLinkObj( $title, $text, '', '', '', '', $time==true );
723734 }
724735 $alt = htmlspecialchars( $title->getText() );
725736 if( $text == '' ) {
Index: trunk/phase3/includes/DefaultSettings.php
@@ -472,6 +472,9 @@
473473 * Useful if you want to use a shared repository by default
474474 * without disabling local uploads (use $wgEnableUploads = false for that)
475475 * e.g. $wgUploadNavigationUrl = 'http://commons.wikimedia.org/wiki/Special:Upload';
 476+ *
 477+ * This also affects images inline images that do not exist. In that case the URL will get
 478+ * (?|&)wpDestFile=<filename> appended to it as appropriate.
476479 */
477480 $wgUploadNavigationUrl = false;
478481
Index: trunk/phase3/RELEASE-NOTES
@@ -81,7 +81,10 @@
8282 similarly to the category namespace.
8383 * $wgEnableSorbs renamed to $wgDnsBlacklistUrls ($wgEnableSorbs kept for
8484 backward compatibility)
85 -
 85+* $wgUploadNavigationUrl now also affects images inline images that do not
 86+ exist. In that case the URL will get (?|&)wpDestFile=<filename> appended to
 87+ it as appropriate.
 88+
8689 === New features in 1.16 ===
8790
8891 * Add CSS defintion of the 'wikitable' class to shared.css
@@ -279,6 +282,7 @@
280283 * (bug 21826) Subsections of Special:Version now also have anchors
281284 * (bug 19791) Add URL of file source as comment to thumbs (for ImageMagick)
282285 * (bug 21946) Sorted wikitables do not properly handle minus signs
 286+* (bug 18885) Red links for media files do not support shared repositories
283287
284288 === Bug fixes in 1.16 ===
285289

Follow-up revisions

RevisionCommit summaryAuthorDate
r60979Fix regression from r60593: The title attribute for links to NS_MEDIA titles ...btongminh19:43, 12 January 2010
r69997Fixes for (bug 18885), r60593, r60979: The upload link for missing files can ...btongminh10:31, 27 July 2010

Comments

#Comment by Bryan (talk | contribs)   22:51, 3 January 2010

Patch by Conrad Irwin.

#Comment by OverlordQ (talk | contribs)   01:16, 12 January 2010

Changes parser output.

--- /tmp/mwParser-512819887-expected 2010-01-12 01:14:30.000000000 +0000 +++ /tmp/mwParser-512819887-actual 2010-01-12 01:14:30.000000000 +0000 @@ -1,2 +1,2 @@

-

<a href="https://www.mediawiki.org/index.php?title=Special:Upload&wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a> +

<a href="https://www.mediawiki.org/index.php?title=Special:Upload&wpDestFile=No_such.jpg" class="new" title="Media:No such.jpg">Media:No such.jpg</a>

#Comment by Bryan (talk | contribs)   19:25, 12 January 2010

I debugged a bit, and the problem appears to be that Linker::makeBrokenImageLinkObj is called instead of Linker::makeMediaLinkObj (in r60592). Since this revision does not change the parser, I have no clue why that happens.

#Comment by Bryan (talk | contribs)   19:28, 12 January 2010

Ok, I get it.

#Comment by Bryan (talk | contribs)   19:43, 12 January 2010

Fixed in r60979

#Comment by TheDJ (talk | contribs)   21:53, 26 July 2010

I think we all agree that this isn't working. This should probably all be reverted until a better solution has been created.

#Comment by Bryan (talk | contribs)   19:08, 12 October 2010

Was fixed in follow up revision r69997.

#Comment by Reedy (talk | contribs)   00:17, 7 January 2011

Tested with $wgUseInstantCommons = true;

Can get images from commons, and any other links, where it's not local either, get redlink. Seems to be WFM

RESOLVED

Status & tagging log