From 740b9aa49f2c8144d3af766501625914ff26539a Mon Sep 17 00:00:00 2001 From: Robin Pepermans Date: Mon, 11 Jul 2011 16:53:31 +0000 Subject: [PATCH] (bug 29797) Error: "Tried to load block with invalid type" when subpages are disabled for user pages. Patch by Jarry1250 --- CREDITS | 1 + RELEASE-NOTES-1.19 | 2 ++ includes/Block.php | 11 ++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CREDITS b/CREDITS index a3b13e562d..7209e8e595 100644 --- 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 diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 240831c916..6fecb7579f 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -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. diff --git a/includes/Block.php b/includes/Block.php index 0600faaa7b..d1218db7f0 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -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 -- 2.20.1