From c6f80ed0c695b86942ff49d09ea4ead44eae6dfe Mon Sep 17 00:00:00 2001 From: Thomas Bleher Date: Fri, 30 Nov 2007 17:28:24 +0000 Subject: [PATCH] * Minor style fix: Normally, the function parameter to wfRunHooks() is enclosed in single quotes. Fix this in includes/SpecialPreferences.php. * Make maintenance/findhooks.php more tolerant, so it accepts both quoting styles. * Fix a typo in hooks.txt (the hook is 'userCan', not 'UserCan'). --- docs/hooks.txt | 4 ++-- includes/SpecialPreferences.php | 18 +++++++++--------- maintenance/findhooks.php | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 36d57aa266..d2ebf0f995 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -757,13 +757,13 @@ string &$error: output: HTML error to show if upload canceled by returning false 'UploadComplete': Upon completion of a file upload $image: Image object representing the file that was uploaded -'UserCan': To interrupt/advise the "user can do X to Y article" check. +'userCan': To interrupt/advise the "user can do X to Y article" check. If you want to display an error message, try getUserPermissionsErrors. $title: Title object being checked against $user : Current user object $action: Action being checked $result: Pointer to result returned if hook returns false. If null is returned, - UserCan checks are continued by internal code. + userCan checks are continued by internal code. 'UserCreateForm': change to manipulate the login form $template: SimpleTemplate instance for the form diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index b8f1385a76..0bc362a8fd 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -98,7 +98,7 @@ class PreferencesForm { $this->mUserLanguage = 'nolanguage'; } - wfRunHooks( "InitPreferencesForm", array( $this, $request ) ); + wfRunHooks( 'InitPreferencesForm', array( $this, $request ) ); } function execute() { @@ -213,23 +213,23 @@ class PreferencesForm { if ( '' != $this->mNewpass && $wgAuth->allowPasswordChange() ) { if ( $this->mNewpass != $this->mRetypePass ) { - wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass, 'badretype' ) ); + wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass, 'badretype' ) ); $this->mainPrefsForm( 'error', wfMsg( 'badretype' ) ); return; } if (!$wgUser->checkPassword( $this->mOldpass )) { - wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass, 'wrongpassword' ) ); + wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass, 'wrongpassword' ) ); $this->mainPrefsForm( 'error', wfMsg( 'wrongpassword' ) ); return; } try { $wgUser->setPassword( $this->mNewpass ); - wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass, 'success' ) ); + wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass, 'success' ) ); $this->mNewpass = $this->mOldpass = $this->mRetypePass = ''; } catch( PasswordError $e ) { - wfRunHooks( "PrefsPasswordAudit", array( $wgUser, $this->mNewpass, 'error' ) ); + wfRunHooks( 'PrefsPasswordAudit', array( $wgUser, $this->mNewpass, 'error' ) ); $this->mainPrefsForm( 'error', $e->getMessage() ); return; } @@ -330,7 +330,7 @@ class PreferencesForm { $wgUser->setEmail( $this->mUserEmail ); } if( $oldadr != $newadr ) { - wfRunHooks( "PrefsEmailAudit", array( $wgUser, $oldadr, $newadr ) ); + wfRunHooks( 'PrefsEmailAudit', array( $wgUser, $oldadr, $newadr ) ); } } @@ -340,7 +340,7 @@ class PreferencesForm { } $msg = ''; - if ( !wfRunHooks( "SavePreferences", array( $this, $wgUser, &$msg ) ) ) { + if ( !wfRunHooks( 'SavePreferences', array( $this, $wgUser, &$msg ) ) ) { print "(($msg))"; $this->mainPrefsForm( 'error', $msg ); return; @@ -408,7 +408,7 @@ class PreferencesForm { } } - wfRunHooks( "ResetPreferences", array( $this, $wgUser ) ); + wfRunHooks( 'ResetPreferences', array( $this, $wgUser ) ); } /** @@ -1013,7 +1013,7 @@ class PreferencesForm { } $wgOut->addHTML( '' ); - wfRunHooks( "RenderPreferencesForm", array( $this, $wgOut ) ); + wfRunHooks( 'RenderPreferencesForm', array( $this, $wgOut ) ); $token = htmlspecialchars( $wgUser->editToken() ); $skin = $wgUser->getSkin(); diff --git a/maintenance/findhooks.php b/maintenance/findhooks.php index 284e790668..e51626c2b7 100644 --- a/maintenance/findhooks.php +++ b/maintenance/findhooks.php @@ -45,8 +45,8 @@ function getHooksFromDoc() { function getHooksFromFile( $file ) { $content = file_get_contents( $file ); $m = array(); - preg_match_all( "/wfRunHooks\(\s*\'(.*?)\'/", $content, $m); - return $m[1]; + preg_match_all( '/wfRunHooks\(\s*([\'"])(.*?)\1/', $content, $m); + return $m[2]; } /** -- 2.20.1