* 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 ===
*/
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 );
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
*/
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
*/
$output->errorpage( 'nosuchaction', 'nosuchactiontext' );
}
wfProfileOut( 'MediaWiki::performAction' );
+ }
- }
+
}
}; /* End of class MediaWiki */
}
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 );
$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 );
?>