Go to the documentation of this file.
41 $old = $this->context->getRequest();
42 $this->context->setRequest( $x );
51 $old = $this->context->getOutput();
52 $this->context->setOutput( $x );
76 $curid = $request->getInt(
'curid' );
77 $title = $request->getVal(
'title' );
78 $action = $request->getVal(
'action',
'view' );
80 if ( $request->getCheck(
'search' ) ) {
98 && !is_null(
$ret ) &&
$ret->getArticleID() == 0
108 if (
$ret ===
null || !
$ret->isSpecialPage() ) {
110 $oldid = $request->getInt(
'oldid' );
111 $oldid = $oldid ? $oldid : $request->getInt(
'diff' );
120 if (
$ret ===
null && strval(
$title ) ===
'' && !$request->getCheck(
'curid' ) && $action !==
'delete' ) {
124 if (
$ret ===
null || (
$ret->getDBkey() ==
'' && !
$ret->isExternal() ) ) {
136 if ( $this->context->getTitle() === null ) {
137 $this->context->setTitle( $this->
parseTitle() );
139 return $this->context->getTitle();
148 static $action =
null;
150 if ( $action ===
null ) {
174 $request = $this->context->getRequest();
175 $requestTitle =
$title = $this->context->getTitle();
176 $output = $this->context->getOutput();
177 $user = $this->context->getUser();
179 if ( $request->getVal(
'printable' ) ===
'yes' ) {
188 ||
$title->isSpecial(
'Badtitle' )
198 $permErrors =
$title->getUserPermissionsErrors(
'read',
$user );
199 if ( count( $permErrors ) ) {
211 $this->context->setTitle( $badTitle );
221 if (
$title->isExternal() ) {
222 $rdfrom = $request->getVal(
'rdfrom' );
224 $url =
$title->getFullURL(
array(
'rdfrom' => $rdfrom ) );
226 $query = $request->getValues();
231 if ( !preg_match(
'/^' . preg_quote( $wgServer,
'/' ) .
'/', $url )
235 $output->redirect( $url, 301 );
242 } elseif ( $request->getVal(
'action',
'view' ) ==
'view' && !$request->wasPosted()
243 && ( $request->getVal(
'title' ) ===
null
244 ||
$title->getPrefixedDBkey() != $request->getVal(
'title' ) )
245 && !count( $request->getValueNames(
array(
'action',
'title' ) ) )
248 if (
$title->isSpecialPage() ) {
256 if ( $targetUrl == $request->getFullRequestURL() ) {
257 $message =
"Redirect loop detected!\n\n" .
258 "This means the wiki got confused about what page was " .
259 "requested; this sometimes happens when moving a wiki " .
260 "to a new server or changing the server configuration.\n\n";
262 if ( $wgUsePathInfo ) {
263 $message .=
"The wiki is trying to interpret the page " .
264 "title from the URL path portion (PATH_INFO), which " .
265 "sometimes fails depending on the web server. Try " .
266 "setting \"\$wgUsePathInfo = false;\" in your " .
267 "LocalSettings.php, or check that \$wgArticlePath " .
270 $message .=
"Your web server was detected as possibly not " .
271 "supporting URL path components (PATH_INFO) correctly; " .
272 "check your LocalSettings.php for a customized " .
273 "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " .
278 $output->setSquidMaxage( 1200 );
279 $output->redirect( $targetUrl,
'301' );
293 } elseif ( is_string(
$article ) ) {
297 throw new MWException(
"Shouldn't happen: MediaWiki::initializeArticle()"
298 .
" returned neither an object nor a URL" );
304 $user->addAutopromoteOnceGroups(
'onView' );
317 global $wgDisableHardRedirects;
321 $title = $this->context->getTitle();
322 if ( $this->context->canUseWikiPage() ) {
326 $page = $this->context->getWikiPage();
331 $this->context->setWikiPage(
$article->getPage() );
341 $request = $this->context->getRequest();
345 $action = $request->getVal(
'action',
'view' );
347 if ( ( $action ==
'view' || $action ==
'render' )
348 && !$request->getVal(
'oldid' )
349 && !$request->getVal(
'diff' )
350 && $request->getVal(
'redirect' ) !=
'no'
352 && !( is_object(
$file ) &&
$file->exists() && !
$file->getRedirected() )
355 $ignoreRedirect = $target =
false;
362 if ( !$ignoreRedirect && ( $target ||
$article->isRedirect() ) ) {
364 $target = $target ? $target :
$article->followRedirect();
365 if ( is_string( $target ) ) {
366 if ( !$wgDisableHardRedirects ) {
372 if ( is_object( $target ) ) {
375 $rarticle->loadPageData();
376 if ( $rarticle->exists() || ( is_object(
$file ) && !
$file->isLocal() ) ) {
377 $rarticle->setRedirectedFrom(
$title );
379 $this->context->setTitle( $target );
380 $this->context->setWikiPage(
$article->getPage() );
384 $this->context->setTitle(
$article->getTitle() );
385 $this->context->setWikiPage(
$article->getPage() );
400 global $wgUseSquid, $wgSquidMaxage;
404 $request = $this->context->getRequest();
405 $output = $this->context->getOutput();
406 $title = $this->context->getTitle();
407 $user = $this->context->getUser();
420 if ( $action instanceof
Action ) {
421 # Let Squid cache things if we can purge them.
423 in_array( $request->getFullRequestURL(), $requestTitle->
getSquidURLs() )
425 $output->setSquidMaxage( $wgSquidMaxage );
433 if (
wfRunHooks(
'UnknownAction',
array( $request->getVal(
'action',
'view' ), $page ) ) ) {
434 $output->showErrorPage(
'nosuchaction',
'nosuchactiontext' );
444 public function run() {
448 if ( function_exists(
'fastcgi_finish_request' ) ) {
449 fastcgi_finish_request();
453 }
catch ( Exception
$e ) {
467 $maxLag = $this->context->getRequest()->getVal(
'maxlag' );
468 if ( !is_null( $maxLag ) ) {
470 if ( $lag > $maxLag ) {
471 $resp = $this->context->getRequest()->response();
472 $resp->header(
'HTTP/1.1 503 Service Unavailable' );
473 $resp->header(
'Retry-After: ' . max( intval( $maxLag ), 5 ) );
474 $resp->header(
'X-Database-Lag: ' . intval( $lag ) );
475 $resp->header(
'Content-Type: text/plain' );
476 if ( $wgShowHostnames ) {
477 echo
"Waiting for $host: $lag seconds lagged\n";
479 echo
"Waiting for a database server: $lag seconds lagged\n";
491 private function main() {
496 $request = $this->context->getRequest();
499 if ( $wgUseAjax && $request->getVal(
'action',
'view' ) ==
'ajax' ) {
503 $this->context->setTitle(
$title );
507 $dispatcher->performAction();
525 $request->getCookie(
'forceHTTPS',
'' ) ||
527 $request->getCookie(
'forceHTTPS' ) ||
530 $this->context->getUser()->isLoggedIn()
531 && $this->context->getUser()->requiresHTTPS()
534 $request->getProtocol() ==
'http'
536 $oldUrl = $request->getFullRequestURL();
537 $redirUrl = str_replace(
'http://',
'https://', $oldUrl );
539 if ( $request->wasPosted() ) {
548 wfDebugLog(
'RedirectedPosts',
"Redirected from HTTP to HTTPS: $oldUrl" );
553 $this->context->setTitle(
$title );
554 $output = $this->context->getOutput();
556 $output->addVaryHeader(
'X-Forwarded-Proto' );
557 $output->redirect( $redirUrl );
563 if ( $wgUseFileCache &&
$title->getNamespace() >= 0 ) {
568 if (
$cache->isCacheGood( ) ) {
571 if ( !$this->context->getOutput()->checkLastModified(
$timestamp ) ) {
572 $cache->loadFromFileCache( $this->context );
576 $this->context->getWikiPage()->doViewUpdates( $this->context->getUser() );
578 $this->context->getOutput()->disable();
592 ignore_user_abort(
true );
598 $this->context->getOutput()->output();
618 wfDebug(
"Request ended normally\n" );
627 global $wgJobRunRate, $wgServer, $wgRunJobsAsync;
631 } elseif ( $this->
getTitle()->isSpecial(
'RunJobs' ) ) {
637 if ( $wgJobRunRate < 1 ) {
638 $max = mt_getrandmax();
639 if ( mt_rand( 0, $max ) > $max * $wgJobRunRate ) {
644 $n = intval( $wgJobRunRate );
647 if ( !$wgRunJobsAsync ) {
659 'tasks' =>
'jobs',
'maxjobs' =>
$n,
'sigexpiry' => time() + 5 );
662 $errno = $errstr =
null;
667 isset( $info[
'port'] ) ? $info[
'port'] : 80,
676 wfDebugLog(
'runJobs',
"Failed to start cron API (socket error $errno): $errstr\n" );
683 $req =
"POST $url HTTP/1.1\r\nHost: {$info['host']}\r\nConnection: Close\r\n\r\n";
685 wfDebugLog(
'runJobs',
"Running $n job(s) via '$url'\n" );
688 stream_set_timeout( $sock, 1 );
689 $bytes = fwrite( $sock, $req );
690 if ( $bytes !== strlen( $req ) ) {
691 wfDebugLog(
'runJobs',
"Failed to start cron API (socket write error)\n" );
695 $status = fgets( $sock );
696 if ( !preg_match(
'#^HTTP/\d\.\d 202 #', $status ) ) {
697 wfDebugLog(
'runJobs',
"Failed to start cron API: received '$status'\n" );
static getActionName(IContextSource $context)
Get the action that will be executed, not necessarily the one passed passed through the "action" requ...
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Abstract class for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
wfGetLB( $wiki=false)
Get a load balancer object.
static newMainPage()
Create a new Title for the Main Page.
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfProfileIn( $functionname)
Begin profiling of a function.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
getSquidURLs()
Get a list of URLs to purge from the Squid cache when this page changes.
wfReadOnly()
Check whether the wiki is in read-only mode.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
getRequest()
Get the WebRequest object.
Show an error when a user tries to do something they do not have the necessary permissions for.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
static executePath(Title &$title, IContextSource &$context, $including=false)
Execute a special page path.
static doUpdates( $commit='')
Do any deferred updates and clear the list.
Show an error that looks like an HTTP server error.
Actions are things which can be done to pages (edit, delete, rollback, etc).
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
Class for handling function-scope profiling.
static newFromWikiPage(WikiPage $page, IContextSource $context)
Create an Article object of the appropriate class for the given page.
wfRestoreWarnings()
Restore error level to previous value.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
static useFileCache(IContextSource $context)
Check if pages can be cached for this request/user.
wfProfileOut( $functionname='missing')
Stop profiling of a function.
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
This class should be covered by a general architecture document which does not exist as of January 20...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
static executeJobs( $maxJobs)
Run jobs from the job queue.
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Object-Oriented Ajax functions.
presenting them properly to the user as errors is done by the caller $title
Allows to change the fields on the form that will be generated $name
static newFromTitle( $title, $action)
Construct an ObjectFileCache from a Title and an action.
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
static resolveAlias( $alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
static getMain()
Static methods.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
static getQuerySignature(array $query)
static handle( $e)
Exception handler which simulates the appropriate catch() handling:
Interface for objects which can provide a context on request.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
if(PHP_SAPI !='cli') $file
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Represents a title within MediaWiki.
& wfGetLBFactory()
Get the load balancer factory object.
static singleton( $wiki=false)
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
static factory( $action, Page $page, IContextSource $context=null)
Get an appropriate Action subclass for the given action.
Show an error page on a badtitle.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
if(! $wgRequest->checkUrlExtension()) if(! $wgEnableAPI) $wgTitle
static newFromTitle( $title, IContextSource $context)
Create an Article object of the appropriate class for the given page.