r12610 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12609‎ | r12610 | r12611 >
Date:14:42, 11 January 2006
Author:magnus_manske
Status:old
Tags:
Comment:
Consolidation of mediaWIki calls into Wiki.php
Modified paths:
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/index.php (modified) (history)

Diff [purge]

Index: trunk/phase3/index.php
@@ -9,7 +9,7 @@
1010 if ( function_exists ( 'getrusage' ) ) {
1111 $wgRUstart = getrusage();
1212 } else {
13 - $wgRUstart = array() ;
 13+ $wgRUstart = array();
1414 }
1515
1616 unset( $IP );
@@ -120,29 +120,22 @@
121121 wfProfileIn( 'main-action' );
122122
123123 # Initialize MediaWiki base class
124 -require_once( "includes/Wiki.php" ) ;
125 -$mediaWiki = new MediaWiki() ;
 124+require_once( "includes/Wiki.php" );
 125+$mediaWiki = new MediaWiki();
126126
127127 $mediaWiki->setVal( "Server", $wgServer );
128128 $mediaWiki->setVal( "DisableInternalSearch", $wgDisableInternalSearch );
 129+$mediaWiki->setVal( "Search", $search );
 130+$mediaWiki->setVal( "action", $action );
 131+$mediaWiki->setVal( "SquidMaxage", $wgSquidMaxage );
 132+$mediaWiki->setVal( "EnableDublinCoreRdf", $wgEnableDublinCoreRdf );
 133+$mediaWiki->setVal( "EnableCreativeCommonsRdf", $wgEnableCreativeCommonsRdf );
 134+$mediaWiki->setVal( "CommandLineMode", $wgCommandLineMode );
 135+$mediaWiki->setVal( "UseExternalEditor", $wgUseExternalEditor );
 136+$mediaWiki->setVal( "DisabledActions", $wgDisabledActions );
129137
130 -if ( !$mediaWiki->initializeSpecialCases( $wgTitle , $wgOut , $wgRequest , $action , $search ) ) {
 138+$wgArticle = $mediaWiki->initialize ( $wgTitle, $wgOut, $wgUser, $wgRequest );
131139
132 - $wgArticle = $mediaWiki->initializeArticle( $wgTitle, $wgRequest, $action );
133 -
134 - if( in_array( $action, $wgDisabledActions ) ) {
135 - $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
136 - } else {
137 - $mediaWiki->setVal( "SquidMaxage", $wgSquidMaxage );
138 - $mediaWiki->setVal( "EnableDublinCoreRdf", $wgEnableDublinCoreRdf );
139 - $mediaWiki->setVal( "EnableCreativeCommonsRdf", $wgEnableCreativeCommonsRdf );
140 - $mediaWiki->setVal( "CommandLineMode", $wgCommandLineMode );
141 - $mediaWiki->setVal( "UseExternalEditor", $wgUseExternalEditor );
142 - $mediaWiki->performAction( $action, $wgOut, $wgArticle, $wgTitle, $wgUser, $wgRequest );
143 - }
144 -
145 -
146 -}
147140 wfProfileOut( 'main-action' );
148141
149142 # Deferred updates aren't really deferred anymore. It's important to report errors to the
Index: trunk/phase3/includes/Wiki.php
@@ -15,10 +15,19 @@
1616 $this->GET = $_GET;
1717 }
1818
 19+ /**
 20+ * Stores key/value pairs to circumvent global variables
 21+ * Note that keys are case-insensitive!
 22+ */
1923 function setVal( $key, &$value ) {
20 - $this->param[strtolower( $key )] = $value;
 24+ $key = strtolower( $key );
 25+ $this->params[$key] =& $value;
2126 }
2227
 28+ /**
 29+ * Retieves key/value pairs to circumvent global variables
 30+ * Note that keys are case-insensitive!
 31+ */
2332 function getVal( $key, $default = "" ) {
2433 $key = strtolower( $key );
2534 if( isset( $this->params[$key] ) ) {
@@ -28,10 +37,29 @@
2938 }
3039
3140 /**
 41+ * Initialization of ... everything
 42+ @return Article either the object to become $wgArticle, or NULL
 43+ */
 44+ function initialize ( &$title, &$output, &$user, $request ) {
 45+ wfProfileIn( 'MediaWiki::initialize' );
 46+ $article = NULL;
 47+ if ( !$this->initializeSpecialCases( $title, $output, $request ) ) {
 48+ $article = $this->initializeArticle( $title, $request );
 49+ $this->performAction( $output, $article, $title, $user, $request );
 50+ }
 51+ wfProfileOut( 'MediaWiki::initialize' );
 52+ return $article;
 53+ }
 54+
 55+ /**
3256 * Initialize the object to be known as $wgArticle for special cases
3357 */
34 - function initializeSpecialCases ( &$title , &$output , $request , $action , &$search ) {
 58+ function initializeSpecialCases ( &$title, &$output, $request ) {
 59+
3560 wfProfileIn( 'MediaWiki::initializeSpecialCases' );
 61+
 62+ $search = $this->getVal('Search');
 63+ $action = $this->getVal('Action');
3664 if( !$this->getVal('DisableInternalSearch') && !is_null( $search ) && $search !== '' ) {
3765 require_once( 'includes/SpecialSearch.php' );
3866 $title = Title::makeTitle( NS_SPECIAL, 'Search' );
@@ -75,9 +103,11 @@
76104 /**
77105 * Initialize the object to be known as $wgArticle for "standard" actions
78106 */
79 - function initializeArticle( &$title, $request, $action ) {
 107+ function initializeArticle( &$title, $request ) {
80108
81109 wfProfileIn( 'MediaWiki::initializeArticle' );
 110+
 111+ $action = $this->getVal('Action');
82112
83113 if( NS_MEDIA == $title->getNamespace() ) {
84114 $title = Title::makeTitle( NS_IMAGE, $title->getDBkey() );
@@ -119,10 +149,16 @@
120150 /**
121151 * Perform one of the "standard" actions
122152 */
123 - function performAction( $action, &$output, &$article, &$title, &$user, &$request ) {
 153+ function performAction( &$output, &$article, &$title, &$user, &$request ) {
124154
125155 wfProfileIn( 'MediaWiki::performAction' );
126156
 157+ $action = $this->getVal('Action');
 158+ if( in_array( $action, $this->getVal('DisabledActions',array()) ) ) {
 159+ /* No such action; this will switch to the default case */
 160+ $action = "nosuchaction";
 161+ }
 162+
127163 switch( $action ) {
128164 case 'view':
129165 $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) );

Status & tagging log