r69094 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69093‎ | r69094 | r69095 >
Date:13:45, 6 July 2010
Author:jojo
Status:resolved (Comments)
Tags:
Comment:
follow redirects in popup code
Modified paths:
  • /trunk/extensions/Collection/Collection.php (modified) (history)
  • /trunk/extensions/Collection/js/bookcreator.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.php
@@ -320,6 +320,12 @@
321321 $json = new Services_JSON();
322322 $result = array();
323323 $imagePath = "$wgScriptPath/extensions/Collection/images";
 324+ $t = Title::newFromText( $title );
 325+ if ( $t->isRedirect() ) {
 326+ $a = new Article( $t, 0 );
 327+ $t = $a->followRedirect();
 328+ $title = $t->getPrefixedText();
 329+ }
324330 if ( CollectionSession::findArticle( $title ) == - 1 ) {
325331 $result['action'] = 'add';
326332 $result['text'] = wfMsg( 'coll-add_linked_article' );
@@ -329,6 +335,7 @@
330336 $result['text'] = wfMsg( 'coll-remove_linked_article' );
331337 $result['img'] = "$imagePath/silk-remove.png";
332338 }
 339+ $result['title'] = $title;
333340 $r = new AjaxResponse( $json->encode( $result ) );
334341 $r->setContentType( 'application/json' );
335342 return $r;
Index: trunk/extensions/Collection/js/bookcreator.js
@@ -106,7 +106,7 @@
107107 .text('\u00a0' + result.text)
108108 .prepend(img)
109109 .unbind('click')
110 - .click(function(e) { addremove_article(result.action, title); });
 110+ .click(function(e) { addremove_article(result.action, result.title); });
111111 popup_div
112112 .css({left: mouse_pos.x + 2 + 'px',
113113 top: mouse_pos.y + 2 + 'px'})

Follow-up revisions

RevisionCommit summaryAuthorDate
r81488Followup r69094: check that $t is a Title before it's used as onecatrope21:27, 3 February 2011

Comments

#Comment by Catrope (talk | contribs)   15:11, 3 February 2011
+		$t = $a->followRedirect();
+		$title = $t->getPrefixedText();

This will throw a fatal error if followRedirect() returns a string (URL) or false, instead of a Title object.

Status & tagging log