Index: trunk/phase3/includes/Article.php |
— | — | @@ -17,7 +17,6 @@ |
18 | 18 | /**@{{ |
19 | 19 | * @private |
20 | 20 | */ |
21 | | - var $mComment = ''; // !< |
22 | 21 | var $mContent; // !< |
23 | 22 | var $mContentLoaded = false; // !< |
24 | 23 | var $mCounter = -1; // !< Not loaded |
— | — | @@ -26,20 +25,18 @@ |
27 | 26 | var $mGoodAdjustment = 0; // !< |
28 | 27 | var $mIsRedirect = false; // !< |
29 | 28 | var $mLatest = false; // !< |
30 | | - var $mMinorEdit; // !< |
31 | 29 | var $mOldId; // !< |
32 | 30 | var $mPreparedEdit = false; // !< Title object if set |
33 | 31 | var $mRedirectedFrom = null; // !< Title object if set |
34 | 32 | var $mRedirectTarget = null; // !< Title object if set |
35 | 33 | var $mRedirectUrl = false; // !< |
36 | 34 | var $mRevIdFetched = 0; // !< |
37 | | - var $mRevision = null; // !< Revision object if set |
| 35 | + var $mLastRevision = null; // !< Latest revision if set |
| 36 | + var $mRevision = null; // !< Loaded revision object if set |
38 | 37 | var $mTimestamp = ''; // !< |
39 | 38 | var $mTitle; // !< Title object |
40 | 39 | var $mTotalAdjustment = 0; // !< |
41 | 40 | var $mTouched = '19700101000000'; // !< |
42 | | - var $mUser = -1; // !< Not loaded |
43 | | - var $mUserText = ''; // !< username from Revision if set |
44 | 41 | var $mParserOptions; // !< ParserOptions object |
45 | 42 | var $mParserOutput; // !< ParserCache object if set |
46 | 43 | /**@}}*/ |
— | — | @@ -223,11 +220,11 @@ |
224 | 221 | $this->mDataLoaded = false; |
225 | 222 | $this->mContentLoaded = false; |
226 | 223 | |
227 | | - $this->mUser = $this->mCounter = -1; # Not loaded |
| 224 | + $this->mCounter = -1; # Not loaded |
228 | 225 | $this->mRedirectedFrom = null; # Title object if set |
229 | 226 | $this->mRedirectTarget = null; # Title object if set |
230 | | - $this->mUserText = |
231 | | - $this->mTimestamp = $this->mComment = ''; |
| 227 | + $this->mLastRevision = null; # Latest revision |
| 228 | + $this->mTimestamp = ''; |
232 | 229 | $this->mGoodAdjustment = $this->mTotalAdjustment = 0; |
233 | 230 | $this->mTouched = '19700101000000'; |
234 | 231 | $this->mForUpdate = false; |
— | — | @@ -691,8 +688,8 @@ |
692 | 689 | * This isn't necessary for all uses, so it's only done if needed. |
693 | 690 | */ |
694 | 691 | protected function loadLastEdit() { |
695 | | - if ( -1 != $this->mUser ) { |
696 | | - return; |
| 692 | + if ( $this->mLastRevision !== null ) { |
| 693 | + return; // already loaded |
697 | 694 | } |
698 | 695 | |
699 | 696 | # New or non-existent articles have no user information |
— | — | @@ -702,7 +699,7 @@ |
703 | 700 | } |
704 | 701 | |
705 | 702 | $revision = Revision::loadFromPageId( wfGetDB( DB_MASTER ), $id ); |
706 | | - if ( !is_null( $revision ) ) { |
| 703 | + if ( $revision ) { |
707 | 704 | $this->setLastEdit( $revision ); |
708 | 705 | } |
709 | 706 | } |
— | — | @@ -712,11 +709,7 @@ |
713 | 710 | */ |
714 | 711 | protected function setLastEdit( Revision $revision ) { |
715 | 712 | $this->mLastRevision = $revision; |
716 | | - $this->mUser = $revision->getUser(); |
717 | | - $this->mUserText = $revision->getUserText(); |
718 | 713 | $this->mTimestamp = $revision->getTimestamp(); |
719 | | - $this->mComment = $revision->getComment(); |
720 | | - $this->mMinorEdit = $revision->isMinor(); |
721 | 714 | } |
722 | 715 | |
723 | 716 | /** |
— | — | @@ -727,32 +720,55 @@ |
728 | 721 | if ( !$this->mTimestamp ) { |
729 | 722 | $this->loadLastEdit(); |
730 | 723 | } |
731 | | - |
732 | 724 | return wfTimestamp( TS_MW, $this->mTimestamp ); |
733 | 725 | } |
734 | 726 | |
735 | 727 | /** |
| 728 | + * @param $audience Integer: one of: |
| 729 | + * Revision::FOR_PUBLIC to be displayed to all users |
| 730 | + * Revision::FOR_THIS_USER to be displayed to $wgUser |
| 731 | + * Revision::RAW get the text regardless of permissions |
736 | 732 | * @return int user ID for the user that made the last article revision |
737 | 733 | */ |
738 | | - public function getUser() { |
| 734 | + public function getUser( $audience = Revision::FOR_PUBLIC ) { |
739 | 735 | $this->loadLastEdit(); |
740 | | - return $this->mUser; |
| 736 | + if ( $this->mLastRevision ) { |
| 737 | + return $this->mLastRevision->getUser( $audience ); |
| 738 | + } else { |
| 739 | + return -1; |
| 740 | + } |
741 | 741 | } |
742 | 742 | |
743 | 743 | /** |
| 744 | + * @param $audience Integer: one of: |
| 745 | + * Revision::FOR_PUBLIC to be displayed to all users |
| 746 | + * Revision::FOR_THIS_USER to be displayed to $wgUser |
| 747 | + * Revision::RAW get the text regardless of permissions |
744 | 748 | * @return string username of the user that made the last article revision |
745 | 749 | */ |
746 | | - public function getUserText() { |
| 750 | + public function getUserText( $audience = Revision::FOR_PUBLIC ) { |
747 | 751 | $this->loadLastEdit(); |
748 | | - return $this->mUserText; |
| 752 | + if ( $this->mLastRevision ) { |
| 753 | + return $this->mLastRevision->getUserText( $audience ); |
| 754 | + } else { |
| 755 | + return ''; |
| 756 | + } |
749 | 757 | } |
750 | 758 | |
751 | 759 | /** |
| 760 | + * @param $audience Integer: one of: |
| 761 | + * Revision::FOR_PUBLIC to be displayed to all users |
| 762 | + * Revision::FOR_THIS_USER to be displayed to $wgUser |
| 763 | + * Revision::RAW get the text regardless of permissions |
752 | 764 | * @return string Comment stored for the last article revision |
753 | 765 | */ |
754 | | - public function getComment() { |
| 766 | + public function getComment( $audience = Revision::FOR_PUBLIC ) { |
755 | 767 | $this->loadLastEdit(); |
756 | | - return $this->mComment; |
| 768 | + if ( $this->mLastRevision ) { |
| 769 | + return $this->mLastRevision->getComment( $audience ); |
| 770 | + } else { |
| 771 | + return ''; |
| 772 | + } |
757 | 773 | } |
758 | 774 | |
759 | 775 | /** |
— | — | @@ -762,7 +778,11 @@ |
763 | 779 | */ |
764 | 780 | public function getMinorEdit() { |
765 | 781 | $this->loadLastEdit(); |
766 | | - return $this->mMinorEdit; |
| 782 | + if ( $this->mLastRevision ) { |
| 783 | + return $this->mLastRevision->isMinor(); |
| 784 | + } else { |
| 785 | + return false; |
| 786 | + } |
767 | 787 | } |
768 | 788 | |
769 | 789 | /** |
Index: trunk/extensions/FlaggedRevs/presentation/FlaggedArticleView.php |
— | — | @@ -456,7 +456,7 @@ |
457 | 457 | # Give a "your edit is pending" notice to newer users if |
458 | 458 | # an unreviewed edit was completed... |
459 | 459 | if ( $wgRequest->getVal( 'shownotice' ) |
460 | | - && $this->article->getUserText() == $wgUser->getName() // FIXME: rawUserText? |
| 460 | + && $this->article->getUserText( Revision::RAW ) == $wgUser->getName() |
461 | 461 | && $this->article->revsArePending() |
462 | 462 | && !$wgUser->isAllowed( 'review' ) ) |
463 | 463 | { |