r76700 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76699‎ | r76700 | r76701 >
Date:20:13, 15 November 2010
Author:hashar
Status:ok (Comments)
Tags:
Comment:
Change HistoryPage properties scope to private as well as some obvious functions scopes.
Add a few comments.
Modified paths:
  • /trunk/phase3/includes/HistoryPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HistoryPage.php
@@ -19,7 +19,12 @@
2020 const DIR_PREV = 0;
2121 const DIR_NEXT = 1;
2222
23 - var $article, $title, $skin;
 23+ /** Contains the Article object. Passed on construction. */
 24+ private $article;
 25+ /** The $article title object. Found on construction. */
 26+ private $title;
 27+ /** Shortcut to the user Skin object. */
 28+ private $skin;
2429
2530 /**
2631 * Construct a new HistoryPage.
@@ -34,11 +39,13 @@
3540 $this->preCacheMessages();
3641 }
3742
38 - function getArticle() {
 43+ /** Get the Article object we are working on. */
 44+ public function getArticle() {
3945 return $this->article;
4046 }
4147
42 - function getTitle() {
 48+ /** Get the Title object. */
 49+ public function getTitle() {
4350 return $this->title;
4451 }
4552
@@ -46,7 +53,7 @@
4754 * As we use the same small set of messages in various methods and that
4855 * they are called often, we call them once and save them in $this->message
4956 */
50 - function preCacheMessages() {
 57+ private function preCacheMessages() {
5158 // Precache various messages
5259 if ( !isset( $this->message ) ) {
5360 $msgs = array( 'cur', 'last', 'pipe-separator' );
@@ -63,7 +70,7 @@
6471 function history() {
6572 global $wgOut, $wgRequest, $wgScript;
6673
67 - /*
 74+ /**
6875 * Allow client caching.
6976 */
7077 if ( $wgOut->checkLastModified( $this->article->getTouched() ) )
@@ -71,9 +78,7 @@
7279
7380 wfProfileIn( __METHOD__ );
7481
75 - /*
76 - * Setup page variables.
77 - */
 82+ // Setup page variables.
7883 $wgOut->setPageTitle( wfMsg( 'history-title', $this->title->getPrefixedText() ) );
7984 $wgOut->setPageTitleActionText( wfMsg( 'history_short' ) );
8085 $wgOut->setArticleFlag( false );
@@ -83,6 +88,7 @@
8489 $wgOut->setFeedAppendQuery( 'action=history' );
8590 $wgOut->addModules( array( 'mediawiki.legacy.history', 'mediawiki.views.history' ) );
8691
 92+ // Creation of a subtitle link pointing to [[Special:Log]]
8793 $logPage = SpecialPage::getTitleFor( 'Log' );
8894 $logLink = $this->skin->link(
8995 $logPage,
@@ -93,15 +99,14 @@
94100 );
95101 $wgOut->setSubtitle( $logLink );
96102
 103+ // Handle atom/RSS feeds.
97104 $feedType = $wgRequest->getVal( 'feed' );
98105 if ( $feedType ) {
99106 wfProfileOut( __METHOD__ );
100107 return $this->feed( $feedType );
101108 }
102109
103 - /*
104 - * Fail if article doesn't exist.
105 - */
 110+ // Fail nicely if article doesn't exist.
106111 if ( !$this->title->exists() ) {
107112 $wgOut->addWikiMsg( 'nohistory' );
108113 # show deletion/move log if there is an entry
@@ -123,10 +128,11 @@
124129 /**
125130 * Add date selector to quickly get to a certain time
126131 */
127 - $year = $wgRequest->getInt( 'year' );
128 - $month = $wgRequest->getInt( 'month' );
129 - $tagFilter = $wgRequest->getVal( 'tagfilter' );
 132+ $year = $wgRequest->getInt( 'year' );
 133+ $month = $wgRequest->getInt( 'month' );
 134+ $tagFilter = $wgRequest->getVal( 'tagfilter' );
130135 $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
 136+
131137 /**
132138 * Option to show only revisions that have been (partially) hidden via RevisionDelete
133139 */
@@ -138,6 +144,7 @@
139145 $checkDeleted = Xml::checkLabel( wfMsg( 'history-show-deleted' ),
140146 'deleted', 'mw-show-deleted-only', $wgRequest->getBool( 'deleted' ) ) . "\n";
141147
 148+ // Add the general form
142149 $action = htmlspecialchars( $wgScript );
143150 $wgOut->addHTML(
144151 "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
@@ -157,9 +164,7 @@
158165
159166 wfRunHooks( 'PageHistoryBeforeList', array( &$this->article ) );
160167
161 - /**
162 - * Do the list
163 - */
 168+ // Create and output the list.
164169 $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
165170 $wgOut->addHTML(
166171 $pager->getNavigationBar() .
@@ -232,6 +237,7 @@
233238 }
234239 $items = $this->fetchRevisions( $limit, 0, HistoryPage::DIR_NEXT );
235240
 241+ // Generate feed elements enclosed between header and footer.
236242 $feed->outHeader();
237243 if ( $items ) {
238244 foreach ( $items as $row ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r76707Use accessor when trying to get a private property....hashar21:14, 15 November 2010

Comments

#Comment by Nikerabbit (talk | contribs)   20:40, 15 November 2010

Why private and not protected?

#Comment by Reedy (talk | contribs)   20:43, 15 November 2010

<Reedy> Fatal error: Cannot access private property HistoryPage::$title in /home/reedy/mediawiki/trunk/phase3/includes/HistoryPage.php on line 316

#Comment by Hashar (talk | contribs)   21:15, 15 November 2010

should be fine with r76707, replaced direct property access by its accessor.

#Comment by Catrope (talk | contribs)   22:59, 2 December 2010
-		/*
+		/**

Doxygen-style comments in the middle of a function body make no sense.

Status & tagging log