r34826 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34825‎ | r34826 | r34827 >
Date:19:12, 14 May 2008
Author:vasilievvv
Status:old
Tags:
Comment:
* Move $var ? true : false check to boolval function
* Introduce $wgLogActionsHandlers
Modified paths:
  • /trunk/phase3/includes/Autopromote.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/LogPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2597,8 +2597,12 @@
25982598 /** Generate a random 32-character hexadecimal token.
25992599 * @param mixed $salt Some sort of salt, if necessary, to add to random characters before hashing.
26002600 */
2601 - function wfGenerateToken( $salt = '' ) {
 2601+function wfGenerateToken( $salt = '' ) {
26022602 $salt = serialize($salt);
26032603
26042604 return md5( mt_rand( 0, 0x7fffffff ) . $salt );
26052605 }
 2606+
 2607+function boolval( $val ) {
 2608+ return $val ? true : false;
 2609+}
Index: trunk/phase3/includes/DefaultSettings.php
@@ -2592,6 +2592,12 @@
25932593 );
25942594
25952595 /**
 2596+ * The same as above, but here values are names of functions,
 2597+ * not messages
 2598+ */
 2599+$wgLogActionsHandlers = array();
 2600+
 2601+/**
25962602 * List of special pages, followed by what subtitle they should go under
25972603 * at Special:SpecialPages
25982604 */
Index: trunk/phase3/includes/Autopromote.php
@@ -87,7 +87,7 @@
8888 if( User::isValidEmailAddr( $user->getEmail() ) ) {
8989 global $wgEmailAuthentication;
9090 if( $wgEmailAuthentication ) {
91 - return $user->getEmailAuthenticationTimestamp() ? true : false;
 91+ return boolval( $user->getEmailAuthenticationTimestamp() );
9292 } else {
9393 return true;
9494 }
Index: trunk/phase3/includes/LogPage.php
@@ -223,8 +223,14 @@
224224 }
225225 }
226226 } else {
227 - wfDebug( "LogPage::actionText - unknown action $key\n" );
228 - $rv = "$action";
 227+ global $wgLogActionsHandlers;
 228+ if( isset( $wgLogActionsHandlers[$key] ) ) {
 229+ $args = func_get_args();
 230+ $rv = call_user_func_array( $wgLogActionsHandlers[$key], $args );
 231+ } else {
 232+ wfDebug( "LogPage::actionText - unknown action $key\n" );
 233+ $rv = "$action";
 234+ }
229235 }
230236 if( $filterWikilinks ) {
231237 $rv = str_replace( "[[", "", $rv );

Follow-up revisions

RevisionCommit summaryAuthorDate
r34868Kill r34826's unnecessary boolval() per yesterday's IRC discussion (thought v...brion15:38, 15 May 2008

Status & tagging log