MediaWiki  1.23.13
Wiki.php
Go to the documentation of this file.
1 <?php
28 class MediaWiki {
29 
34  private $context;
35 
40  public function request( WebRequest $x = null ) {
41  $old = $this->context->getRequest();
42  $this->context->setRequest( $x );
43  return $old;
44  }
45 
50  public function output( OutputPage $x = null ) {
51  $old = $this->context->getOutput();
52  $this->context->setOutput( $x );
53  return $old;
54  }
55 
59  private $action;
60 
64  public function __construct( IContextSource $context = null ) {
65  if ( !$context ) {
67  }
68 
69  $this->context = $context;
70  }
71 
77  private function parseTitle() {
79 
80  $request = $this->context->getRequest();
81  $curid = $request->getInt( 'curid' );
82  $title = $request->getVal( 'title' );
83  $action = $request->getVal( 'action', 'view' );
84 
85  if ( $request->getCheck( 'search' ) ) {
86  // Compatibility with old search URLs which didn't use Special:Search
87  // Just check for presence here, so blank requests still
88  // show the search page when using ugly URLs (bug 8054).
89  $ret = SpecialPage::getTitleFor( 'Search' );
90  } elseif ( $curid ) {
91  // URLs like this are generated by RC, because rc_title isn't always accurate
92  $ret = Title::newFromID( $curid );
93  } else {
95  // Alias NS_MEDIA page URLs to NS_FILE...we only use NS_MEDIA
96  // in wikitext links to tell Parser to make a direct file link
97  if ( !is_null( $ret ) && $ret->getNamespace() == NS_MEDIA ) {
98  $ret = Title::makeTitle( NS_FILE, $ret->getDBkey() );
99  }
100  // Check variant links so that interwiki links don't have to worry
101  // about the possible different language variants
102  if ( count( $wgContLang->getVariants() ) > 1
103  && !is_null( $ret ) && $ret->getArticleID() == 0
104  ) {
105  $wgContLang->findVariantLink( $title, $ret );
106  }
107  }
108 
109  // If title is not provided, always allow oldid and diff to set the title.
110  // If title is provided, allow oldid and diff to override the title, unless
111  // we are talking about a special page which might use these parameters for
112  // other purposes.
113  if ( $ret === null || !$ret->isSpecialPage() ) {
114  // We can have urls with just ?diff=,?oldid= or even just ?diff=
115  $oldid = $request->getInt( 'oldid' );
116  $oldid = $oldid ? $oldid : $request->getInt( 'diff' );
117  // Allow oldid to override a changed or missing title
118  if ( $oldid ) {
119  $rev = Revision::newFromId( $oldid );
120  $ret = $rev ? $rev->getTitle() : $ret;
121  }
122  }
123 
124  // Use the main page as default title if nothing else has been provided
125  if ( $ret === null && strval( $title ) === '' && !$request->getCheck( 'curid' ) && $action !== 'delete' ) {
127  }
128 
129  if ( $ret === null || ( $ret->getDBkey() == '' && !$ret->isExternal() ) ) {
130  $ret = SpecialPage::getTitleFor( 'Badtitle' );
131  }
132 
133  return $ret;
134  }
135 
140  public function getTitle() {
141  if ( $this->context->getTitle() === null ) {
142  $this->context->setTitle( $this->parseTitle() );
143  }
144  return $this->context->getTitle();
145  }
146 
152  public function getAction() {
153  if ( $this->action === null ) {
154  $this->action = Action::getActionName( $this->context );
155  }
156 
157  return $this->action;
158  }
159 
172  private function performRequest() {
173  global $wgServer, $wgUsePathInfo, $wgTitle, $wgHideIdentifiableRedirects;
174 
175  wfProfileIn( __METHOD__ );
176 
177  $request = $this->context->getRequest();
178  $requestTitle = $title = $this->context->getTitle();
179  $output = $this->context->getOutput();
180  $user = $this->context->getUser();
181 
182  if ( $request->getVal( 'printable' ) === 'yes' ) {
183  $output->setPrintable();
184  }
185 
186  $unused = null; // To pass it by reference
187  wfRunHooks( 'BeforeInitialize', array( &$title, &$unused, &$output, &$user, $request, $this ) );
188 
189  // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
190  if ( is_null( $title ) || ( $title->getDBkey() == '' && !$title->isExternal() )
191  || $title->isSpecial( 'Badtitle' )
192  ) {
193  $this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) );
194  wfProfileOut( __METHOD__ );
195  throw new BadTitleError();
196  }
197 
198  // Check user's permissions to read this page.
199  // We have to check here to catch special pages etc.
200  // We will check again in Article::view().
201  $permErrors = $title->getUserPermissionsErrors( 'read', $user );
202  if ( count( $permErrors ) ) {
203  // Bug 32276: allowing the skin to generate output with $wgTitle or
204  // $this->context->title set to the input title would allow anonymous users to
205  // determine whether a page exists, potentially leaking private data. In fact, the
206  // curid and oldid request parameters would allow page titles to be enumerated even
207  // when they are not guessable. So we reset the title to Special:Badtitle before the
208  // permissions error is displayed.
209  //
210  // The skin mostly uses $this->context->getTitle() these days, but some extensions
211  // still use $wgTitle.
212 
213  $badTitle = SpecialPage::getTitleFor( 'Badtitle' );
214  $this->context->setTitle( $badTitle );
215  $wgTitle = $badTitle;
216 
217  wfProfileOut( __METHOD__ );
218  throw new PermissionsError( 'read', $permErrors );
219  }
220 
221  $pageView = false; // was an article or special page viewed?
222 
223  // Interwiki redirects
224  if ( $title->isExternal() ) {
225  $rdfrom = $request->getVal( 'rdfrom' );
226  if ( $rdfrom ) {
227  $url = $title->getFullURL( array( 'rdfrom' => $rdfrom ) );
228  } else {
229  $query = $request->getValues();
230  unset( $query['title'] );
231  $url = $title->getFullURL( $query );
232  }
233  // Check for a redirect loop
234  if ( !preg_match( '/^' . preg_quote( $wgServer, '/' ) . '/', $url )
235  && $title->isLocal()
236  ) {
237  // 301 so google et al report the target as the actual url.
238  $output->redirect( $url, 301 );
239  } else {
240  $this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) );
241  throw new BadTitleError();
242  }
243  // Handle any other redirects.
244  // Redirect loops, titleless URL, $wgUsePathInfo URLs, and URLs with a variant
245  } elseif ( !$this->tryNormaliseRedirect( $title ) ) {
246  // Prevent information leak via Special:MyPage et al (T109724)
247  if ( $title->isSpecialPage() ) {
248  $specialPage = SpecialPageFactory::getPage( $title->getDBKey() );
249  if ( $specialPage instanceof RedirectSpecialPage
250  && $wgHideIdentifiableRedirects
251  && $specialPage->personallyIdentifiableTarget()
252  ) {
253  list( , $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBKey() );
254  $target = $specialPage->getRedirect( $subpage );
255  // target can also be true. We let that case fall through to normal processing.
256  if ( $target instanceof Title ) {
257  $query = $specialPage->getRedirectQuery() ?: array();
258  $request = new DerivativeRequest( $this->context->getRequest(), $query );
259  $request->setRequestURL( $this->context->getRequest()->getRequestURL() );
260  $this->context->setRequest( $request );
261  // Do not varnish cache these. May vary even for anons
262  $this->context->getOutput()->lowerCdnMaxage( 0 );
263  $this->context->setTitle( $target );
264  $wgTitle = $target;
265  // Reset action type cache. (Special pages have only view)
266  $this->action = null;
267  $title = $target;
268  $output->addJsConfigVars( array(
269  'wgInternalRedirectTargetUrl' => $target->getFullURL( $query ),
270  ) );
271  $output->addModules( 'mediawiki.action.view.redirect' );
272  }
273  }
274  }
275 
276  // Special pages ($title may have changed since if statement above)
277  if ( NS_SPECIAL == $title->getNamespace() ) {
278  // Actions that need to be made when we have a special pages
279  SpecialPageFactory::executePath( $title, $this->context );
280  } else {
281  // ...otherwise treat it as an article view. The article
282  // may still be a wikipage redirect to another article or URL.
283  $article = $this->initializeArticle();
284  if ( is_object( $article ) ) {
285  $this->performAction( $article, $requestTitle );
286  } elseif ( is_string( $article ) ) {
287  $output->redirect( $article );
288  } else {
289  throw new MWException( "Shouldn't happen: MediaWiki::initializeArticle()"
290  . " returned neither an object nor a URL" );
291  }
292  }
293  }
294  }
295 
318  private function tryNormaliseRedirect( Title $title ) {
319  global $wgUsePathInfo;
320 
321  $request = $this->context->getRequest();
322  $output = $this->context->getOutput();
323 
324  if ( $request->getVal( 'action', 'view' ) != 'view'
325  || $request->wasPosted()
326  || ( $request->getVal( 'title' ) !== null
327  && $title->getPrefixedDBkey() == $request->getVal( 'title' ) )
328  || count( $request->getValueNames( array( 'action', 'title' ) ) )
329  || !Hooks::run( 'TestCanonicalRedirect', array( $request, $title, $output ) )
330  ) {
331  return false;
332  }
333 
334  if ( $title->isSpecialPage() ) {
335  list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );
336  if ( $name ) {
337  $title = SpecialPage::getTitleFor( $name, $subpage );
338  }
339  }
340  // Redirect to canonical url, make it a 301 to allow caching
341  $targetUrl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
342  if ( $targetUrl == $request->getFullRequestURL() ) {
343  $message = "Redirect loop detected!\n\n" .
344  "This means the wiki got confused about what page was " .
345  "requested; this sometimes happens when moving a wiki " .
346  "to a new server or changing the server configuration.\n\n";
347 
348  if ( $wgUsePathInfo ) {
349  $message .= "The wiki is trying to interpret the page " .
350  "title from the URL path portion (PATH_INFO), which " .
351  "sometimes fails depending on the web server. Try " .
352  "setting \"\$wgUsePathInfo = false;\" in your " .
353  "LocalSettings.php, or check that \$wgArticlePath " .
354  "is correct.";
355  } else {
356  $message .= "Your web server was detected as possibly not " .
357  "supporting URL path components (PATH_INFO) correctly; " .
358  "check your LocalSettings.php for a customized " .
359  "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " .
360  "to true.";
361  }
362  throw new HttpError( 500, $message );
363  }
364  $output->setSquidMaxage( 1200 );
365  $output->redirect( $targetUrl, '301' );
366  return true;
367  }
368 
375  private function initializeArticle() {
376  global $wgDisableHardRedirects;
377 
378  wfProfileIn( __METHOD__ );
379 
380  $title = $this->context->getTitle();
381  if ( $this->context->canUseWikiPage() ) {
382  // Try to use request context wiki page, as there
383  // is already data from db saved in per process
384  // cache there from this->getAction() call.
385  $page = $this->context->getWikiPage();
386  $article = Article::newFromWikiPage( $page, $this->context );
387  } else {
388  // This case should not happen, but just in case.
389  $article = Article::newFromTitle( $title, $this->context );
390  $this->context->setWikiPage( $article->getPage() );
391  }
392 
393  // NS_MEDIAWIKI has no redirects.
394  // It is also used for CSS/JS, so performance matters here...
395  if ( $title->getNamespace() == NS_MEDIAWIKI ) {
396  wfProfileOut( __METHOD__ );
397  return $article;
398  }
399 
400  $request = $this->context->getRequest();
401 
402  // Namespace might change when using redirects
403  // Check for redirects ...
404  $action = $request->getVal( 'action', 'view' );
405  $file = ( $title->getNamespace() == NS_FILE ) ? $article->getFile() : null;
406  if ( ( $action == 'view' || $action == 'render' ) // ... for actions that show content
407  && !$request->getVal( 'oldid' ) // ... and are not old revisions
408  && !$request->getVal( 'diff' ) // ... and not when showing diff
409  && $request->getVal( 'redirect' ) != 'no' // ... unless explicitly told not to
410  // ... and the article is not a non-redirect image page with associated file
411  && !( is_object( $file ) && $file->exists() && !$file->getRedirected() )
412  ) {
413  // Give extensions a change to ignore/handle redirects as needed
414  $ignoreRedirect = $target = false;
415 
416  wfRunHooks( 'InitializeArticleMaybeRedirect',
417  array( &$title, &$request, &$ignoreRedirect, &$target, &$article ) );
418 
419  // Follow redirects only for... redirects.
420  // If $target is set, then a hook wanted to redirect.
421  if ( !$ignoreRedirect && ( $target || $article->isRedirect() ) ) {
422  // Is the target already set by an extension?
423  $target = $target ? $target : $article->followRedirect();
424  if ( is_string( $target ) ) {
425  if ( !$wgDisableHardRedirects ) {
426  // we'll need to redirect
427  wfProfileOut( __METHOD__ );
428  return $target;
429  }
430  }
431  if ( is_object( $target ) ) {
432  // Rewrite environment to redirected article
433  $rarticle = Article::newFromTitle( $target, $this->context );
434  $rarticle->loadPageData();
435  if ( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) {
436  $rarticle->setRedirectedFrom( $title );
437  $article = $rarticle;
438  $this->context->setTitle( $target );
439  $this->context->setWikiPage( $article->getPage() );
440  }
441  }
442  } else {
443  $this->context->setTitle( $article->getTitle() );
444  $this->context->setWikiPage( $article->getPage() );
445  }
446  }
447 
448  wfProfileOut( __METHOD__ );
449  return $article;
450  }
451 
458  private function performAction( Page $page, Title $requestTitle ) {
459  global $wgUseSquid, $wgSquidMaxage;
460 
461  wfProfileIn( __METHOD__ );
462 
463  $request = $this->context->getRequest();
464  $output = $this->context->getOutput();
465  $title = $this->context->getTitle();
466  $user = $this->context->getUser();
467 
468  if ( !wfRunHooks( 'MediaWikiPerformAction',
469  array( $output, $page, $title, $user, $request, $this ) )
470  ) {
471  wfProfileOut( __METHOD__ );
472  return;
473  }
474 
475  $act = $this->getAction();
476 
477  $action = Action::factory( $act, $page, $this->context );
478 
479  if ( $action instanceof Action ) {
480  # Let Squid cache things if we can purge them.
481  if ( $wgUseSquid &&
482  in_array( $request->getFullRequestURL(), $requestTitle->getSquidURLs() )
483  ) {
484  $output->setSquidMaxage( $wgSquidMaxage );
485  }
486 
487  $action->show();
488  wfProfileOut( __METHOD__ );
489  return;
490  }
491 
492  if ( wfRunHooks( 'UnknownAction', array( $request->getVal( 'action', 'view' ), $page ) ) ) {
493  $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' );
494  }
495 
496  wfProfileOut( __METHOD__ );
497  }
498 
503  public function run() {
504  try {
505  $this->checkMaxLag();
506  $this->main();
507  if ( function_exists( 'fastcgi_finish_request' ) ) {
508  fastcgi_finish_request();
509  }
510  $this->triggerJobs();
511  $this->restInPeace();
512  } catch ( Exception $e ) {
514  }
515  }
516 
522  private function checkMaxLag() {
523  global $wgShowHostnames;
524 
525  wfProfileIn( __METHOD__ );
526  $maxLag = $this->context->getRequest()->getVal( 'maxlag' );
527  if ( !is_null( $maxLag ) ) {
528  list( $host, $lag ) = wfGetLB()->getMaxLag();
529  if ( $lag > $maxLag ) {
530  $resp = $this->context->getRequest()->response();
531  $resp->header( 'HTTP/1.1 503 Service Unavailable' );
532  $resp->header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
533  $resp->header( 'X-Database-Lag: ' . intval( $lag ) );
534  $resp->header( 'Content-Type: text/plain' );
535  if ( $wgShowHostnames ) {
536  echo "Waiting for $host: $lag seconds lagged\n";
537  } else {
538  echo "Waiting for a database server: $lag seconds lagged\n";
539  }
540 
541  wfProfileOut( __METHOD__ );
542 
543  exit;
544  }
545  }
546  wfProfileOut( __METHOD__ );
547  return true;
548  }
549 
550  private function main() {
551  global $wgUseFileCache, $wgTitle, $wgUseAjax;
552 
553  wfProfileIn( __METHOD__ );
554 
555  $request = $this->context->getRequest();
556 
557  // Send Ajax requests to the Ajax dispatcher.
558  if ( $wgUseAjax && $request->getVal( 'action', 'view' ) == 'ajax' ) {
559 
560  // Set a dummy title, because $wgTitle == null might break things
561  $title = Title::makeTitle( NS_MAIN, 'AJAX' );
562  $this->context->setTitle( $title );
563  $wgTitle = $title;
564 
565  $dispatcher = new AjaxDispatcher();
566  $dispatcher->performAction();
567  wfProfileOut( __METHOD__ );
568  return;
569  }
570 
571  // Get title from request parameters,
572  // is set on the fly by parseTitle the first time.
573  $title = $this->getTitle();
574  $action = $this->getAction();
575  $wgTitle = $title;
576 
577  // If the user has forceHTTPS set to true, or if the user
578  // is in a group requiring HTTPS, or if they have the HTTPS
579  // preference set, redirect them to HTTPS.
580  // Note: Do this after $wgTitle is setup, otherwise the hooks run from
581  // isLoggedIn() will do all sorts of weird stuff.
582  if (
583  (
584  $request->getCookie( 'forceHTTPS', '' ) ||
585  // check for prefixed version for currently logged in users
586  $request->getCookie( 'forceHTTPS' ) ||
587  // Avoid checking the user and groups unless it's enabled.
588  (
589  $this->context->getUser()->isLoggedIn()
590  && $this->context->getUser()->requiresHTTPS()
591  )
592  ) &&
593  $request->getProtocol() == 'http'
594  ) {
595  $oldUrl = $request->getFullRequestURL();
596  $redirUrl = str_replace( 'http://', 'https://', $oldUrl );
597 
598  if ( $request->wasPosted() ) {
599  // This is weird and we'd hope it almost never happens. This
600  // means that a POST came in via HTTP and policy requires us
601  // redirecting to HTTPS. It's likely such a request is going
602  // to fail due to post data being lost, but let's try anyway
603  // and just log the instance.
604  //
605  // @todo @fixme See if we could issue a 307 or 308 here, need
606  // to see how clients (automated & browser) behave when we do
607  wfDebugLog( 'RedirectedPosts', "Redirected from HTTP to HTTPS: $oldUrl" );
608  }
609 
610  // Setup dummy Title, otherwise OutputPage::redirect will fail
611  $title = Title::newFromText( NS_MAIN, 'REDIR' );
612  $this->context->setTitle( $title );
613  $output = $this->context->getOutput();
614  // Since we only do this redir to change proto, always send a vary header
615  $output->addVaryHeader( 'X-Forwarded-Proto' );
616  $output->redirect( $redirUrl );
617  $output->output();
618  wfProfileOut( __METHOD__ );
619  return;
620  }
621 
622  if ( $wgUseFileCache && $title->getNamespace() >= 0 ) {
623  wfProfileIn( 'main-try-filecache' );
624  if ( HTMLFileCache::useFileCache( $this->context ) ) {
625  // Try low-level file cache hit
627  if ( $cache->isCacheGood( /* Assume up to date */ ) ) {
628  // Check incoming headers to see if client has this cached
629  $timestamp = $cache->cacheTimestamp();
630  if ( !$this->context->getOutput()->checkLastModified( $timestamp ) ) {
631  $cache->loadFromFileCache( $this->context );
632  }
633  // Do any stats increment/watchlist stuff
634  // Assume we're viewing the latest revision (this should always be the case with file cache)
635  $this->context->getWikiPage()->doViewUpdates( $this->context->getUser() );
636  // Tell OutputPage that output is taken care of
637  $this->context->getOutput()->disable();
638  wfProfileOut( 'main-try-filecache' );
639  wfProfileOut( __METHOD__ );
640  return;
641  }
642  }
643  wfProfileOut( 'main-try-filecache' );
644  }
645 
646  // Actually do the work of the request and build up any output
647  $this->performRequest();
648 
649  // Either all DB and deferred updates should happen or none.
650  // The later should not be cancelled due to client disconnect.
651  ignore_user_abort( true );
652  // Now commit any transactions, so that unreported errors after
653  // output() don't roll back the whole DB transaction
654  wfGetLBFactory()->commitMasterChanges();
655 
656  // Output everything!
657  $this->context->getOutput()->output();
658 
659  wfProfileOut( __METHOD__ );
660  }
661 
665  public function restInPeace() {
666  // Do any deferred jobs
667  DeferredUpdates::doUpdates( 'commit' );
668 
669  // Log profiling data, e.g. in the database or UDP
671 
672  // Commit and close up!
674  $factory->commitMasterChanges();
675  $factory->shutdown();
676 
677  wfDebug( "Request ended normally\n" );
678  }
679 
685  protected function triggerJobs() {
686  global $wgJobRunRate, $wgServer, $wgRunJobsAsync;
687 
688  if ( $wgJobRunRate <= 0 || wfReadOnly() ) {
689  return;
690  } elseif ( $this->getTitle()->isSpecial( 'RunJobs' ) ) {
691  return; // recursion guard
692  }
693 
694  $section = new ProfileSection( __METHOD__ );
695 
696  if ( $wgJobRunRate < 1 ) {
697  $max = mt_getrandmax();
698  if ( mt_rand( 0, $max ) > $max * $wgJobRunRate ) {
699  return; // the higher $wgJobRunRate, the less likely we return here
700  }
701  $n = 1;
702  } else {
703  $n = intval( $wgJobRunRate );
704  }
705 
706  if ( !$wgRunJobsAsync ) {
707  // If running jobs asynchronously has been disabled, run the job here
708  // while the user waits
710  return;
711  }
712 
713  if ( !JobQueueGroup::singleton()->queuesHaveJobs( JobQueueGroup::TYPE_DEFAULT ) ) {
714  return; // do not send request if there are probably no jobs
715  }
716 
717  $query = array( 'title' => 'Special:RunJobs',
718  'tasks' => 'jobs', 'maxjobs' => $n, 'sigexpiry' => time() + 5 );
720 
721  $errno = $errstr = null;
722  $info = wfParseUrl( $wgServer );
724  $sock = fsockopen(
725  $info['host'],
726  isset( $info['port'] ) ? $info['port'] : 80,
727  $errno,
728  $errstr,
729  // If it takes more than 100ms to connect to ourselves there
730  // is a problem elsewhere.
731  0.1
732  );
734  if ( !$sock ) {
735  wfDebugLog( 'runJobs', "Failed to start cron API (socket error $errno): $errstr\n" );
736  // Fall back to running the job here while the user waits
738  return;
739  }
740 
741  $url = wfAppendQuery( wfScript( 'index' ), $query );
742  $req = "POST $url HTTP/1.1\r\nHost: {$info['host']}\r\nConnection: Close\r\nContent-Length: 0\r\n\r\n";
743 
744  wfDebugLog( 'runJobs', "Running $n job(s) via '$url'\n" );
745  // Send a cron API request to be performed in the background.
746  // Give up if this takes too long to send (which should be rare).
747  stream_set_timeout( $sock, 1 );
748  $bytes = fwrite( $sock, $req );
749  if ( $bytes !== strlen( $req ) ) {
750  wfDebugLog( 'runJobs', "Failed to start cron API (socket write error)\n" );
751  } else {
752  // Do not wait for the response (the script should handle client aborts).
753  // Make sure that we don't close before that script reaches ignore_user_abort().
754  $status = fgets( $sock );
755  if ( !preg_match( '#^HTTP/\d\.\d 202 #', $status ) ) {
756  wfDebugLog( 'runJobs', "Failed to start cron API: received '$status'\n" );
757  }
758  }
759  fclose( $sock );
760  }
761 }
Action\getActionName
static getActionName(IContextSource $context)
Get the action that will be executed, not necessarily the one passed passed through the "action" requ...
Definition: Action.php:112
$factory
$factory
Definition: img_auth.php:54
DerivativeRequest
Similar to FauxRequest, but only fakes URL parameters and method (POST or GET) and use the base reque...
Definition: WebRequest.php:1463
Title\makeTitle
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
Page
Abstract class for type hinting (accepts WikiPage, Article, ImagePage, CategoryPage)
Definition: WikiPage.php:26
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:189
MediaWiki\$action
String $action
Cache what action this request is.
Definition: Wiki.php:57
MediaWiki\checkMaxLag
checkMaxLag()
Checks if the request should abort due to a lagged server, for given maxlag parameter.
Definition: Wiki.php:520
php
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
Definition: skin.txt:62
Revision\newFromId
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition: Revision.php:88
wfGetLB
wfGetLB( $wiki=false)
Get a load balancer object.
Definition: GlobalFunctions.php:3716
MediaWiki\run
run()
Run the current MediaWiki instance index.php just calls this.
Definition: Wiki.php:501
JobQueueGroup\TYPE_DEFAULT
const TYPE_DEFAULT
Definition: JobQueueGroup.php:40
$timestamp
if( $limit) $timestamp
Definition: importImages.php:104
MediaWiki\restInPeace
restInPeace()
Ends this task peacefully.
Definition: Wiki.php:663
Title\newMainPage
static newMainPage()
Create a new Title for the Main Page.
Definition: Title.php:441
MediaWiki\getTitle
getTitle()
Get the Title object that we'll be acting on, as specified in the WebRequest.
Definition: Wiki.php:138
wfDebugLog
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Definition: GlobalFunctions.php:1087
wfProfileIn
wfProfileIn( $functionname)
Begin profiling of a function.
Definition: Profiler.php:33
$n
$n
Definition: RandomTest.php:76
$ret
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
Definition: hooks.txt:1530
wfSuppressWarnings
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
Definition: GlobalFunctions.php:2434
MediaWiki\main
main()
Definition: Wiki.php:548
Title\getSquidURLs
getSquidURLs()
Get a list of URLs to purge from the Squid cache when this page changes.
Definition: Title.php:3503
NS_FILE
const NS_FILE
Definition: Defines.php:85
wfReadOnly
wfReadOnly()
Check whether the wiki is in read-only mode.
Definition: GlobalFunctions.php:1360
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:74
ContextSource\getRequest
getRequest()
Get the WebRequest object.
Definition: ContextSource.php:77
PermissionsError
Show an error when a user tries to do something they do not have the necessary permissions for.
Definition: PermissionsError.php:28
$wgContLang
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
Definition: design.txt:56
SpecialPageFactory\executePath
static executePath(Title &$title, IContextSource &$context, $including=false)
Execute a special page path.
Definition: SpecialPageFactory.php:443
RedirectSpecialPage
Shortcut to construct a special page alias.
Definition: RedirectSpecialPage.php:29
DeferredUpdates\doUpdates
static doUpdates( $commit='')
Do any deferred updates and clear the list.
Definition: DeferredUpdates.php:82
HttpError
Show an error that looks like an HTTP server error.
Definition: HttpError.php:28
Action
Actions are things which can be done to pages (edit, delete, rollback, etc).
Definition: Action.php:37
wfAppendQuery
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
Definition: GlobalFunctions.php:506
NS_MAIN
const NS_MAIN
Definition: Defines.php:79
FauxRequest\setRequestURL
setRequestURL( $url)
Definition: WebRequest.php:1356
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:68
wfParseUrl
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
Definition: GlobalFunctions.php:802
ProfileSection
Class for handling function-scope profiling.
Definition: Profiler.php:60
Article\newFromWikiPage
static newFromWikiPage(WikiPage $page, IContextSource $context)
Create an Article object of the appropriate class for the given page.
Definition: Article.php:174
MWException
MediaWiki exception.
Definition: MWException.php:26
MediaWiki\performAction
performAction(Page $page, Title $requestTitle)
Perform one of the "standard" actions.
Definition: Wiki.php:456
wfRestoreWarnings
wfRestoreWarnings()
Restore error level to previous value.
Definition: GlobalFunctions.php:2464
wfScript
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
Definition: GlobalFunctions.php:3786
HTMLFileCache\useFileCache
static useFileCache(IContextSource $context)
Check if pages can be cached for this request/user.
Definition: HTMLFileCache.php:90
MediaWiki\parseTitle
parseTitle()
Parse the request to get the Title object.
Definition: Wiki.php:75
wfProfileOut
wfProfileOut( $functionname='missing')
Stop profiling of a function.
Definition: Profiler.php:46
MediaWiki
PROTO_CURRENT
const PROTO_CURRENT
Definition: Defines.php:270
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4058
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
OutputPage
This class should be covered by a general architecture document which does not exist as of January 20...
Definition: OutputPage.php:38
list
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
Definition: deferred.txt:11
SpecialRunJobs\executeJobs
static executeJobs( $maxJobs)
Run jobs from the job queue.
Definition: SpecialRunJobs.php:123
MediaWiki\triggerJobs
triggerJobs()
Potentially open a socket and sent an HTTP request back to the server to run a specified number of jo...
Definition: Wiki.php:683
$section
$section
Definition: Utf8Test.php:88
wfDebug
wfDebug( $text, $dest='all')
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:980
AjaxDispatcher
Object-Oriented Ajax functions.
Definition: AjaxDispatcher.php:32
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
action
action
Definition: parserTests.txt:378
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:67
MediaWiki\tryNormaliseRedirect
tryNormaliseRedirect(Title $title)
Handle redirects for uncanonical title requests.
Definition: Wiki.php:316
MediaWiki\__construct
__construct(IContextSource $context=null)
Definition: Wiki.php:62
HTMLFileCache\newFromTitle
static newFromTitle( $title, $action)
Construct an ObjectFileCache from a Title and an action.
Definition: HTMLFileCache.php:39
Title\newFromURL
static newFromURL( $url)
THIS IS NOT THE FUNCTION YOU WANT.
Definition: Title.php:241
SpecialPageFactory\resolveAlias
static resolveAlias( $alias)
Given a special page name with a possible subpage, return an array where the first element is the spe...
Definition: SpecialPageFactory.php:271
RequestContext\getMain
static getMain()
Static methods.
Definition: RequestContext.php:420
$user
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
Definition: hooks.txt:237
Hooks\run
static run( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:136
SpecialRunJobs\getQuerySignature
static getQuerySignature(array $query)
Definition: SpecialRunJobs.php:108
MWExceptionHandler\handle
static handle( $e)
Exception handler which simulates the appropriate catch() handling:
Definition: MWExceptionHandler.php:134
IContextSource
Interface for objects which can provide a context on request.
Definition: IContextSource.php:29
WebRequest
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form,...
Definition: WebRequest.php:38
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
MediaWiki\performRequest
performRequest()
Performs the request.
Definition: Wiki.php:170
$rev
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
Definition: hooks.txt:1337
MediaWiki\getAction
getAction()
Returns the name of the action that will be executed.
Definition: Wiki.php:150
Title
Represents a title within MediaWiki.
Definition: Title.php:35
MediaWiki\output
output(OutputPage $x=null)
Definition: Wiki.php:49
MediaWiki\initializeArticle
initializeArticle()
Initialize the main Article object for "standard" actions (view, etc) Create an Article object for th...
Definition: Wiki.php:373
wfGetLBFactory
& wfGetLBFactory()
Get the load balancer factory object.
Definition: GlobalFunctions.php:3725
$cache
$cache
Definition: mcc.php:32
MediaWiki\request
request(WebRequest $x=null)
Definition: Wiki.php:39
$output
& $output
Definition: hooks.txt:375
JobQueueGroup\singleton
static singleton( $wiki=false)
Definition: JobQueueGroup.php:61
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:87
SpecialPageFactory\getPage
static getPage( $name)
Find the object with a given name and return it (or NULL)
Definition: SpecialPageFactory.php:338
MediaWiki\$context
IContextSource $context
TODO: fold $output, etc, into this.
Definition: Wiki.php:33
$query
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
Definition: hooks.txt:1105
RedirectSpecialPage\personallyIdentifiableTarget
personallyIdentifiableTarget()
Indicate if the target of this redirect can be used to identify a particular user of this wiki (e....
Definition: RedirectSpecialPage.php:98
Title\newFromID
static newFromID( $id, $flags=0)
Create a new Title from an article ID.
Definition: Title.php:297
$article
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
Definition: hooks.txt:78
Action\factory
static factory( $action, Page $page, IContextSource $context=null)
Get an appropriate Action subclass for the given action.
Definition: Action.php:88
BadTitleError
Show an error page on a badtitle.
Definition: BadTitleError.php:29
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:544
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:1632
$wgTitle
if(! $wgRequest->checkUrlExtension()) if(! $wgEnableAPI) $wgTitle
Definition: api.php:63
wfLogProfilingData
wfLogProfilingData()
Definition: GlobalFunctions.php:1273
Article\newFromTitle
static newFromTitle( $title, IContextSource $context)
Create an Article object of the appropriate class for the given page.
Definition: Article.php:142