r42247 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42246‎ | r42247 | r42248 >
Date:01:43, 20 October 2008
Author:brion
Status:old
Tags:
Comment:
No need for lazy-loading when we always have a repo object to start with :)
Modified paths:
  • /trunk/extensions/CodeReview/CodeRepository.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeReview.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevision.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeRevision.php
@@ -44,10 +44,13 @@
4545 return $rev;
4646 }
4747
48 - static function newFromRow( $row ) {
 48+ static function newFromRow( CodeRepository $repo, $row ) {
4949 $rev = new CodeRevision();
5050 $rev->mRepoId = intval($row->cr_repo_id);
51 - $rev->mRepo = NULL;
 51+ if( $rev->mRepoId != $repo->getId() ) {
 52+ throw new MWException( "Invalid repo ID in " . __METHOD__ );
 53+ }
 54+ $rev->mRepo = $repo;
5255 $rev->mId = intval($row->cr_id);
5356 $rev->mAuthor = $row->cr_author;
5457 $rev->mTimestamp = wfTimestamp( TS_MW, $row->cr_timestamp );
@@ -69,15 +72,8 @@
7073 return $this->mAuthor;
7174 }
7275
73 - function getRepo() {
74 - if( !isset($this->mRepo) ) {
75 - $this->mRepo = CodeRepository::newFromId( $this->mRepoId );
76 - }
77 - return $this->mRepo;
78 - }
79 -
8076 function getWikiUser() {
81 - return $this->getRepo()->authorWikiUser( $this->getAuthor() );
 77+ return $this->mRepo->authorWikiUser( $this->getAuthor() );
8278 }
8379
8480 function getTimestamp() {
@@ -214,7 +210,7 @@
215211 $users[$user->getId()] = $user;
216212 }
217213 // Get repo and build comment title (for url)
218 - $title = SpecialPage::getTitleFor( 'Code', $this->getRepo()->getName().'/'.$this->mId );
 214+ $title = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName().'/'.$this->mId );
219215 $title->setFragment( "#c{$commentId}" );
220216 $url = $title->getFullUrl();
221217 foreach( $users as $userId => $user ) {
@@ -224,7 +220,7 @@
225221 }
226222 if( $user->canReceiveEmail() ) {
227223 $user->sendMail(
228 - wfMsg( 'codereview-email-subj', $this->getRepo()->getName(), $this->mId ),
 224+ wfMsg( 'codereview-email-subj', $this->mRepo->getName(), $this->mId ),
229225 wfMsg( 'codereview-email-body', $wgUser->getName(), $url, $this->mId, $text )
230226 );
231227 }
Index: trunk/extensions/CodeReview/CodeReview.php
@@ -99,4 +99,5 @@
100100 // The name of a repo which represents the code running on this wiki, used to highlight active revisions
101101 $wgWikiSVN = 'MediaWiki';
102102
103 -$wgCodeReviewENotif = true;
 103+// Leave this off by default until it works right
 104+$wgCodeReviewENotif = false;
Index: trunk/extensions/CodeReview/CodeRepository.php
@@ -169,7 +169,7 @@
170170 );
171171 if( !$row )
172172 throw new MWException( 'Failed to load expected revision data' );
173 - return CodeRevision::newFromRow( $row );
 173+ return CodeRevision::newFromRow( $this, $row );
174174 }
175175
176176 /**

Status & tagging log