From aa5d7bbceaa5dff843f0c56d926c3a9633c3b7d5 Mon Sep 17 00:00:00 2001 From: Ian Baker Date: Mon, 25 Jul 2011 22:39:52 +0000 Subject: [PATCH] Added a workaround for the lack of RequestContext in 1.17, so this code can be rolled into production. This code can be removed in 1.18+, but it'll work either way. --- includes/api/ApiUpload.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index ff9ddeb8c3..ff0533015b 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -220,9 +220,18 @@ class ApiUpload extends ApiBase { $this->dieUsageMsg( 'invalid-file-key' ); } - // context allows access to the current user without creating new $wgUser references - $context = $this->createContext(); - $this->mUpload = new UploadFromStash( $context->getUser() ); + if( class_exists( 'RequestContext' ) ) { + // context allows access to the current user without creating new $wgUser references + $context = $this->createContext(); + $this->mUpload = new UploadFromStash( $context->getUser() ); + } else { + // this is here to maintain 1.17 compatibility, so these changes can + // be merged into production + // remove this after we've moved to 1.18 + global $wgUser; + $this->mUpload = new UploadFromStash( $wgUser ); + } + $this->mUpload->initialize( $this->mParams['filekey'], $this->mParams['filename'] ); } elseif ( isset( $this->mParams['file'] ) ) { -- 2.20.1