Fixing a fatal error on upload page:
authorRotem Liss <rotem@users.mediawiki.org>
Fri, 29 Aug 2008 10:25:24 +0000 (10:25 +0000)
committerRotem Liss <rotem@users.mediawiki.org>
Fri, 29 Aug 2008 10:25:24 +0000 (10:25 +0000)
Fatal error: Call to a member function isAllowed() on a non-object in /home/rotemliss/Server/wiki/source/trunk/phase3/includes/specials/SpecialUpload.php on line 125

The old code (introduced in r40190) used a $this->mUpload object, which does not exist on GET requests to Special:Upload. The new code uses direct User::isAllowed check in such cases.

includes/specials/SpecialUpload.php

index 35a9208..d2a55f0 100644 (file)
@@ -122,7 +122,11 @@ class UploadForm {
                }
 
                # Check permissions
-               $permission = $this->mUpload->isAllowed( $wgUser );
+               if( $this->mUpload ) {
+                       $permission = $this->mUpload->isAllowed( $wgUser );
+               } else {
+                       $permission = $wgUser->isAllowed( 'upload' ) ? true : 'upload';
+               }
                if( $permission !== true ) {
                        if( !$wgUser->isLoggedIn() ) {
                                $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );