From: Brion Vibber Date: Fri, 13 Jan 2006 17:33:37 +0000 (+0000) Subject: revert to Wiki.php 1.28 and index.php 1.130 X-Git-Tag: 1.6.0~570 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=59b62d1eb774f63e2f6fa09527628605aaf592e8;p=lhc%2Fweb%2Fwiklou.git revert to Wiki.php 1.28 and index.php 1.130 this broke wikipedia. please DO NOT COMMIT BROKEN CODE ON HEAD EVER AGAIN --- diff --git a/includes/Wiki.php b/includes/Wiki.php index 30994a5fd6..996a5cf832 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -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( '$GLOBALS overwrite vulnerability'); - } - } - - /** - * 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 config/LocalSettings.php to the parent directory."; - } else { - $msg = "Please setup the wiki 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 */ diff --git a/index.php b/index.php index eb8531f32d..2a36bcaaea 100644 --- 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( '$GLOBALS overwrite vulnerability'); +} # 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 +?> + + + + MediaWiki <?php echo $wgVersion ?> + + + + + The MediaWiki logo + +

MediaWiki

+
+ config/LocalSettings.php to the parent directory." ); + } else { + echo( "Please setup the wiki first." ); + } + ?> + +
+ + +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 ); ?>