r86848 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86847‎ | r86848 | r86849 >
Date:11:59, 25 April 2011
Author:happy-melon
Status:resolved (Comments)
Tags:
Comment:
Documentation, type-hinting and deprecated functions in Article.php.
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -17,8 +17,12 @@
1818 /**@{{
1919 * @private
2020 */
21 - protected $mContext; // !< RequestContext
2221
 22+ /**
 23+ * @var RequestContext
 24+ */
 25+ protected $mContext;
 26+
2327 var $mContent; // !<
2428 var $mContentLoaded = false; // !<
2529 var $mCounter = -1; // !< Not loaded
@@ -28,19 +32,49 @@
2933 var $mIsRedirect = false; // !<
3034 var $mLatest = false; // !<
3135 var $mOldId; // !<
32 - var $mPreparedEdit = false; // !< Title object if set
33 - var $mRedirectedFrom = null; // !< Title object if set
34 - var $mRedirectTarget = null; // !< Title object if set
 36+ var $mPreparedEdit = false;
 37+
 38+ /**
 39+ * @var Title
 40+ */
 41+ var $mRedirectedFrom = null;
 42+
 43+ /**
 44+ * @var Title
 45+ */
 46+ var $mRedirectTarget = null;
 47+
 48+ /**
 49+ * @var Title
 50+ */
3551 var $mRedirectUrl = false; // !<
3652 var $mRevIdFetched = 0; // !<
37 - var $mLastRevision = null; // !< Latest revision if set
38 - var $mRevision = null; // !< Loaded revision object if set
 53+
 54+ /**
 55+ * @var Revision
 56+ */
 57+ var $mLastRevision = null;
 58+
 59+ /**
 60+ * @var Revision
 61+ */
 62+ var $mRevision = null;
 63+
3964 var $mTimestamp = ''; // !<
4065 var $mTitle; // !< Title object
4166 var $mTotalAdjustment = 0; // !<
4267 var $mTouched = '19700101000000'; // !<
43 - var $mParserOptions; // !< ParserOptions object
44 - var $mParserOutput; // !< ParserCache object if set
 68+
 69+ /**
 70+ * @var ParserOptions
 71+ */
 72+ var $mParserOptions;
 73+
 74+ /**
 75+ * @var ParserOutput
 76+ */
 77+ var $mParserOutput;
 78+
4579 /**@}}*/
4680
4781 /**
@@ -424,7 +458,7 @@
425459
426460 /**
427461 * Fetch a page record with the given conditions
428 - * @param $dbr Database object
 462+ * @param $dbr DatabaseBase object
429463 * @param $conditions Array
430464 * @return mixed Database result resource, or false on failure
431465 */
@@ -444,7 +478,7 @@
445479 * Fetch a page record matching the Title object's namespace and title
446480 * using a sanitized title string
447481 *
448 - * @param $dbr Database object
 482+ * @param $dbr DatabaseBase object
449483 * @param $title Title object
450484 * @return mixed Database result resource, or false on failure
451485 */
@@ -457,7 +491,7 @@
458492 /**
459493 * Fetch a page record matching the requested ID
460494 *
461 - * @param $dbr Database
 495+ * @param $dbr DatabaseBase
462496 * @param $id Integer
463497 * @return mixed Database result resource, or false on failure
464498 */
@@ -469,7 +503,7 @@
470504 * Set the general counter, title etc data loaded from
471505 * some source.
472506 *
473 - * @param $data Database row object or "fromdb"
 507+ * @param $data Object|String $res->fetchObject() object or the string "fromdb" to reload
