r76913 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76912‎ | r76913 | r76914 >
Date:23:00, 17 November 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Remove identical constructor from CodeRevisionCommitter

Make CodeRevisionView constructor take repo name/CodeRepository, and/or revision number/string/CodeRevision
Modified paths:
  • /trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php
@@ -1,12 +1,6 @@
22 <?php
33
44 class CodeRevisionCommitter extends CodeRevisionView {
5 -
6 - function __construct( $repoName, $rev ) {
7 - // Parent should set $this->mRepo, $this->mRev, $this->mReplyTarget
8 - parent::__construct( $repoName, $rev );
9 - }
10 -
115 function execute() {
126 global $wgRequest, $wgOut, $wgUser;
137
Index: trunk/extensions/CodeReview/ui/CodeRevisionView.php
@@ -3,13 +3,29 @@
44 // Special:Code/MediaWiki/40696
55 class CodeRevisionView extends CodeView {
66
7 - function __construct( $repoName, $rev, $replyTarget = null ) {
 7+ /**
 8+ * @param string|CodeRepository $repo
 9+ * @param string|CodeRevision $rev
 10+ * @param null $replyTarget
 11+ *
 12+ */
 13+ function __construct( $repo, $rev, $replyTarget = null ) {
814 global $wgRequest;
915 parent::__construct();
10 - $this->mRepo = CodeRepository::newFromName( $repoName );
11 - $this->mRevId = intval( ltrim( $rev, 'r' ) );
12 - $this->mRev = $this->mRepo ?
13 - $this->mRepo->getRevision( $this->mRevId ) : null;
 16+ $this->mRepo = ( $repo instanceof CodeRepository )
 17+ ? $repo
 18+ : CodeRepository::newFromName( $repo );
 19+
 20+ if ( $rev instanceof CodeRevision ) {
 21+ $this->mRevId = $rev->getId();
 22+ $this->mRev = $rev;
 23+ } else {
 24+ $this->mRevId = intval( ltrim( $rev, 'r' ) );
 25+ $this->mRev = $this->mRepo
 26+ ? $this->mRepo->getRevision( $this->mRevId )
 27+ : null;
 28+ }
 29+
1430 $this->mPreviewText = false;
1531 # Search path for navigation links
1632 $this->mPath = htmlspecialchars( trim( $wgRequest->getVal( 'path' ) ) );

Comments

#Comment by Nikerabbit (talk | contribs)   09:00, 18 November 2010

Spaces fixed in r76921

Status & tagging log