r95656 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95655‎ | r95656 | r95657 >
Date:12:25, 29 August 2011
Author:catrope
Status:ok
Tags:
Comment:
Rename CodeRevision::getFullUrl() to getCanonicalUrl(), make it behave accordingly, and update callers. I could've left the old getFullUrl() function in, but there was no need to because every caller to getFullUrl() needed a canonical URL instead.
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeRevision.php (modified) (history)
  • /trunk/extensions/CodeReview/tests/CodeReviewTest.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/tests/CodeReviewTest.php
@@ -41,7 +41,7 @@
4242 // $this->assertEquals( '', $formatter->link( '' ) );
4343 }
4444
45 - public function testCommentFullUrl() {
 45+ public function testCommentCanonicalUrl() {
4646 # Fixture:
4747 $repo = $this->createRepo();
4848 $cr = CodeRevision::newFromSvn( $repo, array(
@@ -54,14 +54,14 @@
5555 );
5656
5757 # Find out our revision root URL
58 - $baseUrl = SpecialPage::getTitleFor( 'Code', $repo->getName().'/305' )->getFullUrl();
 58+ $baseUrl = SpecialPage::getTitleFor( 'Code', $repo->getName().'/305' )->getCanonicalUrl();
5959
6060 # Test revision URL with various comment id:
61 - $this->assertEquals( $baseUrl, $cr->getFullUrl( '' ) );
62 - $this->assertEquals( $baseUrl, $cr->getFullUrl( 0 ) );
63 - $this->assertEquals( $baseUrl, $cr->getFullUrl( null ) );
64 - $this->assertEquals( $baseUrl, $cr->getFullUrl( "0" ) );
65 - $this->assertEquals( $baseUrl . '#c777', $cr->getFullUrl( 777 ) );
66 - $this->assertEquals( $baseUrl . '#c777', $cr->getFullUrl( "777" ) );
 61+ $this->assertEquals( $baseUrl, $cr->getCanonicalUrl( '' ) );
 62+ $this->assertEquals( $baseUrl, $cr->getCanonicalUrl( 0 ) );
 63+ $this->assertEquals( $baseUrl, $cr->getCanonicalUrl( null ) );
 64+ $this->assertEquals( $baseUrl, $cr->getCanonicalUrl( "0" ) );
 65+ $this->assertEquals( $baseUrl . '#c777', $cr->getCanonicalUrl( 777 ) );
 66+ $this->assertEquals( $baseUrl . '#c777', $cr->getCanonicalUrl( "777" ) );
6767 }
6868 }
Index: trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php
@@ -118,7 +118,7 @@
119119 $dbw->commit();
120120
121121 if ( $statusChanged || $commentAdded ) {
122 - $url = $this->mRev->getFullUrl( $commentId );
 122+ $url = $this->mRev->getCanonicalUrl( $commentId );
123123 if ( $statusChanged && $commentAdded ) {
124124 $this->mRev->emailNotifyUsersOfChanges( 'codereview-email-subj4', 'codereview-email-body4',
125125 $wgUser->getName(), $this->mRev->getIdStringUnique(), $this->mRev->getOldStatus(),
Index: trunk/extensions/CodeReview/backend/CodeRevision.php
@@ -467,13 +467,13 @@
468468 );
469469
470470 // Get repo and build comment title (for url)
471 - $url = $this->getFullUrl();
 471+ $url = $this->getCanonicalUrl();
472472
473473 foreach ( $res as $row ) {
474474 $revision = CodeRevision::newFromRow( $this->repo, $row );
475475 $users = $revision->getCommentingUsers();
476476
477 - $rowUrl = $revision->getFullUrl();
 477+ $rowUrl = $revision->getCanonicalUrl();
478478
479479 $revisionAuthor = $revision->getWikiUser();
480480
@@ -652,7 +652,7 @@
653653 $commentId = $dbw->insertId();
654654 $dbw->commit();
655655
656 - $url = $this->getFullUrl( $commentId );
 656+ $url = $this->getCanonicalUrl( $commentId );
657657
658658 $this->sendCommentToUDP( $commentId, $text, $url );
659659
@@ -1276,10 +1276,12 @@
12771277 }
12781278
12791279 /**
 1280+ * Get the canonical URL of a revision. Constructs a Title for this revision
 1281+ * along the lines of [[Special:Code/RepoName/12345#c678]] and calls getCanonicalUrl().
12801282 * @param string $commentId
12811283 * @return \type
12821284 */
1283 - public function getFullUrl( $commentId = 0 ) {
 1285+ public function getCanonicalUrl( $commentId = 0 ) {
12841286 $title = SpecialPage::getTitleFor( 'Code', $this->repo->getName() . '/' . $this->id );
12851287
12861288 # Append comment id if not null, empty string or zero
@@ -1287,7 +1289,7 @@
12881290 $title->setFragment( "#c{$commentId}" );
12891291 }
12901292
1291 - return $title->getFullUrl();
 1293+ return $title->getCanonicalUrl();
12921294 }
12931295
12941296 /**
@@ -1301,7 +1303,7 @@
13021304
13031305 if( $wgCodeReviewUDPAddress ) {
13041306 if( is_null( $url ) ) {
1305 - $url = $this->getFullUrl( $commentId );
 1307+ $url = $this->getCanonicalUrl( $commentId );
13061308 }
13071309
13081310 $line = wfMsg( 'code-rev-message' ) . " \00314(" . $this->repo->getName() .
@@ -1320,7 +1322,7 @@
13211323 global $wgCodeReviewUDPAddress, $wgCodeReviewUDPPort, $wgCodeReviewUDPPrefix, $wgUser;
13221324
13231325 if( $wgCodeReviewUDPAddress ) {
1324 - $url = $this->getFullUrl();
 1326+ $url = $this->getCanonicalUrl();
13251327
13261328 $line = wfMsg( 'code-rev-status' ) . " \00314(" . $this->repo->getName() .
13271329 ")\00303 " . RecentChange::cleanupForIRC( $wgUser->getName() ) . "\003 " .

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