r78938 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78937‎ | r78938 | r78939 >
Date:00:05, 24 December 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Thorough base code comment blocks, will fill more out later
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeRevision.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/CodeRevision.php
@@ -3,6 +3,12 @@
44 class CodeRevision {
55 public $mRepoId, $mRepo, $mId, $mAuthor, $mTimestamp, $mMessage, $mPaths, $mStatus, $mOldStatus, $mCommonPath;
66
 7+ /**
 8+ * @static
 9+ * @param CodeRepository $repo
 10+ * @param $data
 11+ * @return CodeRevision
 12+ */
713 public static function newFromSvn( CodeRepository $repo, $data ) {
814 $rev = new CodeRevision();
915 $rev->mRepoId = $repo->getId();
@@ -62,6 +68,13 @@
6369 return $rev;
6470 }
6571
 72+ /**
 73+ * @static
 74+ * @throws MWException
 75+ * @param CodeRepository $repo
 76+ * @param $row
 77+ * @return CodeRevision
 78+ */
6679 public static function newFromRow( CodeRepository $repo, $row ) {
6780 $rev = new CodeRevision();
6881 $rev->mRepoId = intval( $row->cr_repo_id );
@@ -79,6 +92,9 @@
8093 return $rev;
8194 }
8295
 96+ /**
 97+ * @return int
 98+ */
8399 public function getId() {
84100 return intval( $this->mId );
85101 }
@@ -86,6 +102,7 @@
87103 /**
88104 * Like getId(), but returns the result as a string, including prefix,
89105 * i.e. "r123" instead of 123.
 106+ * @param $id
90107 */
91108 public function getIdString( $id = null ) {
92109 if ( $id === null ) {
@@ -101,6 +118,9 @@
102119 * This ensures you get a unique reference, as the revision ID alone can be
103120 * confusing (e.g. in e-mails, page titles etc.). If only one repository is
104121 * defined then this returns the same as getIdString() as there is no ambiguity.
 122+ *
 123+ * @param null $id
 124+ * @return
105125 */
106126 public function getIdStringUnique( $id = null ) {
107127 if ( $id === null ) {
@@ -109,30 +129,51 @@
110130 return $this->mRepo->getRevIdStringUnique( $id );
111131 }
112132
 133+ /**
 134+ * @return int
 135+ */
113136 public function getRepoId() {
114137 return intval( $this->mRepoId );
115138 }
116139
 140+ /**
 141+ * @return
 142+ */
117143 public function getAuthor() {
118144 return $this->mAuthor;
119145 }
120146
 147+ /**
 148+ * @return
 149+ */
121150 public function getWikiUser() {
122151 return $this->mRepo->authorWikiUser( $this->getAuthor() );
123152 }
124153
 154+ /**
 155+ * @return
 156+ */
125157 public function getTimestamp() {
126158 return $this->mTimestamp;
127159 }
128160
 161+ /**
 162+ * @return
 163+ */
129164 public function getMessage() {
130165 return $this->mMessage;
131166 }
132167
 168+ /**
 169+ * @return
 170+ */
133171 public function getStatus() {
134172 return $this->mStatus;
135173 }
136174
 175+ /**
 176+ * @return
 177+ */
137178 public function getCommonPath() {
138179 return $this->mCommonPath;
139180 }
@@ -234,6 +275,9 @@
235276 }
236277 }
237278
 279+ /**
 280+ * @return void
 281+ */
238282 public function save() {
239283 $dbw = wfGetDB( DB_MASTER );
240284 $dbw->begin();
@@ -420,6 +464,9 @@
421465 return $affectedRevs;
422466 }
423467
 468+ /**
 469+ * @return
 470+ */
424471 public function getModifiedPaths() {
425472 $dbr = wfGetDB( DB_SLAVE );
426473 return $dbr->select(
@@ -430,6 +477,9 @@
431478 );
432479 }
433480
 481+ /**
 482+ * @return bool
 483+ */
434484 public function isDiffable() {
435485 $paths = $this->getModifiedPaths();
436486 if ( !$paths->numRows() || $paths->numRows() > 20 ) {
@@ -438,12 +488,24 @@
439489 return true;
440490 }
441491
 492+ /**
 493+ * @param $text
 494+ * @param $review
 495+ * @param null $parent
 496+ * @return CodeComment
 497+ */
442498 public function previewComment( $text, $review, $parent = null ) {
443499 $data = $this->commentData( $text, $review, $parent );
444500 $data['cc_id'] = null;
445501 return CodeComment::newFromData( $this, $data );
446502 }
447503
 504+ /**
 505+ * @param $text
 506+ * @param $review
 507+ * @param null $parent
 508+ * @return int
 509+ */
448510 public function saveComment( $text, $review, $parent = null ) {
449511 $text = trim( $text );
450512 if ( !strlen( $text ) ) {
@@ -511,6 +573,12 @@
512574 }
513575 }
514576
 577+ /**
 578+ * @param $text
 579+ * @param $review
 580+ * @param null $parent
 581+ * @return array
 582+ */
515583 protected function commentData( $text, $review, $parent = null ) {
516584 global $wgUser;
517585 $dbw = wfGetDB( DB_MASTER );
@@ -528,6 +596,12 @@
529597 'cc_sortkey' => $sortkey );
530598 }
531599
 600+ /**
 601+ * @throws MWException
 602+ * @param $parent
 603+ * @param $ts
 604+ * @return string
 605+ */
532606 protected function threadedSortKey( $parent, $ts ) {
533607 if ( $parent ) {
534608 // We construct a threaded sort key by concatenating the timestamps
@@ -548,6 +622,9 @@
549623 }
550624 }
551625
 626+ /**
 627+ * @return array
 628+ */
552629 public function getComments() {
553630 $dbr = wfGetDB( DB_SLAVE );
554631 $result = $dbr->select( 'code_comment',
@@ -593,6 +670,9 @@
594671 }
595672 }
596673
 674+ /**
 675+ * @return array
 676+ */
597677 public function getPropChanges() {
598678 $dbr = wfGetDB( DB_SLAVE );
599679 $result = $dbr->select( array( 'code_prop_changes', 'user' ),
@@ -619,6 +699,9 @@
620700 return $changes;
621701 }
622702
 703+ /**
 704+ * @return array
 705+ */
623706 public function getPropChangeUsers() {
624707 $dbr = wfGetDB( DB_SLAVE );
625708 $result = $dbr->select( 'code_prop_changes',
@@ -643,6 +726,9 @@
644727 return array_merge( $this->getCommentingUsers(), $this->getPropChangeUsers() );
645728 }
646729
 730+ /**
 731+ * @return array
 732+ */
647733 protected function getCommentingUsers() {
648734 $dbr = wfGetDB( DB_SLAVE );
649735 $res = $dbr->select( 'code_comment',
@@ -712,6 +798,10 @@
713799 $this->addReferences( $data );
714800 }
715801
 802+ /**
 803+ * @param $data
 804+ * @return void
 805+ */
716806 private function addReferences( $data ) {
717807 $dbw = wfGetDB( DB_MASTER );
718808 $dbw->insert( 'code_relations', $data, __METHOD__, array( 'IGNORE' ) );
@@ -814,6 +904,10 @@
815905 }
816906 }
817907
 908+ /**
 909+ * @param int $from
 910+ * @return array
 911+ */
818912 public function getTags( $from = DB_SLAVE ) {
819913 $db = wfGetDB( $from );
820914 $result = $db->select( 'code_tags',
@@ -830,6 +924,12 @@
831925 return $tags;
832926 }
833927
 928+ /**
 929+ * @param $addTags
 930+ * @param $removeTags
 931+ * @param null $user
 932+ * @return void
 933+ */
834934 public function changeTags( $addTags, $removeTags, $user = null ) {
835935 // Get the current tags and see what changes
836936 $tagsNow = $this->getTags( DB_MASTER );
@@ -874,6 +974,10 @@
875975 }
876976 }
877977
 978+ /**
 979+ * @param $tags
 980+ * @return array
 981+ */
878982 protected function normalizeTags( $tags ) {
879983 $out = array();
880984 foreach ( $tags as $tag ) {
@@ -882,6 +986,10 @@
883987 return $out;
884988 }
885989
 990+ /**
 991+ * @param $tags
 992+ * @return array
 993+ */
886994 protected function tagData( $tags ) {
887995 $data = array();
888996 foreach ( $tags as $tag ) {
@@ -894,6 +1002,10 @@
8951003 return $data;
8961004 }
8971005
 1006+ /**
 1007+ * @param $tag
 1008+ * @return bool
 1009+ */
8981010 public function normalizeTag( $tag ) {
8991011 global $wgContLang;
9001012 $lower = $wgContLang->lc( $tag );
@@ -906,10 +1018,18 @@
9071019 }
9081020 }
9091021
 1022+ /**
 1023+ * @param $tag
 1024+ * @return bool
 1025+ */
9101026 public function isValidTag( $tag ) {
9111027 return ( $this->normalizeTag( $tag ) !== false );
9121028 }
9131029
 1030+ /**
 1031+ * @param string $path
 1032+ * @return bool|int
 1033+ */
9141034 public function getPrevious( $path = '' ) {
9151035 $dbr = wfGetDB( DB_SLAVE );
9161036 $encId = $dbr->addQuotes( $this->mId );
@@ -935,6 +1055,10 @@
9361056 }
9371057 }
9381058
 1059+ /**
 1060+ * @param string $path
 1061+ * @return bool|int
 1062+ */
9391063 public function getNext( $path = '' ) {
9401064 $dbr = wfGetDB( DB_SLAVE );
9411065 $encId = $dbr->addQuotes( $this->mId );
@@ -960,6 +1084,10 @@
9611085 }
9621086 }
9631087
 1088+ /**
 1089+ * @param $path
 1090+ * @return array
 1091+ */
9641092 protected function getPathConds( $path ) {
9651093 $dbr = wfGetDB( DB_SLAVE );
9661094 return array(
@@ -973,6 +1101,10 @@
9741102 );
9751103 }
9761104
 1105+ /**
 1106+ * @param string $path
 1107+ * @return bool|int
 1108+ */
9771109 public function getNextUnresolved( $path = '' ) {
9781110 $dbr = wfGetDB( DB_SLAVE );
9791111 $encId = $dbr->addQuotes( $this->mId );
@@ -999,6 +1131,10 @@
10001132 }
10011133 }
10021134
 1135+ /**
 1136+ * @param string $commentId
 1137+ * @return \type
 1138+ */
10031139 public function getFullUrl( $commentId = '' ) {
10041140 $title = SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $this->mId );
10051141
@@ -1009,6 +1145,12 @@
10101146 return $title->getFullUrl();
10111147 }
10121148
 1149+ /**
 1150+ * @param $commentId
 1151+ * @param $text
 1152+ * @param null $url
 1153+ * @return void
 1154+ */
10131155 protected function sendCommentToUDP( $commentId, $text, $url = null ) {
10141156 global $wgCodeReviewUDPAddress, $wgCodeReviewUDPPort, $wgCodeReviewUDPPrefix, $wgLang, $wgUser;
10151157
@@ -1025,6 +1167,11 @@
10261168 }
10271169 }
10281170
 1171+ /**
 1172+ * @param $status
 1173+ * @param $oldStatus
 1174+ * @return void
 1175+ */
10291176 protected function sendStatusToUDP( $status, $oldStatus ) {
10301177 global $wgCodeReviewUDPAddress, $wgCodeReviewUDPPort, $wgCodeReviewUDPPrefix, $wgUser;
10311178

Comments

#Comment by Reedy (talk | contribs)   00:11, 24 December 2010

Placeholders!

That's what I trying to think of the word for :P

Status & tagging log