http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95656
Revision: 95656
Author: catrope
Date: 2011-08-29 12:25:07 +0000 (Mon, 29 Aug 2011)
Log Message:
-----------
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
trunk/extensions/CodeReview/tests/CodeReviewTest.php
trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php
Modified: trunk/extensions/CodeReview/backend/CodeRevision.php
===================================================================
--- trunk/extensions/CodeReview/backend/CodeRevision.php 2011-08-29
10:47:44 UTC (rev 95655)
+++ trunk/extensions/CodeReview/backend/CodeRevision.php 2011-08-29
12:25:07 UTC (rev 95656)
@@ -467,13 +467,13 @@
);
// Get repo and build comment title (for url)
- $url = $this->getFullUrl();
+ $url = $this->getCanonicalUrl();
foreach ( $res as $row ) {
$revision = CodeRevision::newFromRow(
$this->repo, $row );
$users = $revision->getCommentingUsers();
- $rowUrl = $revision->getFullUrl();
+ $rowUrl = $revision->getCanonicalUrl();
$revisionAuthor = $revision->getWikiUser();
@@ -652,7 +652,7 @@
$commentId = $dbw->insertId();
$dbw->commit();
- $url = $this->getFullUrl( $commentId );
+ $url = $this->getCanonicalUrl( $commentId );
$this->sendCommentToUDP( $commentId, $text, $url );
@@ -1276,10 +1276,12 @@
}
/**
+ * Get the canonical URL of a revision. Constructs a Title for this
revision
+ * along the lines of [[Special:Code/RepoName/12345#c678]] and calls
getCanonicalUrl().
* @param string $commentId
* @return \type
*/
- public function getFullUrl( $commentId = 0 ) {
+ public function getCanonicalUrl( $commentId = 0 ) {
$title = SpecialPage::getTitleFor( 'Code',
$this->repo->getName() . '/' . $this->id );
# Append comment id if not null, empty string or zero
@@ -1287,7 +1289,7 @@
$title->setFragment( "#c{$commentId}" );
}
- return $title->getFullUrl();
+ return $title->getCanonicalUrl();
}
/**
@@ -1301,7 +1303,7 @@
if( $wgCodeReviewUDPAddress ) {
if( is_null( $url ) ) {
- $url = $this->getFullUrl( $commentId );
+ $url = $this->getCanonicalUrl( $commentId );
}
$line = wfMsg( 'code-rev-message' ) . " \00314(" .
$this->repo->getName() .
@@ -1320,7 +1322,7 @@
global $wgCodeReviewUDPAddress, $wgCodeReviewUDPPort,
$wgCodeReviewUDPPrefix, $wgUser;
if( $wgCodeReviewUDPAddress ) {
- $url = $this->getFullUrl();
+ $url = $this->getCanonicalUrl();
$line = wfMsg( 'code-rev-status' ) . " \00314(" .
$this->repo->getName() .
")\00303 " .
RecentChange::cleanupForIRC( $wgUser->getName() ) . "\003 " .
Modified: trunk/extensions/CodeReview/tests/CodeReviewTest.php
===================================================================
--- trunk/extensions/CodeReview/tests/CodeReviewTest.php 2011-08-29
10:47:44 UTC (rev 95655)
+++ trunk/extensions/CodeReview/tests/CodeReviewTest.php 2011-08-29
12:25:07 UTC (rev 95656)
@@ -41,7 +41,7 @@
// $this->assertEquals( '', $formatter->link( '' ) );
}
- public function testCommentFullUrl() {
+ public function testCommentCanonicalUrl() {
# Fixture:
$repo = $this->createRepo();
$cr = CodeRevision::newFromSvn( $repo, array(
@@ -54,14 +54,14 @@
);
# Find out our revision root URL
- $baseUrl = SpecialPage::getTitleFor( 'Code',
$repo->getName().'/305' )->getFullUrl();
+ $baseUrl = SpecialPage::getTitleFor( 'Code',
$repo->getName().'/305' )->getCanonicalUrl();
# Test revision URL with various comment id:
- $this->assertEquals( $baseUrl, $cr->getFullUrl( '' ) );
- $this->assertEquals( $baseUrl, $cr->getFullUrl( 0 ) );
- $this->assertEquals( $baseUrl, $cr->getFullUrl( null ) );
- $this->assertEquals( $baseUrl, $cr->getFullUrl( "0" ) );
- $this->assertEquals( $baseUrl . '#c777', $cr->getFullUrl( 777
) );
- $this->assertEquals( $baseUrl . '#c777', $cr->getFullUrl( "777"
) );
+ $this->assertEquals( $baseUrl, $cr->getCanonicalUrl( '' ) );
+ $this->assertEquals( $baseUrl, $cr->getCanonicalUrl( 0 ) );
+ $this->assertEquals( $baseUrl, $cr->getCanonicalUrl( null ) );
+ $this->assertEquals( $baseUrl, $cr->getCanonicalUrl( "0" ) );
+ $this->assertEquals( $baseUrl . '#c777', $cr->getCanonicalUrl(
777 ) );
+ $this->assertEquals( $baseUrl . '#c777', $cr->getCanonicalUrl(
"777" ) );
}
}
Modified: trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php
===================================================================
--- trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php 2011-08-29
10:47:44 UTC (rev 95655)
+++ trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php 2011-08-29
12:25:07 UTC (rev 95656)
@@ -118,7 +118,7 @@
$dbw->commit();
if ( $statusChanged || $commentAdded ) {
- $url = $this->mRev->getFullUrl( $commentId );
+ $url = $this->mRev->getCanonicalUrl( $commentId );
if ( $statusChanged && $commentAdded ) {
$this->mRev->emailNotifyUsersOfChanges(
'codereview-email-subj4', 'codereview-email-body4',
$wgUser->getName(),
$this->mRev->getIdStringUnique(), $this->mRev->getOldStatus(),
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs