(bug 29797) Error: "Tried to load block with invalid type" when subpages are disabled...
authorRobin Pepermans <robin@users.mediawiki.org>
Mon, 11 Jul 2011 16:53:31 +0000 (16:53 +0000)
committerRobin Pepermans <robin@users.mediawiki.org>
Mon, 11 Jul 2011 16:53:31 +0000 (16:53 +0000)
Patch by Jarry1250

CREDITS
RELEASE-NOTES-1.19
includes/Block.php

diff --git a/CREDITS b/CREDITS
index a3b13e5..7209e8e 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -97,6 +97,7 @@ following names for their contribution to the product.
 * FunPika
 * Harry Burt
 * Ireas
+* Jarry1250
 * Jaska Zedlik
 * Jeremy Baron
 * Jidanni
index 240831c..6fecb75 100644 (file)
@@ -153,6 +153,8 @@ production.
 * Translate the block expiry date
 * (bug 28630) Add iwlinks, langlinks, redirect to
   RefreshLinks::deleteLinksFromNonexistent
+* (bug 29797) Error: "Tried to load block with invalid type" when subpages
+  are disabled for user pages.
 
 === API changes in 1.19 ===
 * BREAKING CHANGE: action=watch now requires POST and token.
index 0600faa..d1218db 100644 (file)
@@ -203,7 +203,8 @@ class Block {
                        $conds = array( 'ipb_address' => array() );
                }
 
-               # Be aware that the != '' check is explicit, since empty values will be passed by some callers.
+               # Be aware that the != '' check is explicit, since empty values will be
+               # passed by some callers (bug 29116)
                if( $vagueTarget != ''){
                        list( $target, $type ) = self::parseTarget( $vagueTarget );
                        switch( $type ) {
@@ -1039,6 +1040,14 @@ class Block {
                        return array( null, null );
                }
 
+               # Consider the possibility that this is not a username at all
+               # but actually an old subpage (bug #29797)
+               if( strpos( $target, '/' ) !== false ){
+                       # An old subpage, drill down to the user behind it
+                       $parts = explode( '/', $target );
+                       $target = $parts[0];
+               }
+
                $userObj = User::newFromName( $target );
                if ( $userObj instanceof User ) {
                        # Note that since numbers are valid usernames, a $target of "12345" will be