/* set up the default links for the personal toolbar */
$personal_urls = array();
- $page = $wgRequest->getVal( 'returnto', $this->thisurl );
- $query = $wgRequest->getVal( 'returntoquery', $this->thisquery );
- $returnto = "returnto=$page";
- if( $this->thisquery != '' )
- $returnto .= "&returntoquery=$query";
+
+ # Due to bug 32276, if a user does not have read permissions,
+ # $wgOut->getTitle() will just give Special:Badtitle, which is
+ # not especially useful as a returnto parameter. Use the title
+ # from the request instead, if there was one.
+ $page = Title::newFromURL( $wgRequest->getVal( 'title', '' ) );
+ $page = $wgRequest->getVal( 'returnto', $page );
+ $returnto = '';
+ if( strval( $page ) !== '' ) {
+ $returnto = "returnto=$page";
+ $query = $wgRequest->getVal( 'returntoquery', $this->thisquery );
+ if( $query != '' ) {
+ $returnto .= "&returntoquery=$query";
+ }
+ }
+
if( $this->loggedin ) {
$personal_urls['userpage'] = array(
'text' => $this->username,