r95659 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95658‎ | r95659 | r95660 >
Date:12:33, 29 August 2011
Author:catrope
Status:ok
Tags:
Comment:
Switch to using canonical URLs where appropriate in various extensions
* ActiveAbstract: output is stored XML, as I understand it, so use canonical URLs throughout
* AbuseFilter: URLs go into log entries and need to be fully-qualified for the format to work
* EmailCapture: URLs go into e-mails
* SecurePoll: one URL goes to an XML file, make that one canonical. Made the URLs identifying users canonical too, because they would otherwise change when $wgServer is made protocol-relative and possibly break SecurePoll. Of course this means SP might still break if and when we change $wgCanonicalServer to point to HTTPS, but we'll worry about that later
* DoubleWiki: the surrounding code looks scary, but from what I can tell it seems to assume the URL starts with a protocol, then derive some data from it and put it in memcached. That means a canonical URL is needed so the protocol assumption is still valid and the cache isn't polluted
* OAI: use canonical URLs throughout
* LiquidThreads: use canonical URL in e-mail
Modified paths:
  • /trunk/extensions/AbuseFilter/AbuseFilter.class.php (modified) (history)
  • /trunk/extensions/ActiveAbstract/AbstractFilter.php (modified) (history)
  • /trunk/extensions/ActiveAbstract/GoogleCoopFilter.php (modified) (history)
  • /trunk/extensions/DoubleWiki/DoubleWiki_body.php (modified) (history)
  • /trunk/extensions/EmailCapture/api/ApiEmailCapture.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/NewMessagesController.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/View.php (modified) (history)
  • /trunk/extensions/OAI/OAIRepo_body.php (modified) (history)
  • /trunk/extensions/SecurePoll/includes/entities/Election.php (modified) (history)
  • /trunk/extensions/SecurePoll/includes/user/Auth.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/View.php
@@ -161,7 +161,13 @@
162162
163163 return $title->getFullURL( $query );
164164 }
 165+
 166+ static function linkInContextCanonicalURL( $thread, $contextType = 'page' ) {
 167+ list( $title, $query ) = self::linkInContextData( $thread, $contextType );
165168
 169+ return $title->getCanonicalURL( $query );
 170+ }
 171+
