From b6d72cfeb2d10801f0aebdda9545e2d6cfc83255 Mon Sep 17 00:00:00 2001 From: Victor Vasiliev Date: Wed, 14 May 2008 19:12:00 +0000 Subject: [PATCH] * Move $var ? true : false check to boolval function * Introduce $wgLogActionsHandlers --- includes/Autopromote.php | 2 +- includes/DefaultSettings.php | 6 ++++++ includes/GlobalFunctions.php | 6 +++++- includes/LogPage.php | 10 ++++++++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/includes/Autopromote.php b/includes/Autopromote.php index b166aa7bee..2a159fe941 100644 --- a/includes/Autopromote.php +++ b/includes/Autopromote.php @@ -87,7 +87,7 @@ class Autopromote { if( User::isValidEmailAddr( $user->getEmail() ) ) { global $wgEmailAuthentication; if( $wgEmailAuthentication ) { - return $user->getEmailAuthenticationTimestamp() ? true : false; + return boolval( $user->getEmailAuthenticationTimestamp() ); } else { return true; } diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index ff7803fddd..1fa3104da6 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2591,6 +2591,12 @@ $wgLogActions = array( 'suppress/block' => 'blocklogentry', ); +/** + * The same as above, but here values are names of functions, + * not messages + */ +$wgLogActionsHandlers = array(); + /** * List of special pages, followed by what subtitle they should go under * at Special:SpecialPages diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 9d3a17c8e3..5ee4cf09b9 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2597,8 +2597,12 @@ function wfWaitForSlaves( $maxLag ) { /** Generate a random 32-character hexadecimal token. * @param mixed $salt Some sort of salt, if necessary, to add to random characters before hashing. */ - function wfGenerateToken( $salt = '' ) { +function wfGenerateToken( $salt = '' ) { $salt = serialize($salt); return md5( mt_rand( 0, 0x7fffffff ) . $salt ); } + +function boolval( $val ) { + return $val ? true : false; +} diff --git a/includes/LogPage.php b/includes/LogPage.php index 38064e637f..1d82fd9095 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -223,8 +223,14 @@ class LogPage { } } } else { - wfDebug( "LogPage::actionText - unknown action $key\n" ); - $rv = "$action"; + global $wgLogActionsHandlers; + if( isset( $wgLogActionsHandlers[$key] ) ) { + $args = func_get_args(); + $rv = call_user_func_array( $wgLogActionsHandlers[$key], $args ); + } else { + wfDebug( "LogPage::actionText - unknown action $key\n" ); + $rv = "$action"; + } } if( $filterWikilinks ) { $rv = str_replace( "[[", "", $rv ); -- 2.20.1