* Minor style fix:
authorThomas Bleher <tbleher@users.mediawiki.org>
Fri, 30 Nov 2007 17:28:24 +0000 (17:28 +0000)
committerThomas Bleher <tbleher@users.mediawiki.org>
Fri, 30 Nov 2007 17:28:24 +0000 (17:28 +0000)
  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
includes/SpecialPreferences.php
maintenance/findhooks.php

index 36d57aa..d2ebf0f 100644 (file)
@@ -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
index b8f1385..0bc362a 100644 (file)
@@ -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( '</fieldset>' );
 
-               wfRunHooks( "RenderPreferencesForm", array( $this, $wgOut ) );
+               wfRunHooks( 'RenderPreferencesForm', array( $this, $wgOut ) );
 
                $token = htmlspecialchars( $wgUser->editToken() );
                $skin = $wgUser->getSkin();
index 284e790..e51626c 100644 (file)
@@ -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];
 }
 
 /**