r12608 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12607‎ | r12608 | r12609 >
Date:14:01, 11 January 2006
Author:magnus_manske
Status:old
Tags:
Comment:
Page creation now mostly moved from index.php to Wiki.php
Modified paths:
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/index.php (modified) (history)

Diff [purge]

Index: trunk/phase3/index.php
@@ -119,24 +119,15 @@
120120
121121 wfProfileIn( 'main-action' );
122122
 123+# Initialize MediaWiki base class
123124 require_once( "includes/Wiki.php" ) ;
124125 $mediaWiki = new MediaWiki() ;
125126
126127 $mediaWiki->setVal( "Server", $wgServer );
 128+$mediaWiki->setVal( "DisableInternalSearch", $wgDisableInternalSearch );
127129
128 -if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
129 - require_once( 'includes/SpecialSearch.php' );
130 - $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' );
131 - wfSpecialSearch();
132 -} else if( !$wgTitle or $wgTitle->getDBkey() == '' ) {
133 - $wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) );
134 - $wgOut->errorpage( 'badtitle', 'badtitletext' );
135 -} else if ( $mediaWiki->initializeSpecialCases( $wgTitle , $wgOut , $wgRequest , $action ) ) {
136 - # Do nothing, everything was already done by $mediaWiki
 130+if ( !$mediaWiki->initializeSpecialCases( $wgTitle , $wgOut , $wgRequest , $action , $search ) ) {
137131
138 -} else {
139 -
140 -
141132 $wgArticle = $mediaWiki->initializeArticle( $wgTitle, $wgRequest, $action );
142133
143134 if( in_array( $action, $wgDisabledActions ) ) {
Index: trunk/phase3/includes/Wiki.php
@@ -5,14 +5,14 @@
66
77 class MediaWiki {
88
9 - var $GET ; # Stores the $_GET variables at time of creation, can be changed
 9+ var $GET; /* Stores the $_GET variables at time of creation, can be changed */
1010 var $params = array();
1111
1212 /**
1313 * Constructor
1414 */
1515 function MediaWiki () {
16 - $this->GET = $_GET ;
 16+ $this->GET = $_GET;
1717 }
1818
1919 function setVal( $key, &$value ) {
@@ -30,14 +30,22 @@
3131 /**
3232 * Initialize the object to be known as $wgArticle for special cases
3333 */
34 - function initializeSpecialCases ( &$title , &$output , $request , $action ) {
35 - if ( $title->getInterwiki() != '' ) {
 34+ function initializeSpecialCases ( &$title , &$output , $request , $action , &$search ) {
 35+ wfProfileIn( 'MediaWiki::initializeSpecialCases' );
 36+ if( !$this->getVal('DisableInternalSearch') && !is_null( $search ) && $search !== '' ) {
 37+ require_once( 'includes/SpecialSearch.php' );
 38+ $title = Title::makeTitle( NS_SPECIAL, 'Search' );
 39+ wfSpecialSearch();
 40+ } else if( !$title or $title->getDBkey() == '' ) {
 41+ $title = Title::newFromText( wfMsgForContent( 'badtitle' ) );
 42+ $output->errorpage( 'badtitle', 'badtitletext' );
 43+ } else if ( $title->getInterwiki() != '' ) {
3644 if( $rdfrom = $request->getVal( 'rdfrom' ) ) {
3745 $url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) );
3846 } else {
3947 $url = $title->getFullURL();
4048 }
41 - # Check for a redirect loop
 49+ /* Check for a redirect loop */
4250 if ( !preg_match( '/^' . preg_quote( $this->getVal('Server'), '/' ) . '/', $url ) && $title->isLocal() ) {
4351 $output->redirect( $url );
4452 } else {
@@ -52,13 +60,15 @@
5361 $output->setSquidMaxage( 1200 );
5462 $output->redirect( $title->getFullURL(), '301');
5563 } else if ( NS_SPECIAL == $title->getNamespace() ) {
56 - # actions that need to be made when we have a special pages
 64+ /* actions that need to be made when we have a special pages */
5765 SpecialPage::executePath( $title );
5866 } else {
5967 /* No match to special cases */
 68+ wfProfileOut( 'MediaWiki::initializeSpecialCases' );
6069 return false;
6170 }
6271 /* Did match a special case */
 72+ wfProfileOut( 'MediaWiki::initializeSpecialCases' );
6373 return true;
6474 }
6575
@@ -66,6 +76,9 @@
6777 * Initialize the object to be known as $wgArticle for "standard" actions
6878 */
6979 function initializeArticle( &$title, $request, $action ) {
 80+
 81+ wfProfileIn( 'MediaWiki::initializeArticle' );
 82+
7083 if( NS_MEDIA == $title->getNamespace() ) {
7184 $title = Title::makeTitle( NS_IMAGE, $title->getDBkey() );
7285 }
@@ -77,7 +90,7 @@
7891 if( $action == 'view' && !$request->getVal( 'oldid' ) ) {
7992 $rTitle = Title::newFromRedirect( $article->fetchContent() );
8093 if( $rTitle ) {
81 - # Reload from the page pointed to later
 94+ /* Reload from the page pointed to later */
8295 $article->mContentLoaded = false;
8396 $ns = $rTitle->getNamespace();
8497 $wasRedirected = true;
@@ -99,6 +112,7 @@
100113 require_once( 'includes/CategoryPage.php' );
101114 $article = new CategoryPage( $title );
102115 }
 116+ wfProfileOut( 'MediaWiki::initializeArticle' );
103117 return $article;
104118 }
105119
@@ -106,6 +120,9 @@
107121 * Perform one of the "standard" actions
108122 */
109123 function performAction( $action, &$output, &$article, &$title, &$user, &$request ) {
 124+
 125+ wfProfileIn( 'MediaWiki::performAction' );
 126+
110127 switch( $action ) {
111128 case 'view':
112129 $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) );
@@ -151,17 +168,17 @@
152169 break;
153170 case 'submit':
154171 if( !$this->getVal( 'CommandLineMode' ) && !$request->checkSessionCookie() ) {
155 - # Send a cookie so anons get talk message notifications
 172+ /* Send a cookie so anons get talk message notifications */
156173 User::SetupSession();
157174 }
158 - # Continue...
 175+ /* Continue... */
159176 case 'edit':
160177 $internal = $request->getVal( 'internaledit' );
161178 $external = $request->getVal( 'externaledit' );
162179 $section = $request->getVal( 'section' );
163180 $oldid = $request->getVal( 'oldid' );
164181 if( !$this->getVal( 'UseExternalEditor' ) || $action=='submit' || $internal ||
165 - $section || $oldid ||( !$user->getOption( 'externaleditor' ) && !$external ) ) {
 182+ $section || $oldid || ( !$user->getOption( 'externaleditor' ) && !$external ) ) {
166183 require_once( 'includes/EditPage.php' );
167184 $editor = new EditPage( $article );
168185 $editor->submit();
@@ -189,10 +206,12 @@
190207 if( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) {
191208 $output->errorpage( 'nosuchaction', 'nosuchactiontext' );
192209 }
 210+ wfProfileOut( 'MediaWiki::performAction' );
 211+
193212 }
194213 }
195214
196 -}; # End of class MediaWiki
 215+}; /* End of class MediaWiki */
197216
198217 ?>
199218

Status & tagging log