in the function isValidPassWord the if condition on wfRunHooks is wrong, at least it seems a bit strange to me that your hook function should return false for it to evaluate the $result parameter you return... this is in the current trunk version of MediaWiki (1.12 alpha), possibly in earlier versions too...
anyway: function isValidPassword( $password ) { global $wgMinimalPasswordLength, $wgContLang;
$result = null; if( !wfRunHooks( 'isValidPassword', array( $password, &$result, $this ) ) ) return $result;
should be: function isValidPassword( $password ) { global $wgMinimalPasswordLength, $wgContLang;
$result = null; if( !wfRunHooks( 'isValidPassword', array( $password, &$result, $this ) ) ) return $result;
Cheers, Peter.
anyway: function isValidPassword( $password ) { global $wgMinimalPasswordLength, $wgContLang;
$result = null; if( !wfRunHooks( 'isValidPassword', array( $password, &$result,
$this ) ) ) return $result;
should be: function isValidPassword( $password ) { global $wgMinimalPasswordLength, $wgContLang;
$result = null; if( !wfRunHooks( 'isValidPassword', array( $password, &$result,
$this ) ) ) return $result;
I don't see any difference...
However, I think it is correct. Hooks should return true if the code should keep going and run other hooks and the rest of the standard code, and false if it should stop there.
sorry forgot to remove the ! in the fix ...doh...
should be:
function isValidPassword( $password ) { global $wgMinimalPasswordLength, $wgContLang;
$result = null; if( wfRunHooks( 'isValidPassword', array( $password, &$result, $this ) ) ) return $result;
On 9/21/07, Thomas Dalton thomas.dalton@gmail.com wrote:
anyway: function isValidPassword( $password ) { global $wgMinimalPasswordLength, $wgContLang;
$result = null; if( !wfRunHooks( 'isValidPassword', array( $password, &$result,
$this ) ) ) return $result;
should be: function isValidPassword( $password ) { global $wgMinimalPasswordLength, $wgContLang;
$result = null; if( !wfRunHooks( 'isValidPassword', array( $password, &$result,
$this ) ) ) return $result;
I don't see any difference...
However, I think it is correct. Hooks should return true if the code should keep going and run other hooks and the rest of the standard code, and false if it should stop there.
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
ah didn't see it from that standpoint, you have a point there as I don't want to execute the standard mediawiki code that follows... so I'll just set $result to true then and return false :)
However, I think it is correct. Hooks should return true if the code
should keep going and run other hooks and the rest of the standard code, and false if it should stop there.
I don't see the problem. A hooked function call returning 'false' means failure and all other functions attached to that hook are skipped. In such a case, $result is null. A hooked function call returning true doesn't mean that $result is true, it just means that it ran without running into something considered exceptional.
Seeing that a password is invalid is not exceptional and the hook returns true. $result is passed by reference, and will be what it should after the hook is called. It can be true or false if the hook ran within normal parameters (or at all), or null if not (denoted by the hooked function returning false).
Peter-156 wrote:
in the function isValidPassWord the if condition on wfRunHooks is wrong, at least it seems a bit strange to me that your hook function should return false for it to evaluate the $result parameter you return... this is in the current trunk version of MediaWiki (1.12 alpha), possibly in earlier versions too...
anyway: function isValidPassword( $password ) { global $wgMinimalPasswordLength, $wgContLang;
$result = null; if( !wfRunHooks( 'isValidPassword', array( $password, &$result,
$this ) ) ) return $result;
should be: function isValidPassword( $password ) { global $wgMinimalPasswordLength, $wgContLang;
$result = null; if( !wfRunHooks( 'isValidPassword', array( $password, &$result,
$this ) ) ) return $result;
Cheers, Peter. _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
On 22/09/2007, Voice of All jschulz_4587@msn.com wrote:
I don't see the problem. A hooked function call returning 'false' means failure and all other functions attached to that hook are skipped. In such a case, $result is null. A hooked function call returning true doesn't mean that $result is true, it just means that it ran without running into something considered exceptional.
Seeing that a password is invalid is not exceptional and the hook returns true. $result is passed by reference, and will be what it should after the hook is called. It can be true or false if the hook ran within normal parameters (or at all), or null if not (denoted by the hooked function returning false).
Hooks return true or false to indicate whether or not further processing should continue. Where a boolean result is also needed, a hook can provide this using, e.g. a variable passed by reference, as is the case here.
To indicate that a password is not valid, you would set $result to false and return false; returning false causes the hook chain to be aborted (so any additional methods subscribed to that hook won't override the $result) and indicates that MediaWiki shouldn't perform internal checks to determine whether or not the password is valid; the value of $result is then used.
This is how hooks work.
Rob Church
Rob Church wrote:
Hooks return true or false to indicate whether or not further processing should continue. Where a boolean result is also needed, a hook can provide this using, e.g. a variable passed by reference, as is the case here.
Yes, I know.
Rob Church wrote:
To indicate that a password is not valid, you would set $result to false and return false; returning false causes the hook chain to be aborted (so any additional methods subscribed to that hook won't override the $result) and indicates that MediaWiki shouldn't perform internal checks to determine whether or not the password is valid; the value of $result is then used.
I suppose if you have multiple extensions built on that hook, it would be most secure to skip all the other hooks in case they are not well written. Though those hooks should never make a 'false' value 'true' anyway.
Voice of All wrote:
Though those hooks should never make a 'false' value 'true' anyway.
Heh, to be clear, I mean hooked functions.
wikitech-l@lists.wikimedia.org