- $ns = $wgTitle->getNamespace();
-
- // Namespace might change when using redirects
- if($action == 'view' && !$wgRequest->getVal( 'oldid' ) ) {
- $wgArticle = new Article( $wgTitle );
- $rTitle = Title::newFromRedirect( $wgArticle->fetchContent() );
- if($rTitle) {
- # Reload from the page pointed to later
- $wgArticle->mContentLoaded = false;
- $ns = $rTitle->getNamespace();
- }
- }
-
- // Categories and images are handled by a different class
- if ( $ns == NS_IMAGE ) {
- unset($wgArticle);
- require_once( 'includes/ImagePage.php' );
- $wgArticle = new ImagePage( $wgTitle );
- } elseif ( $wgUseCategoryMagic && $ns == NS_CATEGORY ) {
- unset($wgArticle);
- require_once( 'includes/CategoryPage.php' );
- $wgArticle = new CategoryPage( $wgTitle );
- }
-
- if ( in_array( $action, $wgDisabledActions ) ) {
- $wgOut->setStatusCode( 404 );
- $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
- } else {
- switch( $action ) {
- case 'view':
- $wgOut->setSquidMaxage( $wgSquidMaxage );
- $wgArticle->view();
- break;
- case 'watch':
- case 'unwatch':
- case 'delete':
- case 'revert':
- case 'rollback':
- case 'protect':
- case 'unprotect':
- case 'info':
- case 'markpatrolled':
- case 'validate':
- case 'render':
- case 'deletetrackback':
- $wgArticle->$action();
- break;
- case 'print':
- $wgArticle->view();
- break;
- case 'dublincore':
- if( !$wgEnableDublinCoreRdf ) {
- wfHttpError( 403, 'Forbidden', wfMsg( 'nodublincore' ) );
- } else {
- require_once( 'includes/Metadata.php' );
- wfDublinCoreRdf( $wgArticle );
- }
- break;
- case 'creativecommons':
- if( !$wgEnableCreativeCommonsRdf ) {
- wfHttpError( 403, 'Forbidden', wfMsg('nocreativecommons') );
- } else {
- require_once( 'includes/Metadata.php' );
- wfCreativeCommonsRdf( $wgArticle );
- }
- break;
- case 'credits':
- require_once( 'includes/Credits.php' );
- showCreditsPage( $wgArticle );
- break;
- case 'submit':
- if( !$wgCommandLineMode && !$wgRequest->checkSessionCookie() ) {
- # Send a cookie so anons get talk message notifications
- User::SetupSession();
- }
- # Continue...
- case 'edit':
- $internal = $wgRequest->getVal( 'internaledit' );
- $external = $wgRequest->getVal( 'externaledit' );
- $section = $wgRequest->getVal( 'section' );
- $oldid = $wgRequest->getVal( 'oldid' );
- if(!$wgUseExternalEditor || $action=='submit' || $internal ||
- $section || $oldid || (!$wgUser->getOption('externaleditor') && !$external)) {
- require_once( 'includes/EditPage.php' );
- $editor = new EditPage( $wgArticle );
- $editor->submit();
- } elseif($wgUseExternalEditor && ($external || $wgUser->getOption('externaleditor'))) {
- require_once( 'includes/ExternalEdit.php' );
- $mode = $wgRequest->getVal( 'mode' );
- $extedit = new ExternalEdit( $wgArticle, $mode );
- $extedit->edit();
- }
- break;
- case 'history':
- if ($_SERVER['REQUEST_URI'] == $wgTitle->getInternalURL('action=history')) {
- $wgOut->setSquidMaxage( $wgSquidMaxage );
- }
- require_once( 'includes/PageHistory.php' );
- $history = new PageHistory( $wgArticle );
- $history->history();
- break;
- case 'raw':
- require_once( 'includes/RawPage.php' );
- $raw = new RawPage( $wgArticle );
- $raw->view();
- break;
- case 'purge':
- wfPurgeSquidServers(array($wgTitle->getInternalURL()));
- $wgOut->setSquidMaxage( $wgSquidMaxage );
- $wgTitle->invalidateCache();
- $wgArticle->view();
- break;
- default:
- if (wfRunHooks('UnknownAction', array($action, $wgArticle))) {
- $wgOut->setStatusCode( 404 );
- $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );
- }
- }
- }
-}
-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();