166172 static function diffQuery( $thread, $revision ) {
167173 $changed_thread = $revision->getChangeObject();
168174 $curr_rev_id = $changed_thread->rootRevision();
Index: trunk/extensions/LiquidThreads/classes/NewMessagesController.php
@@ -285,7 +285,7 @@
286286 global $wgPasswordSender;
287287 $link_title = clone $t->getTitle();
288288 $link_title->setFragment( '#' . $t->getAnchorName() );
289 - $permalink = LqtView::linkInContextFullURL( $t );
 289+ $permalink = LqtView::linkInContextCanonicalURL( $t );
290290 $talkPage = $t->getTitle()->getPrefixedText();
291291 $from = new MailAddress( $wgPasswordSender, 'WikiAdmin' );
292292 $threadSubject = $t->subject();
Index: trunk/extensions/OAI/OAIRepo_body.php
@@ -550,7 +550,7 @@
551551
552552 function baseUrl() {
553553 $title =& SpecialPage::getTitleFor( 'OAIRepository' );
554 - return $title->getFullUrl();
 554+ return $title->getCanonicalUrl();
555555 }
556556
557557 function earliestDatestamp() {
@@ -839,7 +839,7 @@
840840 oaiTag( 'dc:language', array(), $wgContLanguageCode ) . "\n" .
841841 oaiTag( 'dc:type', array(), 'Text' ) . "\n" .
842842 oaiTag( 'dc:format', array(), $wgMimeType ) . "\n" .
843 - oaiTag( 'dc:identifier', array(), $title->getFullUrl() ) . "\n" .
 843+ oaiTag( 'dc:identifier', array(), $title->getCanonicalUrl() ) . "\n" .
844844 oaiTag( 'dc:contributor', array(), $this->_row->rev_user_text ) . "\n" .
845845 oaiTag( 'dc:date', array(), oaiDatestamp( $this->getDatestamp() ) ) . "\n" .
846846 "</oai_dc:dc>\n";
Index: trunk/extensions/DoubleWiki/DoubleWiki_body.php
@@ -74,7 +74,7 @@
7575 if( $cachedText ) {
7676 $text = $cachedText;
7777 } else {
78 - $url = $nt->getFullURL();
 78+ $url = $nt->getCanonicalURL();
7979 $myURL = $out->getTitle()->getLocalURL();
8080 $languageName = $wgContLang->getLanguageName( $iw );
8181 $myLanguage = $wgLang->getLanguageName( $wgContLang->getCode() );
Index: trunk/extensions/SecurePoll/includes/entities/Election.php
@@ -379,7 +379,7 @@
380380 Xml::element( 'auth', array(), 'local' ) . "\n" .
381381 Xml::element( 'property',
382382 array( 'name' => 'jump-url' ),
383 - $this->context->getSpecialTitle()->getFullURL()
 383+ $this->context->getSpecialTitle()->getCanonicalUrl()
384384 ) . "\n" .
385385 Xml::element( 'property',
386386 array( 'name' => 'jump-id' ),
Index: trunk/extensions/SecurePoll/includes/user/Auth.php
@@ -205,7 +205,7 @@
206206 'name' => $user->getName(),
207207 'type' => 'local',
208208 'domain' => preg_replace( '!.*/(.*)$!', '$1', $wgServer ),
209 - 'url' => $user->getUserPage()->getFullURL(),
 209+ 'url' => $user->getUserPage()->getCanonicalURL(),
210210 'properties' => array(
211211 'wiki' => wfWikiID(),
212212 'blocked' => $user->isBlocked(),
Index: trunk/extensions/EmailCapture/api/ApiEmailCapture.php
@@ -33,8 +33,8 @@
3434 // Send auto-response
3535 global $wgEmailCaptureSendAutoResponse, $wgEmailCaptureAutoResponse;
3636 $title = SpecialPage::getTitleFor( 'EmailCapture' );
37 - $link = $title->getFullURL();
38 - $fullLink = $title->getFullURL( array( 'verify' => $code ) );
 37+ $link = $title->getCanonicalURL();
 38+ $fullLink = $title->getCanonicalURL( array( 'verify' => $code ) );
3939 if ( $wgEmailCaptureSendAutoResponse ) {
4040 UserMailer::send(
4141 new MailAddress( $params['email'] ),
Index: trunk/extensions/AbuseFilter/AbuseFilter.class.php
@@ -1644,12 +1644,12 @@
16451645 static function modifyActionText( $page, $type, $title, $sk, $args ) {
16461646 list( $history_id, $filter_id ) = $args;
16471647
1648 - $filter_link = $sk ? $sk->link( $title ) : $title->getFullURL();
 1648+ $filter_link = $sk ? $sk->link( $title ) : $title->getCanonicalURL();
16491649
16501650 $details_title = SpecialPage::getTitleFor( 'AbuseFilter', "history/$filter_id/diff/prev/$history_id" );
16511651 $details_text = wfMsgExt( 'abusefilter-log-detailslink', 'parseinline' );
16521652 $details_link =
1653 - $sk ? $sk->link( $details_title, $details_text ) : $details_title->getFullURL();
 1653+ $sk ? $sk->link( $details_title, $details_text ) : $details_title->getCanonicalURL();
16541654
16551655 return wfMsgExt( 'abusefilter-log-entry-modify',
16561656 array( 'parseinline', 'replaceafter' ), array( $filter_link, $details_link ) );
Index: trunk/extensions/ActiveAbstract/AbstractFilter.php
@@ -55,7 +55,7 @@
5656
5757 $xml = "<doc>\n";
5858 $xml .= Xml::element( 'title', null, $this->_variant( $title ) ) . "\n";
59 - $xml .= Xml::element( 'url', null, $this->title->getFullUrl() ) . "\n";
 59+ $xml .= Xml::element( 'url', null, $this->title->getCanonicalUrl() ) . "\n";
6060
6161 // add abstract and links when we have revision data...
6262 $this->revision = null;
@@ -216,7 +216,7 @@
217217 $stripped = $this->_stripMarkup( $inside ); // strip internal markup and <h[1-6]>
218218 $header = UtfNormal::cleanUp( $stripped );
219219 $anchor = EditPage::sectionAnchor( $header );
220 - $url = $this->title->getFullUrl() . $anchor;
 220+ $url = $this->title->getCanonicalUrl() . $anchor;
221221 $headers[$header] = $url;
222222 }
223223 return $headers;
@@ -239,7 +239,7 @@
240240 $links = array();
241241 while ( $row = $dbr->fetchObject( $result ) ) {
242242 $category = Title::makeTitle( NS_CATEGORY, $row->cl_to );
243 - $links[$category->getText()] = $category->getFullUrl();
 243+ $links[$category->getText()] = $category->getCanonicalUrl();
244244 }
245245 $dbr->freeResult( $result );
246246
Index: trunk/extensions/ActiveAbstract/GoogleCoopFilter.php
@@ -72,7 +72,7 @@
7373 $xml .= ' ' . Xml::element( 'Output', array( 'name' => 'title' ),
7474 $wgSitename . ':' . $this->title->getPrefixedText() ) . "\n";
7575 $xml .= ' ' . Xml::element( 'Output', array( 'name' => 'more_url' ),
76 - $this->title->getFullUrl() ) . "\n";
 76+ $this->title->getCanonicalUrl() ) . "\n";
7777
7878 // add abstract and links when we have revision data...
7979 $this->revision = null;

Sign-offs

UserFlagDate
Nikerabbitinspected18:52, 29 August 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r959011.17wmf1: MFT HTTPS / prot rel URL fixes: r95627, r95651, r95652, r95653, r95...catrope19:15, 31 August 2011
r964851.18: MFT protocol-relative URL saga: r95014, r95016, r95017, r95627, r95651,...catrope20:14, 7 September 2011

Status & tagging log