Added a workaround for the lack of RequestContext in 1.17, so this code can be rolled...
authorIan Baker <raindrift@users.mediawiki.org>
Mon, 25 Jul 2011 22:39:52 +0000 (22:39 +0000)
committerIan Baker <raindrift@users.mediawiki.org>
Mon, 25 Jul 2011 22:39:52 +0000 (22:39 +0000)
This code can be removed in 1.18+, but it'll work either way.

includes/api/ApiUpload.php

index ff9ddeb..ff05330 100644 (file)
@@ -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'] ) ) {