r62090 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62089‎ | r62090 | r62091 >
Date:17:03, 7 February 2010
Author:ialex
Status:ok
Tags:
Comment:
* Fix some doxygen warnings
* Document a bit
Modified paths:
  • /trunk/phase3/includes/Revision.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Revision.php
@@ -1,8 +1,4 @@
22 <?php
3 -/**
4 - * @todo document
5 - * @file
6 - */
73
84 /**
95 * @todo document
@@ -23,9 +19,8 @@
2420 * Load a page revision from a given revision ID number.
2521 * Returns null if no such revision can be found.
2622 *
27 - * @param int $id
28 - * @access public
29 - * @static
 23+ * @param $id Integer
 24+ * @return Revision or null
3025 */
3126 public static function newFromId( $id ) {
3227 return Revision::newFromConds(
@@ -38,9 +33,9 @@
3934 * that's attached to a given title. If not attached
4035 * to that title, will return null.
4136 *
42 - * @param Title $title
43 - * @param int $id
44 - * @return Revision
 37+ * @param $title Title
 38+ * @param $id Integer
 39+ * @return Revision or null
4540 */
4641 public static function newFromTitle( $title, $id = 0 ) {
4742 $conds = array(
@@ -95,10 +90,9 @@
9691 * Load a page revision from a given revision ID number.
9792 * Returns null if no such revision can be found.
9893 *
99 - * @param Database $db
100 - * @param int $id
101 - * @access public
102 - * @static
 94+ * @param $db DatabaseBase
 95+ * @param $id Integer
 96+ * @return Revision or null
10397 */
10498 public static function loadFromId( $db, $id ) {
10599 return Revision::loadFromConds( $db,
@@ -111,12 +105,10 @@
112106 * that's attached to a given page. If not attached
113107 * to that page, will return null.
114108 *
115 - * @param Database $db
116 - * @param int $pageid
117 - * @param int $id
118 - * @return Revision
119 - * @access public
120 - * @static
 109+ * @param $db DatabaseBase
 110+ * @param $pageid Integer
 111+ * @param $id Integer
 112+ * @return Revision or null
121113 */
122114 public static function loadFromPageId( $db, $pageid, $id = 0 ) {
123115 $conds = array( 'page_id=rev_page','rev_page' => intval( $pageid ), 'page_id'=>intval( $pageid ) );
@@ -133,12 +125,10 @@
134126 * that's attached to a given page. If not attached
135127 * to that page, will return null.
136128 *
137 - * @param Database $db
138 - * @param Title $title
139 - * @param int $id
140 - * @return Revision
141 - * @access public
142 - * @static
 129+ * @param $db DatabaseBase
 130+ * @param $title Title
 131+ * @param $id Integer
 132+ * @return Revision or null
143133 */
144134 public static function loadFromTitle( $db, $title, $id = 0 ) {
145135 if( $id ) {
@@ -159,12 +149,10 @@
160150 * WARNING: Timestamps may in some circumstances not be unique,
161151 * so this isn't the best key to use.
162152 *
163 - * @param Database $db
164 - * @param Title $title
165 - * @param string $timestamp
166 - * @return Revision
167 - * @access public
168 - * @static
 153+ * @param $db Database
 154+ * @param $title Title
 155+ * @param $timestamp String
 156+ * @return Revision or null
169157 */
170158 public static function loadFromTimestamp( $db, $title, $timestamp ) {
171159 return Revision::loadFromConds(
@@ -178,10 +166,8 @@
179167 /**
180168 * Given a set of conditions, fetch a revision.
181169 *
182 - * @param array $conditions
183 - * @return Revision
184 - * @access private
185 - * @static
 170+ * @param $conditions Array
 171+ * @return Revision or null
186172 */
187173 public static function newFromConds( $conditions ) {
188174 $db = wfGetDB( DB_SLAVE );
@@ -197,11 +183,9 @@
198184 * Given a set of conditions, fetch a revision from
199185 * the given database connection.
200186 *
201 - * @param Database $db
202 - * @param array $conditions
203 - * @return Revision
204 - * @access private
205 - * @static
 187+ * @param $db Database
 188+ * @param $conditions Array
 189+ * @return Revision or null
206190 */
207191 private static function loadFromConds( $db, $conditions ) {
208192 $res = Revision::fetchFromConds( $db, $conditions );
@@ -222,10 +206,8 @@
223207 * fetch all of a given page's revisions in turn.
224208 * Each row can be fed to the constructor to get objects.
225209 *
226 - * @param Title $title
 210+ * @param $title Title
227211 * @return ResultWrapper
228 - * @access public
229 - * @static
230212 */
231213 public static function fetchRevision( $title ) {
232214 return Revision::fetchFromConds(
@@ -241,11 +223,9 @@
242224 * which will return matching database rows with the
243225 * fields necessary to build Revision objects.
244226 *
245 - * @param Database $db
246 - * @param array $conditions
 227+ * @param $db Database
 228+ * @param $conditions Array
247229 * @return ResultWrapper
248 - * @access private
249 - * @static
250230 */
251231 private static function fetchFromConds( $db, $conditions ) {
252232 $fields = self::selectFields();
@@ -305,7 +285,9 @@
306286 }
307287
308288 /**
309 - * @param object $row
 289+ * Constructor
 290+ *
 291+ * @param $row Mixed: either a database row or an array
310292 * @access private
311293 */
312294 function Revision( $row ) {
@@ -378,13 +360,10 @@
379361 $this->mUnpatrolled = null;
380362 }
381363
382 - /**#@+
383 - * @access public
384 - */
385 -
386364 /**
387365 * Get revision ID
388 - * @return int
 366+ *
 367+ * @return Integer
389368 */
390369 public function getId() {
391370 return $this->mId;
@@ -392,7 +371,8 @@
393372
394373 /**
395374 * Get text row ID
396 - * @return int
 375+ *
 376+ * @return Integer
397377 */
398378 public function getTextId() {
399379 return $this->mTextId;
@@ -400,7 +380,8 @@
401381
402382 /**
403383 * Get parent revision ID (the original previous page revision)
404 - * @return int
 384+ *
 385+ * @return Integer
405386 */
406387 public function getParentId() {
407388 return $this->mParentId;
@@ -408,7 +389,8 @@
409390
410391 /**
411392 * Returns the length of the text in this revision, or null if unknown.
412 - * @return int
 393+ *
 394+ * @return Integer
413395 */
414396 public function getSize() {
415397 return $this->mSize;
@@ -416,6 +398,7 @@
417399
418400 /**
419401 * Returns the title of the page associated with this entry.
 402+ *
420403 * @return Title
421404 */
422405 public function getTitle() {
@@ -438,7 +421,8 @@
439422
440423 /**
441424 * Set the title of the revision
442 - * @param Title $title
 425+ *
 426+ * @param $title Title
443427 */
444428 public function setTitle( $title ) {
445429 $this->mTitle = $title;
@@ -446,7 +430,8 @@
447431
448432 /**
449433 * Get the page ID
450 - * @return int
 434+ *
 435+ * @return Integer
451436 */
452437 public function getPage() {
453438 return $this->mPage;
@@ -457,13 +442,13 @@
458443 * If the specified audience does not have access to it, zero will be
459444 * returned.
460445 *
461 - * @param integer $audience One of:
 446+ * @param $audience Integer: one of:
462447 * Revision::FOR_PUBLIC to be displayed to all users
463448 * Revision::FOR_THIS_USER to be displayed to $wgUser
464449 * Revision::RAW get the ID regardless of permissions
465450 *
466451 *
467 - * @return int
 452+ * @return Integer
468453 */
469454 public function getUser( $audience = self::FOR_PUBLIC ) {
470455 if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) {
@@ -477,7 +462,8 @@
478463
479464 /**
480465 * Fetch revision's user id without regard for the current user's permissions
481 - * @return string
 466+ *
 467+ * @return String
482468 */
483469 public function getRawUser() {
484470 return $this->mUser;
@@ -488,7 +474,7 @@
489475 * If the specified audience does not have access to the username, an
490476 * empty string will be returned.
491477 *
492 - * @param integer $audience One of:
 478+ * @param $audience Integer: one of:
493479 * Revision::FOR_PUBLIC to be displayed to all users
494480 * Revision::FOR_THIS_USER to be displayed to $wgUser
495481 * Revision::RAW get the text regardless of permissions
@@ -507,7 +493,8 @@
508494
509495 /**
510496 * Fetch revision's username without regard for view restrictions
511 - * @return string
 497+ *
 498+ * @return String
512499 */
513500 public function getRawUserText() {
514501 return $this->mUserText;
@@ -518,12 +505,12 @@
519506 * If the specified audience does not have access to the comment, an
520507 * empty string will be returned.
521508 *
522 - * @param integer $audience One of:
 509+ * @param $audience Integer: one of:
523510 * Revision::FOR_PUBLIC to be displayed to all users
524511 * Revision::FOR_THIS_USER to be displayed to $wgUser
525512 * Revision::RAW get the text regardless of permissions
526513 *
527 - * @return string
 514+ * @return String
528515 */
529516 function getComment( $audience = self::FOR_PUBLIC ) {
530517 if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_COMMENT ) ) {
@@ -537,21 +524,22 @@
538525
539526 /**
540527 * Fetch revision comment without regard for the current user's permissions
541 - * @return string
 528+ *
 529+ * @return String
542530 */
543531 public function getRawComment() {
544532 return $this->mComment;
545533 }
546534
547535 /**
548 - * @return bool
 536+ * @return Boolean
549537 */
550538 public function isMinor() {
551539 return (bool)$this->mMinorEdit;
552540 }
553541
554542 /**
555 - * @return int rcid of the unpatrolled row, zero if there isn't one
 543+ * @return Integer rcid of the unpatrolled row, zero if there isn't one
556544 */
557545 public function isUnpatrolled() {
558546 if( $this->mUnpatrolled !== null ) {
@@ -573,7 +561,8 @@
574562
575563 /**
576564 * int $field one of DELETED_* bitfield constants
577 - * @return bool
 565+ *
 566+ * @return Boolean
578567 */
579568 public function isDeleted( $field ) {
580569 return ( $this->mDeleted & $field ) == $field;
@@ -581,7 +570,7 @@
582571
583572 /**
584573 * Get the deletion bitfield of the revision
585 - */
 574+ */
586575 public function getVisibility() {
587576 return (int)$this->mDeleted;
588577 }
@@ -591,13 +580,13 @@
592581 * If the specified audience does not have the ability to view this
593582 * revision, an empty string will be returned.
594583 *
595 - * @param integer $audience One of:
 584+ * @param $audience Integer: one of:
596585 * Revision::FOR_PUBLIC to be displayed to all users
597586 * Revision::FOR_THIS_USER to be displayed to $wgUser
598587 * Revision::RAW get the text regardless of permissions
599588 *
600589 *
601 - * @return string
 590+ * @return String
602591 */
603592 public function getText( $audience = self::FOR_PUBLIC ) {
604593 if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_TEXT ) ) {
@@ -611,6 +600,8 @@
612601
613602 /**
614603 * Alias for getText(Revision::FOR_THIS_USER)
 604+ *
 605+ * @return String
615606 */
616607 public function revText() {
617608 return $this->getText( self::FOR_THIS_USER );
@@ -618,7 +609,8 @@
619610
620611 /**
621612 * Fetch revision text without regard for view restrictions
622 - * @return string
 613+ *
 614+ * @return String
623615 */
624616 public function getRawText() {
625617 if( is_null( $this->mText ) ) {
@@ -629,14 +621,14 @@
630622 }
631623
632624 /**
633 - * @return string
 625+ * @return String
634626 */
635627 public function getTimestamp() {
636 - return wfTimestamp(TS_MW, $this->mTimestamp);
 628+ return wfTimestamp( TS_MW, $this->mTimestamp );
637629 }
638630
639631 /**
640 - * @return bool
 632+ * @return Boolean
641633 */
642634 public function isCurrent() {
643635 return $this->mCurrent;
@@ -644,7 +636,8 @@
645637
646638 /**
647639 * Get previous revision for this title
648 - * @return Revision
 640+ *
 641+ * @return Revision or null
649642 */
650643 public function getPrevious() {
651644 if( $this->getTitle() ) {
@@ -657,7 +650,9 @@
658651 }
659652
660653 /**
661 - * @return Revision
 654+ * Get next revision for this title
 655+ *
 656+ * @return Revision or null
662657 */
663658 public function getNext() {
664659 if( $this->getTitle() ) {
@@ -672,8 +667,9 @@
673668 /**
674669 * Get previous revision Id for this page_id
675670 * This is used to populate rev_parent_id on save
676 - * @param Database $db
677 - * @return int
 671+ *
 672+ * @param $db DatabaseBase
 673+ * @return Integer
678674 */
679675 private function getPreviousRevisionId( $db ) {
680676 if( is_null( $this->mPage ) ) {
@@ -698,9 +694,9 @@
699695 * $row is usually an object from wfFetchRow(), both the flags and the text
700696 * field must be included
701697 *
702 - * @param object $row The text data
703 - * @param string $prefix table prefix (default 'old_')
704 - * @return string $text|false the text requested
 698+ * @param $row Object: the text data
 699+ * @param $prefix String: table prefix (default 'old_')
 700+ * @return String: text the text requested or false on failure
705701 */
706702 public static function getRevisionText( $row, $prefix = 'old_' ) {
707703 wfProfileIn( __METHOD__ );
@@ -774,8 +770,8 @@
775771 * data is compressed, and 'utf-8' if we're saving in UTF-8
776772 * mode.
777773 *
778 - * @param mixed $text reference to a text
779 - * @return string
 774+ * @param $text Mixed: reference to a text
 775+ * @return String
780776 */
781777 public static function compressRevisionText( &$text ) {
782778 global $wgCompressRevisions;
@@ -800,8 +796,8 @@
801797 * Insert a new revision into the database, returning the new revision ID
802798 * number on success and dies horribly on failure.
803799 *
804 - * @param Database $dbw
805 - * @return int
 800+ * @param $dbw DatabaseBase (master connection)
 801+ * @return Integer
806802 */
807803 public function insertOn( $dbw ) {
808804 global $wgDefaultExternalStore;
@@ -852,7 +848,7 @@
853849 'rev_user_text' => $this->mUserText,
854850 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ),
855851 'rev_deleted' => $this->mDeleted,
856 - 'rev_len' => $this->mSize,
 852+ 'rev_len' => $this->mSize,
857853 'rev_parent_id' => is_null($this->mParentId) ?
858854 $this->getPreviousRevisionId( $dbw ) : $this->mParentId
859855 ), __METHOD__
@@ -870,7 +866,7 @@
871867 * Lazy-load the revision's text.
872868 * Currently hardcoded to the 'text' table storage engine.
873869 *
874 - * @return string
 870+ * @return String
875871 */
876872 protected function loadText() {
877873 wfProfileIn( __METHOD__ );
@@ -934,11 +930,11 @@
935931 * Such revisions can for instance identify page rename
936932 * operations and other such meta-modifications.
937933 *
938 - * @param Database $dbw
939 - * @param int $pageId ID number of the page to read from
940 - * @param string $summary
941 - * @param bool $minor
942 - * @return mixed Revision, or null on error
 934+ * @param $dbw DatabaseBase
 935+ * @param $pageId Integer: ID number of the page to read from
 936+ * @param $summary String: revision's summary
 937+ * @param $minor Boolean: whether the revision should be considered as minor
 938+ * @return Mixed: Revision, or null on error
943939 */
944940 public static function newNullRevision( $dbw, $pageId, $summary, $minor ) {
945941 wfProfileIn( __METHOD__ );
@@ -972,10 +968,11 @@
973969 /**
974970 * Determine if the current user is allowed to view a particular
975971 * field of this revision, if it's marked as deleted.
976 - * @param int $field one of self::DELETED_TEXT,
977 - * self::DELETED_COMMENT,
978 - * self::DELETED_USER
979 - * @return bool
 972+ *
 973+ * @param $field Integer:one of self::DELETED_TEXT,
 974+ * self::DELETED_COMMENT,
 975+ * self::DELETED_USER
 976+ * @return Boolean
980977 */
981978 public function userCan( $field ) {
982979 return self::userCanBitfield( $this->mDeleted, $field );
@@ -985,11 +982,12 @@
986983 * Determine if the current user is allowed to view a particular
987984 * field of this revision, if it's marked as deleted. This is used
988985 * by various classes to avoid duplication.
989 - * @param int $bitfield (current field)
990 - * @param int $field one of self::DELETED_TEXT = File::DELETED_FILE,
991 - * self::DELETED_COMMENT = File::DELETED_COMMENT,
992 - * self::DELETED_USER = File::DELETED_USER
993 - * @return bool
 986+ *
 987+ * @param $bitfield Integer: current field
 988+ * @param $field Integer: one of self::DELETED_TEXT = File::DELETED_FILE,
 989+ * self::DELETED_COMMENT = File::DELETED_COMMENT,
 990+ * self::DELETED_USER = File::DELETED_USER
 991+ * @return Boolean
994992 */
995993 public static function userCanBitfield( $bitfield, $field ) {
996994 if( $bitfield & $field ) { // aspect is deleted
@@ -1011,8 +1009,10 @@
10121010
10131011 /**
10141012 * Get rev_timestamp from rev_id, without loading the rest of the row
1015 - * @param Title $title
1016 - * @param integer $id
 1013+ *
 1014+ * @param $title Title
 1015+ * @param $id Integer
 1016+ * @return String
10171017 */
10181018 static function getTimestampFromId( $title, $id ) {
10191019 $dbr = wfGetDB( DB_SLAVE );
@@ -1033,8 +1033,10 @@
10341034
10351035 /**
10361036 * Get count of revisions per page...not very efficient
1037 - * @param Database $db
1038 - * @param int $id, page id
 1037+ *
 1038+ * @param $db DatabaseBase
 1039+ * @param $id Integer: page id
 1040+ * @return Integer
10391041 */
10401042 static function countByPageId( $db, $id ) {
10411043 $row = $db->selectRow( 'revision', 'COUNT(*) AS revCount',
@@ -1047,8 +1049,10 @@
10481050
10491051 /**
10501052 * Get count of revisions per page...not very efficient
1051 - * @param Database $db
1052 - * @param Title $title
 1053+ *
 1054+ * @param $db DatabaseBase
 1055+ * @param $title Title
 1056+ * @return Integer
10531057 */
10541058 static function countByTitle( $db, $title ) {
10551059 $id = $title->getArticleId();

Status & tagging log