From: Magnus Manske Date: Wed, 11 Jan 2006 15:46:01 +0000 (+0000) Subject: Most of index.php now in Wiki.php X-Git-Tag: 1.6.0~599 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=dcae8b53ae0facca05e61a742b6c3c0032b16d57;p=lhc%2Fweb%2Fwiklou.git Most of index.php now in Wiki.php --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index d0b5524d74..17d9f85786 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -460,6 +460,8 @@ fully support the editing toolbar, but was found to be too confusing. * Cleanup and error checking on Special:Listredirects * Clear up some instances of old OutputPage::sysopRequired() function usage * Improve "upload disabled" notice +* Move parts of index.php to include/Wiki.php in an attempt to both cleanup index.php + and create a MediaWiki-class mediaWiki base object === Caveats === diff --git a/includes/Wiki.php b/includes/Wiki.php index 63627838e5..0c8633ef4a 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -42,6 +42,7 @@ class MediaWiki { */ function initialize ( &$title, &$output, &$user, $request ) { wfProfileIn( 'MediaWiki::initialize' ); + $this->preliminaryChecks ( $title , $output , $request ) ; $article = NULL; if ( !$this->initializeSpecialCases( $title, $output, $request ) ) { $article = $this->initializeArticle( $title, $request ); @@ -51,6 +52,30 @@ class MediaWiki { return $article; } + function preliminaryChecks ( &$title , &$output , $request ) { + + # Debug statement for user levels + // print_r($wgUser); + + $search = $request->getText( 'search' ); + if( !is_null( $search ) && $search !== '' ) { + // Compatibility with old search URLs which didn't use Special:Search + // Do this above the read whitelist check for security... + $title = Title::makeTitle( NS_SPECIAL, 'Search' ); + } + $this->setVal( "Search", $search ); + + # If the user is not logged in, the Namespace:title of the article must be in + # the Read array in order for the user to see it. (We have to check here to + # catch special pages etc. We check again in Article::view()) + if ( !is_null( $title ) && !$title->userCanRead() ) { + $output->loginToUse(); + $output->output(); + exit; + } + + } + /** * Initialize the object to be known as $wgArticle for special cases */ @@ -146,6 +171,42 @@ class MediaWiki { return $article; } + /** + * Cleaning up by doing deferred updates, calling loadbalancer and doing the output + */ + function finalCleanup ( &$deferredUpdates , &$loadBalancer , &$output ) { + wfProfileIn( 'MediaWiki::finalCleanup' ); + $this->doUpdates( $deferredUpdates ); + $loadBalancer->saveMasterPos(); + # Now commit any transactions, so that unreported errors after output() don't roll back the whole thing + $loadBalancer->commitAll(); + $output->output(); + wfProfileOut( 'MediaWiki::finalCleanup' ); + } + + /** + * Deferred updates aren't really deferred anymore. It's important to report errors to the + * user, and that means doing this before OutputPage::output(). Note that for page saves, + * the client will wait until the script exits anyway before following the redirect. + */ + function doUpdates ( &$updates ) { + wfProfileIn( 'MediaWiki::doUpdates' ); + foreach( $updates as $up ) { + $up->doUpdate(); + } + wfProfileOut( 'MediaWiki::doUpdates' ); + } + + /** + * Ends this task peacefully + */ + function restInPeace ( &$loadBalancer ) { + wfProfileClose(); + logProfilingData(); + $loadBalancer->closeAll(); + wfDebug( "Request ended normally\n" ); + } + /** * Perform one of the "standard" actions */ @@ -243,8 +304,9 @@ class MediaWiki { $output->errorpage( 'nosuchaction', 'nosuchactiontext' ); } wfProfileOut( 'MediaWiki::performAction' ); + } - } + } }; /* End of class MediaWiki */ diff --git a/index.php b/index.php index 1d8d63e650..883f42d3da 100644 --- a/index.php +++ b/index.php @@ -98,34 +98,14 @@ if ( '' == $title && 'delete' != $action ) { } wfProfileOut( 'main-misc-setup' ); -# Debug statement for user levels -// print_r($wgUser); - -$search = $wgRequest->getText( 'search' ); -if( !is_null( $search ) && $search !== '' ) { - // Compatibility with old search URLs which didn't use Special:Search - // Do this above the read whitelist check for security... - $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' ); -} - -# If the user is not logged in, the Namespace:title of the article must be in -# the Read array in order for the user to see it. (We have to check here to -# catch special pages etc. We check again in Article::view()) -if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) { - $wgOut->loginToUse(); - $wgOut->output(); - exit; -} - -wfProfileIn( 'main-action' ); # Initialize MediaWiki base class require_once( "includes/Wiki.php" ); $mediaWiki = new MediaWiki(); +# Setting global variables in mediaWiki $mediaWiki->setVal( "Server", $wgServer ); $mediaWiki->setVal( "DisableInternalSearch", $wgDisableInternalSearch ); -$mediaWiki->setVal( "Search", $search ); $mediaWiki->setVal( "action", $action ); $mediaWiki->setVal( "SquidMaxage", $wgSquidMaxage ); $mediaWiki->setVal( "EnableDublinCoreRdf", $wgEnableDublinCoreRdf ); @@ -135,34 +115,10 @@ $mediaWiki->setVal( "UseExternalEditor", $wgUseExternalEditor ); $mediaWiki->setVal( "DisabledActions", $wgDisabledActions ); $wgArticle = $mediaWiki->initialize ( $wgTitle, $wgOut, $wgUser, $wgRequest ); +$mediaWiki->finalCleanup ( $wgDeferredUpdateList , $wgLoadBalancer , $wgOut ) ; -wfProfileOut( 'main-action' ); - -# Deferred updates aren't really deferred anymore. It's important to report errors to the -# user, and that means doing this before OutputPage::output(). Note that for page saves, -# the client will wait until the script exits anyway before following the redirect. -wfProfileIn( 'main-updates' ); -foreach( $wgDeferredUpdateList as $up ) { - $up->doUpdate(); -} -wfProfileOut( 'main-updates' ); - -wfProfileIn( 'main-cleanup' ); -$wgLoadBalancer->saveMasterPos(); - -# Now commit any transactions, so that unreported errors after output() don't roll back the whole thing -$wgLoadBalancer->commitAll(); - -$wgOut->output(); - -foreach( $wgPostCommitUpdateList as $up ) { - $up->doUpdate(); -} - -wfProfileOut( 'main-cleanup' ); +# Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup +$mediaWiki->doUpdates( $wgPostCommitUpdateList ); -wfProfileClose(); -logProfilingData(); -$wgLoadBalancer->closeAll(); -wfDebug( "Request ended normally\n" ); +$mediaWiki->restInPeace( $wgLoadBalancer ); ?>