474508 */
475509 public function loadPageData( $data = 'fromdb' ) {
476510 if ( $data === 'fromdb' ) {
@@ -1225,7 +1259,7 @@
12261260 * @return boolean
12271261 */
12281262 public function showRedirectedFromHeader() {
1229 - global $wgOut, $wgUser, $wgRequest, $wgRedirectSources;
 1263+ global $wgOut, $wgRequest, $wgRedirectSources;
12301264
12311265 $rdfrom = $wgRequest->getVal( 'rdfrom' );
12321266
@@ -1233,7 +1267,7 @@
12341268 // This is an internally redirected page view.
12351269 // We'll need a backlink to the source page for navigation.
12361270 if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
1237 - $redir = $wgUser->getSkin()->link(
 1271+ $redir = Linker::link(
12381272 $this->mRedirectedFrom,
12391273 null,
12401274 array(),
@@ -1261,7 +1295,7 @@
12621296 // This is an externally redirected view, from some other wiki.
12631297 // If it was reported from a trusted site, supply a backlink.
12641298 if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
1265 - $redir = $wgUser->getSkin()->makeExternalLink( $rdfrom, $rdfrom );
 1299+ $redir = Linker::makeExternalLink( $rdfrom, $rdfrom );
12661300 $s = wfMsgExt( 'redirectedfrom', array( 'parseinline', 'replaceafter' ), $redir );
12671301 $wgOut->setSubtitle( $s );
12681302
@@ -1324,7 +1358,6 @@
13251359 return;
13261360 }
13271361
1328 - $sk = $wgUser->getSkin();
13291362 $token = $wgUser->editToken( $rcid );
13301363 $wgOut->preventClickjacking();
13311364
@@ -1332,7 +1365,7 @@
13331366 "<div class='patrollink'>" .
13341367 wfMsgHtml(
13351368 'markaspatrolledlink',
1336 - $sk->link(
 1369+ Linker::link(
13371370 $this->mTitle,
13381371 wfMsgHtml( 'markaspatrolledtext' ),
13391372 array(),
@@ -1550,7 +1583,7 @@
15511584 * @return string containing HMTL with redirect link
15521585 */
15531586 public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
1554 - global $wgOut, $wgContLang, $wgStylePath, $wgUser;
 1587+ global $wgOut, $wgContLang, $wgStylePath;
15551588
15561589 if ( !is_array( $target ) ) {
15571590 $target = array( $target );
@@ -1562,14 +1595,13 @@
15631596 $wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) );
15641597 }
15651598
1566 - $sk = $wgUser->getSkin();
15671599 // the loop prepends the arrow image before the link, so the first case needs to be outside
15681600 $title = array_shift( $target );
15691601
15701602 if ( $forceKnown ) {
1571 - $link = $sk->linkKnown( $title, htmlspecialchars( $title->getFullText() ) );
 1603+ $link = Linker::linkKnown( $title, htmlspecialchars( $title->getFullText() ) );
15721604 } else {
1573 - $link = $sk->link( $title, htmlspecialchars( $title->getFullText() ) );
 1605+ $link = Linker::link( $title, htmlspecialchars( $title->getFullText() ) );
15741606 }
15751607
15761608 $nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
@@ -1578,9 +1610,9 @@
15791611 foreach ( $target as $rt ) {
15801612 $link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) );
15811613 if ( $forceKnown ) {
1582 - $link .= $sk->linkKnown( $rt, htmlspecialchars( $rt->getFullText(), array(), array( 'redirect' => 'no' ) ) );
 1614+ $link .= Linker::linkKnown( $rt, htmlspecialchars( $rt->getFullText(), array(), array( 'redirect' => 'no' ) ) );
15831615 } else {
1584 - $link .= $sk->link( $rt, htmlspecialchars( $rt->getFullText() ), array(), array( 'redirect' => 'no' ) );
 1616+ $link .= Linker::link( $rt, htmlspecialchars( $rt->getFullText() ), array(), array( 'redirect' => 'no' ) );
15851617 }
15861618 }
15871619
@@ -1801,7 +1833,7 @@
18021834 /**
18031835 * Add row to the redirect table if this is a redirect, remove otherwise.
18041836 *
1805 - * @param $dbw Database
 1837+ * @param $dbw DatabaseBase
18061838 * @param $redirectTitle Title object pointing to the redirect target,
18071839 * or NULL if this is not a redirect
18081840 * @param $lastRevIsRedirect If given, will optimize adding and
@@ -2299,7 +2331,7 @@
23002332 if ( in_array( array( 'markedaspatrollederror-noautopatrol' ), $errors ) ) {
23012333 $wgOut->setPageTitle( wfMsg( 'markedaspatrollederror' ) );
23022334 $wgOut->addWikiMsg( 'markedaspatrollederror-noautopatrol' );
2303 - $wgOut->returnToMain( false, $return );
 2335+ $wgOut->returnToMain( null, $return );
23042336
23052337 return;
23062338 }
@@ -2313,7 +2345,7 @@
23142346 # Inform the user
23152347 $wgOut->setPageTitle( wfMsg( 'markedaspatrolled' ) );
23162348 $wgOut->addWikiMsg( 'markedaspatrolledtext', $rc->getTitle()->getPrefixedText() );
2317 - $wgOut->returnToMain( false, $return );
 2349+ $wgOut->returnToMain( null, $return );
23182350 }
23192351
23202352 /**
@@ -2770,12 +2802,11 @@
27712803 if ( $hasHistory && !$confirm ) {
27722804 global $wgLang;
27732805
2774 - $skin = $wgOut->getSkin();
27752806 $revisions = $this->estimateRevisionCount();
27762807 //FIXME: lego
27772808 $wgOut->addHTML( '<strong class="mw-delete-warning-revisions">' .
27782809 wfMsgExt( 'historywarning', array( 'parseinline' ), $wgLang->formatNum( $revisions ) ) .
2779 - wfMsgHtml( 'word-separator' ) . $skin->link( $this->mTitle,
 2810+ wfMsgHtml( 'word-separator' ) . Linker::link( $this->mTitle,
27802811 wfMsgHtml( 'history' ),
27812812 array( 'rel' => 'archives' ),
27822813 array( 'action' => 'history' ) ) .
@@ -2882,7 +2913,7 @@
28832914
28842915 wfDebug( "Article::confirmDelete\n" );
28852916
2886 - $deleteBackLink = $wgOut->getSkin()->linkKnown( $this->mTitle );
 2917+ $deleteBackLink = Linker::linkKnown( $this->mTitle );
28872918 $wgOut->setSubtitle( wfMsgHtml( 'delete-backlink', $deleteBackLink ) );
28882919 $wgOut->setRobotPolicy( 'noindex,nofollow' );
28892920 $wgOut->addWikiMsg( 'confirmdeletetext' );
@@ -2959,9 +2990,8 @@
29602991 Xml::closeElement( 'form' );
29612992
29622993 if ( $wgOut->getUser()->isAllowed( 'editinterface' ) ) {
2963 - $skin = $wgOut->getSkin();
29642994 $title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
2965 - $link = $skin->link(
 2995+ $link = Linker::link(
29662996 $title,
29672997 wfMsgHtml( 'delete-edit-reasonlist' ),
29682998 array(),
@@ -3378,7 +3408,7 @@
33793409
33803410 if ( $current->getComment() != '' ) {
33813411 $wgOut->addWikiMsgArray( 'editcomment', array(
3382 - $wgUser->getSkin()->formatComment( $current->getComment() ) ), array( 'replaceafter' ) );
 3412+ Linker::formatComment( $current->getComment() ) ), array( 'replaceafter' ) );
33833413 }
33843414 }
33853415
@@ -3417,12 +3447,12 @@
34183448 if ( $current->getUserText() === '' ) {
34193449 $old = wfMsg( 'rev-deleted-user' );
34203450 } else {
3421 - $old = $wgUser->getSkin()->userLink( $current->getUser(), $current->getUserText() )
3422 - . $wgUser->getSkin()->userToolLinks( $current->getUser(), $current->getUserText() );
 3451+ $old = Linker::userLink( $current->getUser(), $current->getUserText() )
 3452+ . Linker::userToolLinks( $current->getUser(), $current->getUserText() );
34233453 }
34243454
3425 - $new = $wgUser->getSkin()->userLink( $target->getUser(), $target->getUserText() )
3426 - . $wgUser->getSkin()->userToolLinks( $target->getUser(), $target->getUserText() );
 3455+ $new = Linker::userLink( $target->getUser(), $target->getUserText() )
 3456+ . Linker::userToolLinks( $target->getUser(), $target->getUserText() );
34273457 $wgOut->addHTML( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) );
34283458 $wgOut->returnToMain( false, $this->mTitle );
34293459
@@ -3630,10 +3660,10 @@
36313661 $td = $wgLang->timeanddate( $timestamp, true );
36323662 $tddate = $wgLang->date( $timestamp, true );
36333663 $tdtime = $wgLang->time( $timestamp, true );
3634 - $sk = $wgUser->getSkin();
 3664+
36353665 $lnk = $current
36363666 ? wfMsgHtml( 'currentrevisionlink' )
3637 - : $sk->link(
 3667+ : Linker::link(
36383668 $this->mTitle,
36393669 wfMsgHtml( 'currentrevisionlink' ),
36403670 array(),
@@ -3642,7 +3672,7 @@
36433673 );
36443674 $curdiff = $current
36453675 ? wfMsgHtml( 'diff' )
3646 - : $sk->link(
 3676+ : Linker::link(
36473677 $this->mTitle,
36483678 wfMsgHtml( 'diff' ),
36493679 array(),
@@ -3654,7 +3684,7 @@
36553685 );
36563686 $prev = $this->mTitle->getPreviousRevisionID( $oldid ) ;
36573687 $prevlink = $prev
3658 - ? $sk->link(
 3688+ ? Linker::link(
36593689 $this->mTitle,
36603690 wfMsgHtml( 'previousrevision' ),
36613691 array(),
@@ -3666,7 +3696,7 @@
36673697 )
36683698 : wfMsgHtml( 'previousrevision' );
36693699 $prevdiff = $prev
3670 - ? $sk->link(
 3700+ ? Linker::link(
36713701 $this->mTitle,
36723702 wfMsgHtml( 'diff' ),
36733703 array(),
@@ -3679,7 +3709,7 @@
36803710 : wfMsgHtml( 'diff' );
36813711 $nextlink = $current
36823712 ? wfMsgHtml( 'nextrevision' )
3683 - : $sk->link(
 3713+ : Linker::link(
36843714 $this->mTitle,
36853715 wfMsgHtml( 'nextrevision' ),
36863716 array(),
@@ -3691,7 +3721,7 @@
36923722 );
36933723 $nextdiff = $current
36943724 ? wfMsgHtml( 'diff' )
3695 - : $sk->link(
 3725+ : Linker::link(
36963726 $this->mTitle,
36973727 wfMsgHtml( 'diff' ),
36983728 array(),
@@ -3708,20 +3738,20 @@
37093739 $canHide = $wgUser->isAllowed( 'deleterevision' );
37103740 if ( $canHide || ( $revision->getVisibility() && $wgUser->isAllowed( 'deletedhistory' ) ) ) {
37113741 if ( !$revision->userCan( Revision::DELETED_RESTRICTED ) ) {
3712 - $cdel = $sk->revDeleteLinkDisabled( $canHide ); // rev was hidden from Sysops
 3742+ $cdel = Linker::revDeleteLinkDisabled( $canHide ); // rev was hidden from Sysops
37133743 } else {
37143744 $query = array(
37153745 'type' => 'revision',
37163746 'target' => $this->mTitle->getPrefixedDbkey(),
37173747 'ids' => $oldid
37183748 );
3719 - $cdel = $sk->revDeleteLink( $query, $revision->isDeleted( File::DELETED_RESTRICTED ), $canHide );
 3749+ $cdel = Linker::revDeleteLink( $query, $revision->isDeleted( File::DELETED_RESTRICTED ), $canHide );
37203750 }
37213751 $cdel .= ' ';
37223752 }
37233753
37243754 # Show user links if allowed to see them. If hidden, then show them only if requested...
3725 - $userlinks = $sk->revUserTools( $revision, !$unhide );
 3755+ $userlinks = Linker::revUserTools( $revision, !$unhide );
37263756
37273757 $infomsg = $current && !wfMessage( 'revision-info-current' )->isDisabled()
37283758 ? 'revision-info-current'
@@ -3918,6 +3948,8 @@
39193949
39203950 /**
39213951 * Clears caches when article is deleted
 3952+ *
 3953+ * @param $title Title
39223954 */
39233955 public static function onArticleDelete( $title ) {
39243956 # Update existence markers on article/talk tabs...
@@ -4284,7 +4316,7 @@
42854317 /**
42864318 * Updates cascading protections
42874319 *
4288 - * @param $parserOutput mixed ParserOptions object, or boolean false
 4320+ * @param $parserOutput ParserOutput object, or boolean false
42894321 **/
42904322 protected function doCascadeProtectionUpdates( $parserOutput ) {
42914323 if ( !$this->isCurrent() || wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
@@ -4469,6 +4501,10 @@
44704502 }
44714503
44724504 class PoolWorkArticleView extends PoolCounterWork {
 4505+
 4506+ /**
 4507+ * @var Article
 4508+ */
44734509 private $mArticle;
44744510
44754511 function __construct( $article, $key, $useParserCache, $parserOptions ) {
@@ -4503,6 +4539,9 @@
45044540 return $this->mArticle->tryDirtyCache();
45054541 }
45064542
 4543+ /**
 4544+ * @param $status Status
 4545+ */
45074546 function error( $status ) {
45084547 global $wgOut;
45094548

Sign-offs

UserFlagDate
Platonidesinspected20:25, 26 April 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r90087Fix one bad doc comment entry from r86848brion21:10, 14 June 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   21:09, 14 June 2011
  • mRedirectUrl is labeled as Title, but it actually holds either boolean (false) or string (URL).

Otherwise ok :D

#Comment by Brion VIBBER (talk | contribs)   21:10, 14 June 2011

Fixed in r90087.

Status & tagging log