revert to Wiki.php 1.28 and index.php 1.130
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 13 Jan 2006 17:33:37 +0000 (17:33 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 13 Jan 2006 17:33:37 +0000 (17:33 +0000)
this broke wikipedia. please DO NOT COMMIT BROKEN CODE ON HEAD EVER AGAIN

includes/Wiki.php
index.php

index 30994a5..996a5cf 100644 (file)
@@ -36,74 +36,18 @@ class MediaWiki {
                return $default;
        }
        
-       /**
-        * Wrapper for getrusage, if it exists
-        * getrusage() does not exist on the Window$ platform, catching this
-        */
-       function getRUsage() {
-               if ( function_exists ( 'getrusage' ) ) {
-                       return getrusage();
-               } else {
-                       return array();
-               }
-       }
-       
-       /**
-        * CHeck for $GLOBALS vulnerability
-        */
-       function ckeckGlobalsVulnerability() {
-               @ini_set( 'allow_url_fopen', 0 ); # For security...
-               if ( isset( $_REQUEST['GLOBALS'] ) ) {
-                       die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
-               }
-       }
-       
-       /**
-        * Checks if the wiki is set up at all, or configured but not activated
-        */
-       function checkSetup() {
-               if ( file_exists( './LocalSettings.php' ) ) {
-                       /* LocalSettings exists, commerce normally */
-                       return;
-               }
-               
-               /* LocalSettings is not in the right place, do something */
-               $IP = ".";
-               require_once( 'includes/DefaultSettings.php' ); # used for printing the version
-               $out = file_get_contents( "./setup_message.html" );
-               $out = str_replace( "$1", $wgVersion, $out );
-               if ( file_exists( 'config/LocalSettings.php' ) ) {
-                       $msg = "To complete the installation, move <tt>config/LocalSettings.php</tt> to the parent directory.";
-               } else {
-                       $msg = "Please <a href='config/index.php' title='setup'>setup the wiki</a> first.";
-               }
-               $out = str_replace( "$2", $msg, $out );
-               echo $out;
-               die();
-       }
-       
-       /**
-        * Reads title and action values from request
-        */
-       function initializeActionTitle () {
-               $request = $this->getVal( 'Request' );
-               $this->setVal( 'action', $request->getVal( 'action', 'view' ) );
-               $this->setVal( 'urltitle', $request->getVal( 'title' ) );
-       }
-       
        /**
         * Initialization of ... everything
         @return Article either the object to become $wgArticle, or NULL
         */
-       function initialize ( &$title, &$output, &$user ) {
+       function initialize ( &$title, &$output, &$user, $request) {
                wfProfileIn( 'MediaWiki::initialize' );
-               $request = $this->getVal( 'Request' );
-               $this->preliminaryChecks ( $title, $output );
+               $this->preliminaryChecks ( $title, $output, $request ) ;
                $article = NULL;
-               if ( !$this->initializeSpecialCases( $title, $output ) ) {
-                       $article = $this->initializeArticle( $title );
+               if ( !$this->initializeSpecialCases( $title, $output, $request ) ) {
+                       $article = $this->initializeArticle( $title, $request );
                        if( is_object( $article ) ) {
-                               $this->performAction( $output, $article, $title, $user );
+                               $this->performAction( $output, $article, $title, $user, $request );
                        } elseif( is_string( $article ) ) {
                                $output->redirect( $article );
                        } else {
@@ -116,17 +60,14 @@ class MediaWiki {
        
        /**
         * Checks some initial queries
+        * Note that $title here is *not* a Title object, but a string!
         */
-       function checkInitialQueries( &$output, $lang) {
-               wfProfileIn( 'MediaWiki::checkInitialQueries' );
-               $request = $this->getVal( 'Request' );
-               $action = $this->getVal( 'action' );
-               $title = $this->getVal( 'urltitle' );
+       function checkInitialQueries( $title,$action,&$output,$request, $lang) {
                if ($request->getVal( 'printable' ) == 'yes') {
                        $output->setPrintable();
                }
                
-               $ret = NULL;
+               $ret = NULL ;
                
                
                if ( '' == $title && 'delete' != $action ) {
@@ -143,15 +84,14 @@ class MediaWiki {
                                $lang->findVariantLink( $title, $ret );
                
                }
-               wfProfileOut( 'MediaWiki::checkInitialQueries' );
-               return $ret;
+               return $ret ;
        }
        
        /**
         * Checks for search query and anon-cannot-read case
         */
-       function preliminaryChecks ( &$title, &$output ) {
-               $request = $this->getVal( 'Request' );
+       function preliminaryChecks ( &$title, &$output, $request ) {
+       
                # Debug statement for user levels
                // print_r($wgUser);
                
@@ -177,9 +117,9 @@ class MediaWiki {
        /**
         * Initialize the object to be known as $wgArticle for special cases
         */
-       function initializeSpecialCases ( &$title, &$output ) {
+       function initializeSpecialCases ( &$title, &$output, $request ) {
+
                wfProfileIn( 'MediaWiki::initializeSpecialCases' );
-               $request = $this->getVal( 'Request' );
                
                $search = $this->getVal('Search');
                $action = $this->getVal('Action');
@@ -250,12 +190,13 @@ class MediaWiki {
         * Initialize the object to be known as $wgArticle for "standard" actions
         * Create an Article object for the page, following redirects if needed.
         * @param Title $title
+        * @param Request $request
+        * @param string $action
         * @return mixed an Article, or a string to redirect to another URL
         */
-       function initializeArticle( $title ) {
+       function initializeArticle( $title, $request ) {
                wfProfileIn( 'MediaWiki::initializeArticle' );
                
-               $request = $this->getVal( 'Request' );
                $action = $this->getVal('Action');
                $article = $this->articleFromTitle( $title );
                
@@ -321,10 +262,10 @@ class MediaWiki {
        /**
         * Perform one of the "standard" actions
         */
-       function performAction( &$output, &$article, &$title, &$user ) {
+       function performAction( &$output, &$article, &$title, &$user, &$request ) {
+
                wfProfileIn( 'MediaWiki::performAction' );
-               
-               $request = $this->getVal( 'Request' );
+
                $action = $this->getVal('Action');
                if( in_array( $action, $this->getVal('DisabledActions',array()) ) ) {
                        /* No such action; this will switch to the default case */
index eb8531f..2a36bca 100644 (file)
--- a/index.php
+++ b/index.php
@@ -3,13 +3,21 @@
  * Main wiki script; see docs/design.txt
  * @package MediaWiki
  */
-
-# In the beginning...
-require_once( "./includes/Wiki.php" );
 $wgRequestTime = microtime();
-$wgRUstart = MediaWiki::getRUsage();
+
+# getrusage() does not exist on the Window$ platform, catching this
+if ( function_exists ( 'getrusage' ) ) {
+       $wgRUstart = getrusage();
+} else {
+       $wgRUstart = array();
+}
+
 unset( $IP );
-MediaWiki::ckeckGlobalsVulnerability();
+@ini_set( 'allow_url_fopen', 0 ); # For security...
+
+if ( isset( $_REQUEST['GLOBALS'] ) ) {
+       die( '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>');
+}
 
 # Valid web server entry point, enable includes.
 # Please don't move this line to includes/Defines.php. This line essentially defines
@@ -18,34 +26,74 @@ MediaWiki::ckeckGlobalsVulnerability();
 define( 'MEDIAWIKI', true );
 require_once( './includes/Defines.php' );
 
+if( !file_exists( 'LocalSettings.php' ) ) {
+       $IP = ".";
+       require_once( 'includes/DefaultSettings.php' ); # used for printing the version
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
+       <head>
+               <title>MediaWiki <?php echo $wgVersion ?></title>
+               <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
+               <style type='text/css' media='screen, projection'>
+                       html, body {
+                               color: #000;
+                               background-color: #fff;
+                               font-family: sans-serif;
+                               text-align: center;
+                       }
 
-# Initialize MediaWiki base class
-$mediaWiki = new MediaWiki();
-$mediaWiki->checkSetup();
+                       h1 {
+                               font-size: 150%;
+                       }
+               </style>
+       </head>
+       <body>
+               <img src='skins/common/images/mediawiki.png' alt='The MediaWiki logo' />
+
+               <h1>MediaWiki <?php echo $wgVersion ?></h1>
+               <div class='error'>
+               <?php
+               if ( file_exists( 'config/LocalSettings.php' ) ) {
+                       echo( "To complete the installation, move <tt>config/LocalSettings.php</tt> to the parent directory." );
+               } else {
+                       echo( "Please <a href='config/index.php' title='setup'>setup the wiki</a> first." );
+               }
+               ?>
+
+               </div>
+       </body>
+</html>
+<?php
+       die();
+}
 
-# These can't be done in mdiaWiki.php for some weird reason
 require_once( './LocalSettings.php' );
 require_once( 'includes/Setup.php' );
 
-OutputPage::setEncodings(); # Not really used yet
 
-$mediaWiki->setVal( "Request", $wgRequest );
+# Initialize MediaWiki base class
+require_once( "includes/Wiki.php" );
+$mediaWiki = new MediaWiki();
 
-# Query string fields
-$mediaWiki->initializeActionTitle();
-$action = $mediaWiki->getVal( 'action' ); # Global might be needed somewhere, sadly...
+wfProfileIn( 'main-misc-setup' );
+OutputPage::setEncodings(); # Not really used yet
 
-# Run initial queries
-$wgTitle = $mediaWiki->checkInitialQueries( $wgOut, $wgContLang );
+# Query string fields
+$action = $wgRequest->getVal( 'action', 'view' );
+$title = $wgRequest->getVal( 'title' );
 
-# Is this necessary? Who knows...
+$wgTitle = $mediaWiki->checkInitialQueries( $title,$action,$wgOut, $wgRequest, $wgContLang );
 if ($wgTitle == NULL) {
        unset( $wgTitle );
 }
 
+wfProfileOut( 'main-misc-setup' );
+
 # Setting global variables in mediaWiki
 $mediaWiki->setVal( "Server", $wgServer );
 $mediaWiki->setVal( "DisableInternalSearch", $wgDisableInternalSearch );
+$mediaWiki->setVal( "action", $action );
 $mediaWiki->setVal( "SquidMaxage", $wgSquidMaxage );
 $mediaWiki->setVal( "EnableDublinCoreRdf", $wgEnableDublinCoreRdf );
 $mediaWiki->setVal( "EnableCreativeCommonsRdf", $wgEnableCreativeCommonsRdf );
@@ -53,8 +101,11 @@ $mediaWiki->setVal( "CommandLineMode", $wgCommandLineMode );
 $mediaWiki->setVal( "UseExternalEditor", $wgUseExternalEditor );
 $mediaWiki->setVal( "DisabledActions", $wgDisabledActions );
 
-$wgArticle = $mediaWiki->initialize ( $wgTitle, $wgOut, $wgUser );
+$wgArticle = $mediaWiki->initialize ( $wgTitle, $wgOut, $wgUser, $wgRequest );
 $mediaWiki->finalCleanup ( $wgDeferredUpdateList, $wgLoadBalancer, $wgOut );
+
+# Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup
 $mediaWiki->doUpdates( $wgPostCommitUpdateList );
+
 $mediaWiki->restInPeace( $wgLoadBalancer );
 ?>