Robert Vogel has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376482 )

Change subject: Fix for invalid title error
......................................................................

Fix for invalid title error

Change by PWirth

Change-Id: I935ed17ee30cb39ca65ec75d7ef3a7380a1575b8
---
M src/Hooks/UserCan.php
1 file changed, 7 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/NSFileRepo 
refs/changes/82/376482/1

diff --git a/src/Hooks/UserCan.php b/src/Hooks/UserCan.php
index c8a3d08..2a35f19 100644
--- a/src/Hooks/UserCan.php
+++ b/src/Hooks/UserCan.php
@@ -95,6 +95,13 @@
                $ntitle = \Title::newFromText( $this->title->getDBkey() );
                $ret_val = true;
 
+               //When image title cannot be created, due to upload errors,
+               //$this->title->getDBKey() is empty, resulting in an invaid
+               //title object in Title::newFromText
+               if( !$ntitle instanceof \Title ) {
+                       return $ret_val;
+               }
+
                //Additional check for NS_MAIN: If a user is not allowed to 
read NS_MAIN he should also be not allowed
                //to view files with no namespace-prefix as they are logically 
assigned to namespace NS_MAIN
                $titleIsNSMAIN =  $ntitle->getNamespace() === NS_MAIN;

-- 
To view, visit https://gerrit.wikimedia.org/r/376482
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I935ed17ee30cb39ca65ec75d7ef3a7380a1575b8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/NSFileRepo
Gerrit-Branch: REL1_27
Gerrit-Owner: Robert Vogel <vo...@hallowelt.biz>
Gerrit-Reviewer: ItSpiderman <d.savulje...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to