- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- :CodeReading/MediaWiki/1.10 へ行く。
- 1 (2007-12-30 (日) 02:57:46)
- 2 (2008-02-11 (月) 15:28:58)
- 3 (2008-02-19 (火) 16:35:17)
- 4 (2008-02-19 (火) 16:56:31)
- 5 (2008-02-19 (火) 17:06:46)
- 6 (2008-02-19 (火) 17:19:05)
- 7 (2008-02-19 (火) 17:34:14)
- 8 (2008-02-19 (火) 17:54:03)
- 9 (2008-02-19 (火) 18:53:00)
- 10 (2008-02-19 (火) 18:57:16)
- 11 (2008-02-19 (火) 23:20:24)
- 12 (2008-02-20 (水) 00:42:57)
- 13 (2008-02-20 (水) 00:50:27)
- 14 (2008-02-20 (水) 01:04:14)
- 15 (2008-02-20 (水) 01:10:07)
- 16 (2008-02-20 (水) 11:21:37)
- 17 (2008-02-20 (水) 12:06:01)
- 18 (2008-02-25 (月) 00:41:15)
- 19 (2008-02-25 (月) 00:44:06)
- 20 (2008-02-27 (水) 03:20:01)
- 21 (2008-02-27 (水) 04:43:43)
- 22 (2008-02-27 (水) 04:50:42)
- 23 (2008-02-27 (水) 05:02:39)
- 24 (2008-02-27 (水) 05:05:49)
- 25 (2008-02-27 (水) 05:26:52)
- 26 (2008-02-27 (水) 05:38:59)
- 27 (2008-02-27 (水) 20:41:53)
- 28 (2008-02-28 (木) 00:48:05)
- 29 (2008-02-28 (木) 00:57:57)
- 30 (2008-02-28 (木) 01:03:58)
- 31 (2008-02-28 (木) 01:26:17)
- 32 (2008-02-28 (木) 18:39:01)
- 33 (2008-02-28 (木) 18:53:23)
- 34 (2008-03-11 (火) 04:20:02)
- 35 (2008-11-22 (土) 15:41:13)
- 36 (2008-11-22 (土) 15:51:05)
- 37 (2008-12-07 (日) 17:56:00)
- 38 (2009-01-18 (日) 21:23:00)
- 39 (2009-03-04 (水) 23:43:45)
- 40 (2009-03-14 (土) 15:25:16)
- 41 (2009-08-26 (水) 22:57:32)
- 42 (2009-08-26 (水) 23:08:03)
- 43 (2009-08-30 (日) 11:15:27)
- 44 (2009-09-07 (月) 22:24:14)
- 45 (2009-11-07 (土) 01:15:53)
- 46 (2009-12-12 (土) 13:27:19)
- 47 (2011-12-14 (水) 01:29:17)
- 48 (2013-03-20 (水) 22:31:00)
- 49 (2014-01-23 (木) 02:57:35)
目次 † 
- その他[?]
関連 † 
参考 † 
- MediaWiki Documentation
- http://svn.wikimedia.org/doc/
- The MediaWiki codebase
- http://www.mediawiki.org/wiki/How_to_become_a_MediaWiki_hacker#The_MediaWiki_codebase
WikiEngine/MediaWiki/1.10 † 
主処理への入り口 † 
- index.phpがエントリーポイント。
- なぜかMediaWiki::initializeの中に主処理がある。
index.php > MediaWiki::initialize > MediaWiki::performAction > (URLクエリーの'action'次第で分岐、それぞれの処理へ) - initialize直後にCleanup。
MediaWikiひとめぐり † 
起動から終了までの主な処理を処理順に。
MediaWiki::performActionが処理の中心。
ここで何をするかはMediaWikiの外から与えられるクエリー次第。
- index.php
- includes/Wiki.php(41)
MediaWiki::initialize - includes/Wiki.php(365)
MediaWiki::performAction
※クエリー'action'次第でいろいろ処理。またはOutputPage::redirectを呼び出すことでリダイレクトすることにする(実際の出力は後のOutputPage::outputで)。 - includes/Wiki.php(289)
MediaWiki::finalCleanup - includes/Wiki.php(305)
MediaWiki::doUpdates
$wgDeferredUpdateListに溜め込んだオブジェクト全て->doUpdates
こうして処理タイミングを遅らせているのは、処理間の依存関係を解決するため? - includes/OutputPage.php(553)
OutputPage::output
※スキン適用、HTTPヘッダー・HTMLヘッダー生成、レスポンス出力
action † 
'action'はほとんどMediaWiki(includes/Wiki.php)とArticle(includes/Article.php)で処理される。
それ以外には3つ程度のクラスしか関与しない。
処理の中心になっているのはこれらの数少ないクラスらしい。
'view'というactionは複数のクラスを通して処理される。
'view'はactionのデフォルト値。
MediaWikiが処理する'action' † 
- dublincore
- creativecommons
- credits
Articleが処理する'action' † 
- view *
- watch
- unwatch
- delete
- revert
- rollback
- protect
- unprotect
- info
- markpatrolled
- render
- deletetrackback
- purge
その他 † 
- submit *(editを含む)
- edit *
- history *
- raw ?
action 'view' † 
Articleが処理する。
includes/Article.php:
actionのデフォルト。
クエリーで指示されたページを表示する。
$sk = $wgUser->getSkin(); wfProfileIn( __METHOD__ ); $parserCache =& ParserCache::singleton(); $ns = $this->mTitle->getNamespace(); # shortcut # Get variables from query string $oldid = $this->getOldID(); # getOldID may want us to redirect somewhere else if ( $this->mRedirectUrl ) { $wgOut->redirect( $this->mRedirectUrl ); wfProfileOut( __METHOD__ ); return; } $diff = $wgRequest->getVal( 'diff' ); $rcid = $wgRequest->getVal( 'rcid' ); $rdfrom = $wgRequest->getVal( 'rdfrom' ); $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) ); $wgOut->setArticleFlag( true ); # Discourage indexing of printable versions, but encourage following if( $wgOut->isPrintable() ) { $policy = 'noindex,follow'; } elseif( isset( $wgNamespaceRobotPolicies[$ns] ) ) { # Honour customised robot policies for this namespace $policy = $wgNamespaceRobotPolicies[$ns]; } else { # Default to encourage indexing and following links $policy = 'index,follow'; } $wgOut->setRobotPolicy( $policy ); # If we got diff and oldid in the query, we want to see a # diff page instead of the article. if ( !is_null( $diff ) ) { $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid ); // DifferenceEngine directly fetched the revision: $this->mRevIdFetched = $de->mNewid; $de->showDiffPage( $diffOnly ); // Needed to get the page's current revision $this->loadPageData(); if( $diff == 0 || $diff == $this->mLatest ) { # Run view updates for current revision only $this->viewUpdates(); } wfProfileOut( __METHOD__ ); return; } if ( empty( $oldid ) && $this->checkTouched() ) { $wgOut->setETag($parserCache->getETag($this, $wgUser)); if( $wgOut->checkLastModified( $this->mTouched ) ){ wfProfileOut( __METHOD__ ); return; } else if ( $this->tryFileCache() ) { # tell wgOut that output is taken care of $wgOut->disable(); $this->viewUpdates(); wfProfileOut( __METHOD__ ); return; } } # Should the parser cache be used? $pcache = $wgEnableParserCache && intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 && $this->exists() && empty( $oldid ); wfDebug( 'Article::view using parser cache: ' . ($pcache ? 'yes' : 'no' ) . "\n" ); if ( $wgUser->getOption( 'stubthreshold' ) ) { wfIncrStats( 'pcache_miss_stub' ); } $wasRedirected = false; if ( isset( $this->mRedirectedFrom ) ) { // This is an internally redirected page view. // We'll need a backlink to the source page for navigation. if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) { $sk = $wgUser->getSkin(); $redir = $sk->makeKnownLinkObj( $this->mRedirectedFrom, '', 'redirect=no' ); $s = wfMsg( 'redirectedfrom', $redir ); $wgOut->setSubtitle( $s ); // Set the fragment if one was specified in the redirect if ( strval( $this->mTitle->getFragment() ) != '' ) { $fragment = Xml::escapeJsString( $this->mTitle->getFragmentForURL() ); $wgOut->addInlineScript( "redirectToFragment(\"$fragment\");" ); } $wasRedirected = true; } } elseif ( !empty( $rdfrom ) ) { // This is an externally redirected view, from some other wiki. // If it was reported from a trusted site, supply a backlink. global $wgRedirectSources; if( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) { $sk = $wgUser->getSkin(); $redir = $sk->makeExternalLink( $rdfrom, $rdfrom ); $s = wfMsg( 'redirectedfrom', $redir ); $wgOut->setSubtitle( $s ); $wasRedirected = true; } } $outputDone = false; wfRunHooks( 'ArticleViewHeader', array( &$this ) ); if ( $pcache ) { if ( $wgOut->tryParserCache( $this, $wgUser ) ) { $outputDone = true; } } if ( !$outputDone ) { $text = $this->getContent(); if ( $text === false ) { # Failed to load, replace text with error message $t = $this->mTitle->getPrefixedText(); if( $oldid ) { $t .= ',oldid='.$oldid; $text = wfMsg( 'missingarticle', $t ); } else { $text = wfMsg( 'noarticletext', $t ); } } # Another whitelist check in case oldid is altering the title if ( !$this->mTitle->userCanRead() ) { $wgOut->loginToUse(); $wgOut->output(); exit; } # We're looking at an old revision if ( !empty( $oldid ) ) { $wgOut->setRobotpolicy( 'noindex,nofollow' ); if( is_null( $this->mRevision ) ) { // FIXME: This would be a nice place to load the 'no such page' text. } else { $this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid ); if( $this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { if( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) { $wgOut->addWikiText( wfMsg( 'rev-deleted-text-permission' ) ); $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); return; } else { $wgOut->addWikiText( wfMsg( 'rev-deleted-text-view' ) ); // and we are allowed to see... } } } } } if( !$outputDone ) { $wgOut->setRevisionId( $this->getRevIdFetched() ); # wrap user css and user js in pre and don't parse # XXX: use $this->mTitle->usCssJsSubpage() when php is fixed/ a workaround is found if ( $ns == NS_USER && preg_match('/
/[
w]+
.(?:css|js)$/', $this->mTitle->getDBkey()) ) { $wgOut->addWikiText( wfMsg('clearyourcache')); $wgOut->addHTML( '<pre>'.htmlspecialchars($this->mContent)."\n</pre>" ); } else if ( $rt = Title::newFromRedirect( $text ) ) { # Display redirect $imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr'; $imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png'; # Don't overwrite the subtitle if this was an old revision if( !$wasRedirected && $this->isCurrent() ) { $wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) ); } $link = $sk->makeLinkObj( $rt, $rt->getFullText() ); $wgOut->addHTML( '<img src="'.$imageUrl.'" alt="#REDIRECT " />' . '<span class="redirectText">'.$link.'</span>' ); $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser)); $wgOut->addParserOutputNoText( $parseout ); } else if ( $pcache ) { # Display content and save to parser cache $this->outputWikiText( $text ); } else { # Display content, don't attempt to save to parser cache # Don't show section-edit links on old revisions... this way lies madness. if( !$this->isCurrent() ) { $oldEditSectionSetting = $wgOut->parserOptions()->setEditSection( false ); } # Display content and don't save to parser cache # With timing hack -- TS 2006-07-26 $time = -wfTime(); $this->outputWikiText( $text, false ); $time += wfTime(); # Timing hack if ( $time > 3 ) { wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time, $this->mTitle->getPrefixedDBkey())); } if( !$this->isCurrent() ) { $wgOut->parserOptions()->setEditSection( $oldEditSectionSetting ); } } } /* title may have been set from the cache */ $t = $wgOut->getPageTitle(); if( empty( $t ) ) { $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); } # check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page if( $ns == NS_USER_TALK && User::isIP( $this->mTitle->getText() ) ) { $wgOut->addWikiText( wfMsg('anontalkpagetext') ); } # If we have been passed an &rcid= parameter, we want to give the user a # chance to mark this new article as patrolled. if ( $wgUseRCPatrol && !is_null( $rcid ) && $rcid != 0 && $wgUser->isAllowed( 'patrol' ) ) { $wgOut->addHTML( "<div class='patrollink'>" . wfMsgHtml( 'markaspatrolledlink', $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml('markaspatrolledtext'), "action=markpatrolled&rcid=$rcid" ) ) . '</div>' ); } # Trackbacks if ($wgUseTrackbacks) $this->addTrackbacks(); $this->viewUpdates(); wfProfileOut( __METHOD__ );