Thread:Project:Support desk/Error Page is not parsing wikitext in System Message

Link to example of problem: http://clubs.uci.edu/sba/w/Special:EmailUser/Law.Student
 * Mediawiki:1.17.0
 * PHP: 5.2.9 (apache2handler)
 * MySQL: 5.0.92-log

What I'm trying to do: When a user receives an Error because they are not logged in, I'd like have that Error Message point to Special:Mailto/(Username they were trying to email) so that they can use Special:Mailto. (I realize it'd be easier to just always use Special:Mailto, but I'd prefer to have them use EmailUser if they are logged in.

How I'm trying to do it: Within LocalSettings.php I have: require_once("$IP/extensions/EmailUserAnon.php"); $wgHooks['EmailUserPermissionsErrors'][] = 'emailUserAnon'; $wgNamespacesWithSubpages[NS_SPECIAL] = true; Manual:Hooks/EmailUserPermissionsErrors

Body of EmailUserAnon.php: function emailUserAnon( $user, $editToken, &$hookErr ) { $hookErr = array('permError', 'parseinline', 'sendToAnonEmail' ); return true; } Text of those system messages: http://clubs.uci.edu/sba/w/MediaWiki:PermError, http://clubs.uci.edu/sba/w/MediaWiki:SendToAnonEmail

Below are some more funny things I found as I was digging, but I don't believe they affect this problem. Again, I think I just need to figure out how to get it to parse the wikitext in the system message.

Note: $hookErr looks like it's out of order, but as you see on the page I initially referenced, it's finding the right system message.

Explanation: When I tried to use just permError and sendToAnonEmail, I got a fatal PHP error because it won't take NULL for the third term (which it infers when I specify only 2 terms). First up, here's the call of OutputPage::ShowErrorPage from SpecialEmailUser.php:

$error = self::getPermissionsError( $wgUser, $wgRequest->getVal( 'wpEditToken' ) ); switch ( $error ) { case null: # Wahey! break; case 'badaccess': $wgOut->permissionRequired( 'sendemail' ); return; case 'blockedemailuser': $wgOut->blockedPage; return; case 'actionthrottledtext': $wgOut->rateLimited; return; case 'mailnologin': $wgOut->showErrorPage( $error, "{$error}text" ); return; case 'usermaildisabled': $wgOut->showErrorPage( $error, "{$error}text" ); return; default: # It's a hook error list( $title, $msg, $params ) = $error; $wgOut->showErrorPage( $title, $msg, $params ); return; }

from getPermissionsError: public static function getPermissionsError( $user, $editToken ) { ... wfRunHooks( 'UserCanSendEmail', array( &$user, &$hookErr ) ); wfRunHooks( 'EmailUserPermissionsErrors', array( $user, $editToken, &$hookErr ) ); if ( $hookErr ) { return $hookErr; }

Diving through the code, I found this in OutputPage::showErrorPage: array_unshift( $params, 'parse' ); array_unshift( $params, $msg ); $this->addHTML( call_user_func_array( 'wfMsgExt', $params ) );

And within GlobalFunctions.php, wfMsgExt has the code below. I believe this is causing the weird interpretation of my params: function wfMsgExt( $key, $options ) { global $wgOut;

$args = func_get_args; array_shift( $args ); array_shift( $args ); $options = (array)$options; ...       if( in_array( 'parse', $options, true ) ) { $string = $wgOut->parse( $string, true, !$forContent ); } elseif ( in_array( 'parseinline', $options, true ) ) { $string = $wgOut->parse( $string, true, !$forContent ); $m = array; if( preg_match( '/^ (.*)\n?<\/p>\n?$/sU', $string, $m ) ) { $string = $m[1]; }       } elseif ( in_array( 'parsemag', $options, true ) ) { global $wgMessageCache; if ( isset( $wgMessageCache ) ) { $string = $wgMessageCache->transform( $string,                               !$forContent,                                is_object( $langCode ) ? $langCode : null ); }       }