summaryrefslogtreecommitdiff
path: root/includes/Wiki.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/Wiki.php')
-rw-r--r--includes/Wiki.php88
1 files changed, 60 insertions, 28 deletions
diff --git a/includes/Wiki.php b/includes/Wiki.php
index a4a89032..f8f699c9 100644
--- a/includes/Wiki.php
+++ b/includes/Wiki.php
@@ -126,7 +126,7 @@ class MediaWiki {
* @return Title
*/
public function getTitle() {
- if( $this->context->getTitle() === null ){
+ if( $this->context->getTitle() === null ) {
$this->context->setTitle( $this->parseTitle() );
}
return $this->context->getTitle();
@@ -169,6 +169,7 @@ class MediaWiki {
* - special pages
* - normal pages
*
+ * @throws MWException|PermissionsError|BadTitleError|HttpError
* @return void
*/
private function performRequest() {
@@ -177,7 +178,7 @@ class MediaWiki {
wfProfileIn( __METHOD__ );
$request = $this->context->getRequest();
- $title = $this->context->getTitle();
+ $requestTitle = $title = $this->context->getTitle();
$output = $this->context->getOutput();
$user = $this->context->getUser();
@@ -246,7 +247,7 @@ class MediaWiki {
// Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
} elseif ( $request->getVal( 'action', 'view' ) == 'view' && !$request->wasPosted()
&& ( $request->getVal( 'title' ) === null ||
- $title->getPrefixedDBKey() != $request->getVal( 'title' ) )
+ $title->getPrefixedDBkey() != $request->getVal( 'title' ) )
&& !count( $request->getValueNames( array( 'action', 'title' ) ) )
&& wfRunHooks( 'TestCanonicalRedirect', array( $request, $title, $output ) ) )
{
@@ -301,7 +302,7 @@ class MediaWiki {
global $wgArticle;
$wgArticle = new DeprecatedGlobal( 'wgArticle', $article, '1.18' );
- $this->performAction( $article );
+ $this->performAction( $article, $requestTitle );
} elseif ( is_string( $article ) ) {
$output->redirect( $article );
} else {
@@ -330,8 +331,18 @@ class MediaWiki {
wfProfileIn( __METHOD__ );
$title = $this->context->getTitle();
- $article = Article::newFromTitle( $title, $this->context );
- $this->context->setWikiPage( $article->getPage() );
+ if ( $this->context->canUseWikiPage() ) {
+ // Try to use request context wiki page, as there
+ // is already data from db saved in per process
+ // cache there from this->getAction() call.
+ $page = $this->context->getWikiPage();
+ $article = Article::newFromWikiPage( $page, $this->context );
+ } else {
+ // This case should not happen, but just in case.
+ $article = Article::newFromTitle( $title, $this->context );
+ $this->context->setWikiPage( $article->getPage() );
+ }
+
// NS_MEDIAWIKI has no redirects.
// It is also used for CSS/JS, so performance matters here...
if ( $title->getNamespace() == NS_MEDIAWIKI ) {
@@ -345,10 +356,10 @@ class MediaWiki {
// Check for redirects ...
$action = $request->getVal( 'action', 'view' );
$file = ( $title->getNamespace() == NS_FILE ) ? $article->getFile() : null;
- if ( ( $action == 'view' || $action == 'render' ) // ... for actions that show content
- && !$request->getVal( 'oldid' ) && // ... and are not old revisions
- !$request->getVal( 'diff' ) && // ... and not when showing diff
- $request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to
+ if ( ( $action == 'view' || $action == 'render' ) // ... for actions that show content
+ && !$request->getVal( 'oldid' ) && // ... and are not old revisions
+ !$request->getVal( 'diff' ) && // ... and not when showing diff
+ $request->getVal( 'redirect' ) != 'no' && // ... unless explicitly told not to
// ... and the article is not a non-redirect image page with associated file
!( is_object( $file ) && $file->exists() && !$file->getRedirected() ) )
{
@@ -395,8 +406,9 @@ class MediaWiki {
* Perform one of the "standard" actions
*
* @param $page Page
+ * @param $requestTitle The original title, before any redirects were applied
*/
- private function performAction( Page $page ) {
+ private function performAction( Page $page, Title $requestTitle ) {
global $wgUseSquid, $wgSquidMaxage;
wfProfileIn( __METHOD__ );
@@ -419,7 +431,7 @@ class MediaWiki {
if ( $action instanceof Action ) {
# Let Squid cache things if we can purge them.
if ( $wgUseSquid &&
- in_array( $request->getFullRequestURL(), $title->getSquidURLs() )
+ in_array( $request->getFullRequestURL(), $requestTitle->getSquidURLs() )
) {
$output->setSquidMaxage( $wgSquidMaxage );
}
@@ -490,6 +502,23 @@ class MediaWiki {
$request = $this->context->getRequest();
+ if ( $request->getCookie( 'forceHTTPS' )
+ && $request->detectProtocol() == 'http'
+ && $request->getMethod() == 'GET'
+ ) {
+ $redirUrl = $request->getFullRequestURL();
+ $redirUrl = str_replace( 'http://', 'https://', $redirUrl );
+
+ // Setup dummy Title, otherwise OutputPage::redirect will fail
+ $title = Title::newFromText( NS_MAIN, 'REDIR' );
+ $this->context->setTitle( $title );
+ $output = $this->context->getOutput();
+ $output->redirect( $redirUrl );
+ $output->output();
+ wfProfileOut( __METHOD__ );
+ return;
+ }
+
// Send Ajax requests to the Ajax dispatcher.
if ( $wgUseAjax && $request->getVal( 'action', 'view' ) == 'ajax' ) {
@@ -555,9 +584,6 @@ class MediaWiki {
// Execute a job from the queue
$this->doJobs();
- // Log message usage, if $wgAdaptiveMessageCache is set to true
- MessageCache::logMessages();
-
// Log profiling data, e.g. in the database or UDP
wfLogProfilingData();
@@ -578,28 +604,34 @@ class MediaWiki {
if ( $wgJobRunRate <= 0 || wfReadOnly() ) {
return;
}
+
if ( $wgJobRunRate < 1 ) {
$max = mt_getrandmax();
if ( mt_rand( 0, $max ) > $max * $wgJobRunRate ) {
- return;
+ return; // the higher $wgJobRunRate, the less likely we return here
}
$n = 1;
} else {
$n = intval( $wgJobRunRate );
}
- while ( $n-- && false != ( $job = Job::pop() ) ) {
- $output = $job->toString() . "\n";
- $t = - microtime( true );
- $success = $job->run();
- $t += microtime( true );
- $t = round( $t * 1000 );
- if ( !$success ) {
- $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n";
- } else {
- $output .= "Success, Time: $t ms\n";
+ $group = JobQueueGroup::singleton();
+ do {
+ $job = $group->pop( JobQueueGroup::USE_CACHE ); // job from any queue
+ if ( $job ) {
+ $output = $job->toString() . "\n";
+ $t = - microtime( true );
+ $success = $job->run();
+ $group->ack( $job ); // done
+ $t += microtime( true );
+ $t = round( $t * 1000 );
+ if ( !$success ) {
+ $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n";
+ } else {
+ $output .= "Success, Time: $t ms\n";
+ }
+ wfDebugLog( 'jobqueue', $output );
}
- wfDebugLog( 'jobqueue', $output );
- }
+ } while ( --$n && $job );
}
}