Index: trunk/phase3/includes/Revision.php |
— | — | @@ -1,8 +1,4 @@ |
2 | 2 | <?php |
3 | | -/** |
4 | | - * @todo document |
5 | | - * @file |
6 | | - */ |
7 | 3 | |
8 | 4 | /** |
9 | 5 | * @todo document |
— | — | @@ -23,9 +19,8 @@ |
24 | 20 | * Load a page revision from a given revision ID number. |
25 | 21 | * Returns null if no such revision can be found. |
26 | 22 | * |
27 | | - * @param int $id |
28 | | - * @access public |
29 | | - * @static |
| 23 | + * @param $id Integer |
| 24 | + * @return Revision or null |
30 | 25 | */ |
31 | 26 | public static function newFromId( $id ) { |
32 | 27 | return Revision::newFromConds( |
— | — | @@ -38,9 +33,9 @@ |
39 | 34 | * that's attached to a given title. If not attached |
40 | 35 | * to that title, will return null. |
41 | 36 | * |
42 | | - * @param Title $title |
43 | | - * @param int $id |
44 | | - * @return Revision |
| 37 | + * @param $title Title |
| 38 | + * @param $id Integer |
| 39 | + * @return Revision or null |
45 | 40 | */ |
46 | 41 | public static function newFromTitle( $title, $id = 0 ) { |
47 | 42 | $conds = array( |
— | — | @@ -95,10 +90,9 @@ |
96 | 91 | * Load a page revision from a given revision ID number. |
97 | 92 | * Returns null if no such revision can be found. |
98 | 93 | * |
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 |
103 | 97 | */ |
104 | 98 | public static function loadFromId( $db, $id ) { |
105 | 99 | return Revision::loadFromConds( $db, |
— | — | @@ -111,12 +105,10 @@ |
112 | 106 | * that's attached to a given page. If not attached |
113 | 107 | * to that page, will return null. |
114 | 108 | * |
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 |
121 | 113 | */ |
122 | 114 | public static function loadFromPageId( $db, $pageid, $id = 0 ) { |
123 | 115 | $conds = array( 'page_id=rev_page','rev_page' => intval( $pageid ), 'page_id'=>intval( $pageid ) ); |
— | — | @@ -133,12 +125,10 @@ |
134 | 126 | * that's attached to a given page. If not attached |
135 | 127 | * to that page, will return null. |
136 | 128 | * |
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 |
143 | 133 | */ |
144 | 134 | public static function loadFromTitle( $db, $title, $id = 0 ) { |
145 | 135 | if( $id ) { |
— | — | @@ -159,12 +149,10 @@ |
160 | 150 | * WARNING: Timestamps may in some circumstances not be unique, |
161 | 151 | * so this isn't the best key to use. |
162 | 152 | * |
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 |
169 | 157 | */ |
170 | 158 | public static function loadFromTimestamp( $db, $title, $timestamp ) { |
171 | 159 | return Revision::loadFromConds( |
— | — | @@ -178,10 +166,8 @@ |
179 | 167 | /** |
180 | 168 | * Given a set of conditions, fetch a revision. |
181 | 169 | * |
182 | | - * @param array $conditions |
183 | | - * @return Revision |
184 | | - * @access private |
185 | | - * @static |
| 170 | + * @param $conditions Array |
| 171 | + * @return Revision or null |
186 | 172 | */ |
187 | 173 | public static function newFromConds( $conditions ) { |
188 | 174 | $db = wfGetDB( DB_SLAVE ); |
— | — | @@ -197,11 +183,9 @@ |
198 | 184 | * Given a set of conditions, fetch a revision from |
199 | 185 | * the given database connection. |
200 | 186 | * |
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 |
206 | 190 | */ |
207 | 191 | private static function loadFromConds( $db, $conditions ) { |
208 | 192 | $res = Revision::fetchFromConds( $db, $conditions ); |
— | — | @@ -222,10 +206,8 @@ |
223 | 207 | * fetch all of a given page's revisions in turn. |
224 | 208 | * Each row can be fed to the constructor to get objects. |
225 | 209 | * |
226 | | - * @param Title $title |
| 210 | + * @param $title Title |
227 | 211 | * @return ResultWrapper |
228 | | - * @access public |
229 | | - * @static |
230 | 212 | */ |
231 | 213 | public static function fetchRevision( $title ) { |
232 | 214 | return Revision::fetchFromConds( |
— | — | @@ -241,11 +223,9 @@ |
242 | 224 | * which will return matching database rows with the |
243 | 225 | * fields necessary to build Revision objects. |
244 | 226 | * |
245 | | - * @param Database $db |
246 | | - * @param array $conditions |
| 227 | + * @param $db Database |
| 228 | + * @param $conditions Array |
247 | 229 | * @return ResultWrapper |
248 | | - * @access private |
249 | | - * @static |
250 | 230 | */ |
251 | 231 | private static function fetchFromConds( $db, $conditions ) { |
252 | 232 | $fields = self::selectFields(); |
— | — | @@ -305,7 +285,9 @@ |
306 | 286 | } |
307 | 287 | |
308 | 288 | /** |
309 | | - * @param object $row |
| 289 | + * Constructor |
| 290 | + * |
| 291 | + * @param $row Mixed: either a database row or an array |
310 | 292 | * @access private |
311 | 293 | */ |
312 | 294 | function Revision( $row ) { |
— | — | @@ -378,13 +360,10 @@ |
379 | 361 | $this->mUnpatrolled = null; |
380 | 362 | } |
381 | 363 | |
382 | | - /**#@+ |
383 | | - * @access public |
384 | | - */ |
385 | | - |
386 | 364 | /** |
387 | 365 | * Get revision ID |
388 | | - * @return int |
| 366 | + * |
| 367 | + * @return Integer |
389 | 368 | */ |
390 | 369 | public function getId() { |
391 | 370 | return $this->mId; |
— | — | @@ -392,7 +371,8 @@ |
393 | 372 | |
394 | 373 | /** |
395 | 374 | * Get text row ID |
396 | | - * @return int |
| 375 | + * |
| 376 | + * @return Integer |
397 | 377 | */ |
398 | 378 | public function getTextId() { |
399 | 379 | return $this->mTextId; |
— | — | @@ -400,7 +380,8 @@ |
401 | 381 | |
402 | 382 | /** |
403 | 383 | * Get parent revision ID (the original previous page revision) |
404 | | - * @return int |
| 384 | + * |
| 385 | + * @return Integer |
405 | 386 | */ |
406 | 387 | public function getParentId() { |
407 | 388 | return $this->mParentId; |
— | — | @@ -408,7 +389,8 @@ |
409 | 390 | |
410 | 391 | /** |
411 | 392 | * Returns the length of the text in this revision, or null if unknown. |
412 | | - * @return int |
| 393 | + * |
| 394 | + * @return Integer |
413 | 395 | */ |
414 | 396 | public function getSize() { |
415 | 397 | return $this->mSize; |
— | — | @@ -416,6 +398,7 @@ |
417 | 399 | |
418 | 400 | /** |
419 | 401 | * Returns the title of the page associated with this entry. |
| 402 | + * |
420 | 403 | * @return Title |
421 | 404 | */ |
422 | 405 | public function getTitle() { |
— | — | @@ -438,7 +421,8 @@ |
439 | 422 | |
440 | 423 | /** |
441 | 424 | * Set the title of the revision |
442 | | - * @param Title $title |
| 425 | + * |
| 426 | + * @param $title Title |
443 | 427 | */ |
444 | 428 | public function setTitle( $title ) { |
445 | 429 | $this->mTitle = $title; |
— | — | @@ -446,7 +430,8 @@ |
447 | 431 | |
448 | 432 | /** |
449 | 433 | * Get the page ID |
450 | | - * @return int |
| 434 | + * |
| 435 | + * @return Integer |
451 | 436 | */ |
452 | 437 | public function getPage() { |
453 | 438 | return $this->mPage; |
— | — | @@ -457,13 +442,13 @@ |
458 | 443 | * If the specified audience does not have access to it, zero will be |
459 | 444 | * returned. |
460 | 445 | * |
461 | | - * @param integer $audience One of: |
| 446 | + * @param $audience Integer: one of: |
462 | 447 | * Revision::FOR_PUBLIC to be displayed to all users |
463 | 448 | * Revision::FOR_THIS_USER to be displayed to $wgUser |
464 | 449 | * Revision::RAW get the ID regardless of permissions |
465 | 450 | * |
466 | 451 | * |
467 | | - * @return int |
| 452 | + * @return Integer |
468 | 453 | */ |
469 | 454 | public function getUser( $audience = self::FOR_PUBLIC ) { |
470 | 455 | if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_USER ) ) { |
— | — | @@ -477,7 +462,8 @@ |
478 | 463 | |
479 | 464 | /** |
480 | 465 | * Fetch revision's user id without regard for the current user's permissions |
481 | | - * @return string |
| 466 | + * |
| 467 | + * @return String |
482 | 468 | */ |
483 | 469 | public function getRawUser() { |
484 | 470 | return $this->mUser; |
— | — | @@ -488,7 +474,7 @@ |
489 | 475 | * If the specified audience does not have access to the username, an |
490 | 476 | * empty string will be returned. |
491 | 477 | * |
492 | | - * @param integer $audience One of: |
| 478 | + * @param $audience Integer: one of: |
493 | 479 | * Revision::FOR_PUBLIC to be displayed to all users |
494 | 480 | * Revision::FOR_THIS_USER to be displayed to $wgUser |
495 | 481 | * Revision::RAW get the text regardless of permissions |
— | — | @@ -507,7 +493,8 @@ |
508 | 494 | |
509 | 495 | /** |
510 | 496 | * Fetch revision's username without regard for view restrictions |
511 | | - * @return string |
| 497 | + * |
| 498 | + * @return String |
512 | 499 | */ |
513 | 500 | public function getRawUserText() { |
514 | 501 | return $this->mUserText; |
— | — | @@ -518,12 +505,12 @@ |
519 | 506 | * If the specified audience does not have access to the comment, an |
520 | 507 | * empty string will be returned. |
521 | 508 | * |
522 | | - * @param integer $audience One of: |
| 509 | + * @param $audience Integer: one of: |
523 | 510 | * Revision::FOR_PUBLIC to be displayed to all users |
524 | 511 | * Revision::FOR_THIS_USER to be displayed to $wgUser |
525 | 512 | * Revision::RAW get the text regardless of permissions |
526 | 513 | * |
527 | | - * @return string |
| 514 | + * @return String |
528 | 515 | */ |
529 | 516 | function getComment( $audience = self::FOR_PUBLIC ) { |
530 | 517 | if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_COMMENT ) ) { |
— | — | @@ -537,21 +524,22 @@ |
538 | 525 | |
539 | 526 | /** |
540 | 527 | * Fetch revision comment without regard for the current user's permissions |
541 | | - * @return string |
| 528 | + * |
| 529 | + * @return String |
542 | 530 | */ |
543 | 531 | public function getRawComment() { |
544 | 532 | return $this->mComment; |
545 | 533 | } |
546 | 534 | |
547 | 535 | /** |
548 | | - * @return bool |
| 536 | + * @return Boolean |
549 | 537 | */ |
550 | 538 | public function isMinor() { |
551 | 539 | return (bool)$this->mMinorEdit; |
552 | 540 | } |
553 | 541 | |
554 | 542 | /** |
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 |
556 | 544 | */ |
557 | 545 | public function isUnpatrolled() { |
558 | 546 | if( $this->mUnpatrolled !== null ) { |
— | — | @@ -573,7 +561,8 @@ |
574 | 562 | |
575 | 563 | /** |
576 | 564 | * int $field one of DELETED_* bitfield constants |
577 | | - * @return bool |
| 565 | + * |
| 566 | + * @return Boolean |
578 | 567 | */ |
579 | 568 | public function isDeleted( $field ) { |
580 | 569 | return ( $this->mDeleted & $field ) == $field; |
— | — | @@ -581,7 +570,7 @@ |
582 | 571 | |
583 | 572 | /** |
584 | 573 | * Get the deletion bitfield of the revision |
585 | | - */ |
| 574 | + */ |
586 | 575 | public function getVisibility() { |
587 | 576 | return (int)$this->mDeleted; |
588 | 577 | } |
— | — | @@ -591,13 +580,13 @@ |
592 | 581 | * If the specified audience does not have the ability to view this |
593 | 582 | * revision, an empty string will be returned. |
594 | 583 | * |
595 | | - * @param integer $audience One of: |
| 584 | + * @param $audience Integer: one of: |
596 | 585 | * Revision::FOR_PUBLIC to be displayed to all users |
597 | 586 | * Revision::FOR_THIS_USER to be displayed to $wgUser |
598 | 587 | * Revision::RAW get the text regardless of permissions |
599 | 588 | * |
600 | 589 | * |
601 | | - * @return string |
| 590 | + * @return String |
602 | 591 | */ |
603 | 592 | public function getText( $audience = self::FOR_PUBLIC ) { |
604 | 593 | if( $audience == self::FOR_PUBLIC && $this->isDeleted( self::DELETED_TEXT ) ) { |
— | — | @@ -611,6 +600,8 @@ |
612 | 601 | |
613 | 602 | /** |
614 | 603 | * Alias for getText(Revision::FOR_THIS_USER) |
| 604 | + * |
| 605 | + * @return String |
615 | 606 | */ |
616 | 607 | public function revText() { |
617 | 608 | return $this->getText( self::FOR_THIS_USER ); |
— | — | @@ -618,7 +609,8 @@ |
619 | 610 | |
620 | 611 | /** |
621 | 612 | * Fetch revision text without regard for view restrictions |
622 | | - * @return string |
| 613 | + * |
| 614 | + * @return String |
623 | 615 | */ |
624 | 616 | public function getRawText() { |
625 | 617 | if( is_null( $this->mText ) ) { |
— | — | @@ -629,14 +621,14 @@ |
630 | 622 | } |
631 | 623 | |
632 | 624 | /** |
633 | | - * @return string |
| 625 | + * @return String |
634 | 626 | */ |
635 | 627 | public function getTimestamp() { |
636 | | - return wfTimestamp(TS_MW, $this->mTimestamp); |
| 628 | + return wfTimestamp( TS_MW, $this->mTimestamp ); |
637 | 629 | } |
638 | 630 | |
639 | 631 | /** |
640 | | - * @return bool |
| 632 | + * @return Boolean |
641 | 633 | */ |
642 | 634 | public function isCurrent() { |
643 | 635 | return $this->mCurrent; |
— | — | @@ -644,7 +636,8 @@ |
645 | 637 | |
646 | 638 | /** |
647 | 639 | * Get previous revision for this title |
648 | | - * @return Revision |
| 640 | + * |
| 641 | + * @return Revision or null |
649 | 642 | */ |
650 | 643 | public function getPrevious() { |
651 | 644 | if( $this->getTitle() ) { |
— | — | @@ -657,7 +650,9 @@ |
658 | 651 | } |
659 | 652 | |
660 | 653 | /** |
661 | | - * @return Revision |
| 654 | + * Get next revision for this title |
| 655 | + * |
| 656 | + * @return Revision or null |
662 | 657 | */ |
663 | 658 | public function getNext() { |
664 | 659 | if( $this->getTitle() ) { |
— | — | @@ -672,8 +667,9 @@ |
673 | 668 | /** |
674 | 669 | * Get previous revision Id for this page_id |
675 | 670 | * 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 |
678 | 674 | */ |
679 | 675 | private function getPreviousRevisionId( $db ) { |
680 | 676 | if( is_null( $this->mPage ) ) { |
— | — | @@ -698,9 +694,9 @@ |
699 | 695 | * $row is usually an object from wfFetchRow(), both the flags and the text |
700 | 696 | * field must be included |
701 | 697 | * |
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 |
705 | 701 | */ |
706 | 702 | public static function getRevisionText( $row, $prefix = 'old_' ) { |
707 | 703 | wfProfileIn( __METHOD__ ); |
— | — | @@ -774,8 +770,8 @@ |
775 | 771 | * data is compressed, and 'utf-8' if we're saving in UTF-8 |
776 | 772 | * mode. |
777 | 773 | * |
778 | | - * @param mixed $text reference to a text |
779 | | - * @return string |
| 774 | + * @param $text Mixed: reference to a text |
| 775 | + * @return String |
780 | 776 | */ |
781 | 777 | public static function compressRevisionText( &$text ) { |
782 | 778 | global $wgCompressRevisions; |
— | — | @@ -800,8 +796,8 @@ |
801 | 797 | * Insert a new revision into the database, returning the new revision ID |
802 | 798 | * number on success and dies horribly on failure. |
803 | 799 | * |
804 | | - * @param Database $dbw |
805 | | - * @return int |
| 800 | + * @param $dbw DatabaseBase (master connection) |
| 801 | + * @return Integer |
806 | 802 | */ |
807 | 803 | public function insertOn( $dbw ) { |
808 | 804 | global $wgDefaultExternalStore; |
— | — | @@ -852,7 +848,7 @@ |
853 | 849 | 'rev_user_text' => $this->mUserText, |
854 | 850 | 'rev_timestamp' => $dbw->timestamp( $this->mTimestamp ), |
855 | 851 | 'rev_deleted' => $this->mDeleted, |
856 | | - 'rev_len' => $this->mSize, |
| 852 | + 'rev_len' => $this->mSize, |
857 | 853 | 'rev_parent_id' => is_null($this->mParentId) ? |
858 | 854 | $this->getPreviousRevisionId( $dbw ) : $this->mParentId |
859 | 855 | ), __METHOD__ |
— | — | @@ -870,7 +866,7 @@ |
871 | 867 | * Lazy-load the revision's text. |
872 | 868 | * Currently hardcoded to the 'text' table storage engine. |
873 | 869 | * |
874 | | - * @return string |
| 870 | + * @return String |
875 | 871 | */ |
876 | 872 | protected function loadText() { |
877 | 873 | wfProfileIn( __METHOD__ ); |
— | — | @@ -934,11 +930,11 @@ |
935 | 931 | * Such revisions can for instance identify page rename |
936 | 932 | * operations and other such meta-modifications. |
937 | 933 | * |
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 |
943 | 939 | */ |
944 | 940 | public static function newNullRevision( $dbw, $pageId, $summary, $minor ) { |
945 | 941 | wfProfileIn( __METHOD__ ); |
— | — | @@ -972,10 +968,11 @@ |
973 | 969 | /** |
974 | 970 | * Determine if the current user is allowed to view a particular |
975 | 971 | * 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 |
980 | 977 | */ |
981 | 978 | public function userCan( $field ) { |
982 | 979 | return self::userCanBitfield( $this->mDeleted, $field ); |
— | — | @@ -985,11 +982,12 @@ |
986 | 983 | * Determine if the current user is allowed to view a particular |
987 | 984 | * field of this revision, if it's marked as deleted. This is used |
988 | 985 | * 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 |
994 | 992 | */ |
995 | 993 | public static function userCanBitfield( $bitfield, $field ) { |
996 | 994 | if( $bitfield & $field ) { // aspect is deleted |
— | — | @@ -1011,8 +1009,10 @@ |
1012 | 1010 | |
1013 | 1011 | /** |
1014 | 1012 | * 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 |
1017 | 1017 | */ |
1018 | 1018 | static function getTimestampFromId( $title, $id ) { |
1019 | 1019 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -1033,8 +1033,10 @@ |
1034 | 1034 | |
1035 | 1035 | /** |
1036 | 1036 | * 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 |
1039 | 1041 | */ |
1040 | 1042 | static function countByPageId( $db, $id ) { |
1041 | 1043 | $row = $db->selectRow( 'revision', 'COUNT(*) AS revCount', |
— | — | @@ -1047,8 +1049,10 @@ |
1048 | 1050 | |
1049 | 1051 | /** |
1050 | 1052 | * 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 |
1053 | 1057 | */ |
1054 | 1058 | static function countByTitle( $db, $title ) { |
1055 | 1059 | $id = $title->getArticleId(); |