Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | die( "This file is part of MediaWiki, it is not a valid entry point" ); |
10 | 10 | } |
11 | 11 | |
12 | | -require_once dirname(__FILE__) . '/normal/UtfNormalUtil.php'; |
| 12 | +require_once dirname( __FILE__ ) . '/normal/UtfNormalUtil.php'; |
13 | 13 | |
14 | 14 | // Hide compatibility functions from Doxygen |
15 | 15 | /// @cond |
— | — | @@ -20,15 +20,23 @@ |
21 | 21 | * Re-implementations of newer functions or functions in non-standard |
22 | 22 | * PHP extensions may be included here. |
23 | 23 | */ |
24 | | -if( !function_exists('iconv') ) { |
| 24 | +if( !function_exists( 'iconv' ) ) { |
25 | 25 | # iconv support is not in the default configuration and so may not be present. |
26 | 26 | # Assume will only ever use utf-8 and iso-8859-1. |
27 | 27 | # This will *not* work in all circumstances. |
28 | 28 | function iconv( $from, $to, $string ) { |
29 | | - if ( substr( $to, -8 ) == '//IGNORE' ) $to = substr( $to, 0, strlen( $to ) - 8 ); |
30 | | - if(strcasecmp( $from, $to ) == 0) return $string; |
31 | | - if(strcasecmp( $from, 'utf-8' ) == 0) return utf8_decode( $string ); |
32 | | - if(strcasecmp( $to, 'utf-8' ) == 0) return utf8_encode( $string ); |
| 29 | + if ( substr( $to, -8 ) == '//IGNORE' ) { |
| 30 | + $to = substr( $to, 0, strlen( $to ) - 8 ); |
| 31 | + } |
| 32 | + if( strcasecmp( $from, $to ) == 0 ) { |
| 33 | + return $string; |
| 34 | + } |
| 35 | + if( strcasecmp( $from, 'utf-8' ) == 0 ) { |
| 36 | + return utf8_decode( $string ); |
| 37 | + } |
| 38 | + if( strcasecmp( $to, 'utf-8' ) == 0 ) { |
| 39 | + return utf8_encode( $string ); |
| 40 | + } |
33 | 41 | return $string; |
34 | 42 | } |
35 | 43 | } |
— | — | @@ -71,8 +79,9 @@ |
72 | 80 | // This will cut out most of our slow time on Latin-based text, |
73 | 81 | // and 1/2 to 1/3 on East European and Asian scripts. |
74 | 82 | $bytePos = $splitPos; |
75 | | - while ($bytePos < $byteLen && $str{$bytePos} >= "\x80" && $str{$bytePos} < "\xc0") |
| 83 | + while ( $bytePos < $byteLen && $str{$bytePos} >= "\x80" && $str{$bytePos} < "\xc0" ) { |
76 | 84 | ++$bytePos; |
| 85 | + } |
77 | 86 | $charPos = mb_strlen( substr( $str, 0, $bytePos ) ); |
78 | 87 | } else { |
79 | 88 | $charPos = 0; |
— | — | @@ -82,8 +91,9 @@ |
83 | 92 | while( $charPos++ < $splitPos ) { |
84 | 93 | ++$bytePos; |
85 | 94 | // Move past any tail bytes |
86 | | - while ($bytePos < $byteLen && $str{$bytePos} >= "\x80" && $str{$bytePos} < "\xc0") |
| 95 | + while ( $bytePos < $byteLen && $str{$bytePos} >= "\x80" && $str{$bytePos} < "\xc0" ) { |
87 | 96 | ++$bytePos; |
| 97 | + } |
88 | 98 | } |
89 | 99 | } else { |
90 | 100 | $splitPosX = $splitPos + 1; |
— | — | @@ -92,8 +102,9 @@ |
93 | 103 | while( $bytePos > 0 && $charPos-- >= $splitPosX ) { |
94 | 104 | --$bytePos; |
95 | 105 | // Move past any tail bytes |
96 | | - while ($bytePos > 0 && $str{$bytePos} >= "\x80" && $str{$bytePos} < "\xc0") |
| 106 | + while ( $bytePos > 0 && $str{$bytePos} >= "\x80" && $str{$bytePos} < "\xc0" ) { |
97 | 107 | --$bytePos; |
| 108 | + } |
98 | 109 | } |
99 | 110 | } |
100 | 111 | |
— | — | @@ -108,7 +119,7 @@ |
109 | 120 | * @param string $enc optional encoding; ignored |
110 | 121 | * @return int |
111 | 122 | */ |
112 | | - function mb_strlen( $str, $enc="" ) { |
| 123 | + function mb_strlen( $str, $enc = '' ) { |
113 | 124 | $counts = count_chars( $str ); |
114 | 125 | $total = 0; |
115 | 126 | |
— | — | @@ -135,11 +146,11 @@ |
136 | 147 | * @param $encoding String: optional encoding; ignored |
137 | 148 | * @return int |
138 | 149 | */ |
139 | | - function mb_strpos( $haystack, $needle, $offset = 0, $encoding="" ) { |
| 150 | + function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) { |
140 | 151 | $needle = preg_quote( $needle, '/' ); |
141 | 152 | |
142 | 153 | $ar = array(); |
143 | | - preg_match( '/'.$needle.'/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset ); |
| 154 | + preg_match( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset ); |
144 | 155 | |
145 | 156 | if( isset( $ar[0][1] ) ) { |
146 | 157 | return $ar[0][1]; |
— | — | @@ -158,15 +169,15 @@ |
159 | 170 | * @param $encoding String: optional encoding; ignored |
160 | 171 | * @return int |
161 | 172 | */ |
162 | | - function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = "" ) { |
| 173 | + function mb_strrpos( $haystack, $needle, $offset = 0, $encoding = '' ) { |
163 | 174 | $needle = preg_quote( $needle, '/' ); |
164 | 175 | |
165 | 176 | $ar = array(); |
166 | | - preg_match_all( '/'.$needle.'/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset ); |
| 177 | + preg_match_all( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset ); |
167 | 178 | |
168 | 179 | if( isset( $ar[0] ) && count( $ar[0] ) > 0 && |
169 | | - isset( $ar[0][count($ar[0])-1][1] ) ) { |
170 | | - return $ar[0][count($ar[0])-1][1]; |
| 180 | + isset( $ar[0][count( $ar[0] ) - 1][1] ) ) { |
| 181 | + return $ar[0][count( $ar[0] ) - 1][1]; |
171 | 182 | } else { |
172 | 183 | return false; |
173 | 184 | } |
— | — | @@ -232,7 +243,7 @@ |
233 | 244 | # The maximum random value is "only" 2^31-1, so get two random |
234 | 245 | # values to reduce the chance of dupes |
235 | 246 | $max = mt_getrandmax() + 1; |
236 | | - $rand = number_format( (mt_rand() * $max + mt_rand()) |
| 247 | + $rand = number_format( ( mt_rand() * $max + mt_rand() ) |
237 | 248 | / $max / $max, 12, '.', '' ); |
238 | 249 | return $rand; |
239 | 250 | } |
— | — | @@ -262,8 +273,8 @@ |
263 | 274 | function wfUrlencode( $s ) { |
264 | 275 | static $needle; |
265 | 276 | if ( is_null( $needle ) ) { |
266 | | - $needle = array( '%3B','%40','%24','%21','%2A','%28','%29','%2C','%2F' ); |
267 | | - if (! isset($_SERVER['SERVER_SOFTWARE']) || ( strpos($_SERVER['SERVER_SOFTWARE'], "Microsoft-IIS/7") === false)) { |
| 277 | + $needle = array( '%3B', '%40', '%24', '%21', '%2A', '%28', '%29', '%2C', '%2F' ); |
| 278 | + if ( !isset( $_SERVER['SERVER_SOFTWARE'] ) || ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7' ) === false ) ) { |
268 | 279 | $needle[] = '%3A'; |
269 | 280 | } |
270 | 281 | } |
— | — | @@ -271,7 +282,7 @@ |
272 | 283 | $s = urlencode( $s ); |
273 | 284 | $s = str_ireplace( |
274 | 285 | $needle, |
275 | | - array( ';', '@', '$', '!', '*', '(', ')', ',', '/', ':' ), |
| 286 | + array( ';', '@', '$', '!', '*', '(', ')', ',', '/', ':' ), |
276 | 287 | $s |
277 | 288 | ); |
278 | 289 | |
— | — | @@ -334,7 +345,9 @@ |
335 | 346 | |
336 | 347 | function wfDebugTimer() { |
337 | 348 | global $wgDebugTimestamps; |
338 | | - if ( !$wgDebugTimestamps ) return ''; |
| 349 | + if ( !$wgDebugTimestamps ) { |
| 350 | + return ''; |
| 351 | + } |
339 | 352 | static $start = null; |
340 | 353 | |
341 | 354 | if ( $start === null ) { |
— | — | @@ -372,7 +385,7 @@ |
373 | 386 | */ |
374 | 387 | function wfDebugLog( $logGroup, $text, $public = true ) { |
375 | 388 | global $wgDebugLogGroups, $wgShowHostnames; |
376 | | - $text = trim($text)."\n"; |
| 389 | + $text = trim( $text ) . "\n"; |
377 | 390 | if( isset( $wgDebugLogGroups[$logGroup] ) ) { |
378 | 391 | $time = wfTimestamp( TS_DB ); |
379 | 392 | $wiki = wfWikiID(); |
— | — | @@ -382,7 +395,7 @@ |
383 | 396 | $host = ''; |
384 | 397 | } |
385 | 398 | wfErrorLog( "$time $host $wiki: $text", $wgDebugLogGroups[$logGroup] ); |
386 | | - } else if ( $public === true ) { |
| 399 | + } elseif ( $public === true ) { |
387 | 400 | wfDebug( $text, true ); |
388 | 401 | } |
389 | 402 | } |
— | — | @@ -395,7 +408,7 @@ |
396 | 409 | global $wgDBerrorLog, $wgDBname; |
397 | 410 | if ( $wgDBerrorLog ) { |
398 | 411 | $host = trim(`hostname`); |
399 | | - $text = date('D M j G:i:s T Y') . "\t$host\t$wgDBname\t$text"; |
| 412 | + $text = date( 'D M j G:i:s T Y' ) . "\t$host\t$wgDBname\t$text"; |
400 | 413 | wfErrorLog( $text, $wgDBerrorLog ); |
401 | 414 | } |
402 | 415 | } |
— | — | @@ -426,7 +439,7 @@ |
427 | 440 | $prefix = isset( $m[4] ) ? $m[4] : false; |
428 | 441 | $domain = AF_INET; |
429 | 442 | } else { |
430 | | - throw new MWException( __METHOD__.": Invalid UDP specification" ); |
| 443 | + throw new MWException( __METHOD__ . ': Invalid UDP specification' ); |
431 | 444 | } |
432 | 445 | // Clean it up for the multiplexer |
433 | 446 | if ( strval( $prefix ) !== '' ) { |
— | — | @@ -460,29 +473,38 @@ |
461 | 474 | global $wgRequestTime, $wgDebugLogFile, $wgDebugRawPage, $wgRequest; |
462 | 475 | global $wgProfiler, $wgProfileLimit, $wgUser; |
463 | 476 | # Profiling must actually be enabled... |
464 | | - if( is_null( $wgProfiler ) ) return; |
| 477 | + if( is_null( $wgProfiler ) ) { |
| 478 | + return; |
| 479 | + } |
465 | 480 | # Get total page request time |
466 | 481 | $now = wfTime(); |
467 | 482 | $elapsed = $now - $wgRequestTime; |
468 | 483 | # Only show pages that longer than $wgProfileLimit time (default is 0) |
469 | | - if( $elapsed <= $wgProfileLimit ) return; |
| 484 | + if( $elapsed <= $wgProfileLimit ) { |
| 485 | + return; |
| 486 | + } |
470 | 487 | $prof = wfGetProfilingOutput( $wgRequestTime, $elapsed ); |
471 | 488 | $forward = ''; |
472 | | - if( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) |
| 489 | + if( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
473 | 490 | $forward = ' forwarded for ' . $_SERVER['HTTP_X_FORWARDED_FOR']; |
474 | | - if( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) |
| 491 | + } |
| 492 | + if( !empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
475 | 493 | $forward .= ' client IP ' . $_SERVER['HTTP_CLIENT_IP']; |
476 | | - if( !empty( $_SERVER['HTTP_FROM'] ) ) |
| 494 | + } |
| 495 | + if( !empty( $_SERVER['HTTP_FROM'] ) ) { |
477 | 496 | $forward .= ' from ' . $_SERVER['HTTP_FROM']; |
478 | | - if( $forward ) |
| 497 | + } |
| 498 | + if( $forward ) { |
479 | 499 | $forward = "\t(proxied via {$_SERVER['REMOTE_ADDR']}{$forward})"; |
| 500 | + } |
480 | 501 | // Don't unstub $wgUser at this late stage just for statistics purposes |
481 | | - if( StubObject::isRealObject($wgUser) && $wgUser->isAnon() ) |
| 502 | + if( StubObject::isRealObject( $wgUser ) && $wgUser->isAnon() ) { |
482 | 503 | $forward .= ' anon'; |
| 504 | + } |
483 | 505 | $log = sprintf( "%s\t%04.3f\t%s\n", |
484 | | - gmdate( 'YmdHis' ), $elapsed, |
485 | | - urldecode( $wgRequest->getRequestURL() . $forward ) ); |
486 | | - if ( $wgDebugLogFile != '' && ( $wgRequest->getVal('action') != 'raw' || $wgDebugRawPage ) ) { |
| 506 | + gmdate( 'YmdHis' ), $elapsed, |
| 507 | + urldecode( $wgRequest->getRequestURL() . $forward ) ); |
| 508 | + if ( $wgDebugLogFile != '' && ( $wgRequest->getVal( 'action' ) != 'raw' || $wgDebugRawPage ) ) { |
487 | 509 | wfErrorLog( $log . $prof, $wgDebugLogFile ); |
488 | 510 | } |
489 | 511 | } |
— | — | @@ -607,7 +629,7 @@ |
608 | 630 | * Get a message from anywhere, for the current global language |
609 | 631 | * set with $wgLanguageCode. |
610 | 632 | * |
611 | | - * Use this if the message should NOT change dependent on the |
| 633 | + * Use this if the message should NOT change dependent on the |
612 | 634 | * language set in the user's preferences. This is the case for |
613 | 635 | * most text written into logs, as well as link targets (such as |
614 | 636 | * the name of the copyright policy page). Link titles, on the |
— | — | @@ -632,7 +654,9 @@ |
633 | 655 | $forcontent = true; |
634 | 656 | if( is_array( $wgForceUIMsgAsContentMsg ) && |
635 | 657 | in_array( $key, $wgForceUIMsgAsContentMsg ) ) |
| 658 | + { |
636 | 659 | $forcontent = false; |
| 660 | + } |
637 | 661 | return wfMsgReal( $key, $args, true, $forcontent ); |
638 | 662 | } |
639 | 663 | |
— | — | @@ -646,7 +670,9 @@ |
647 | 671 | $forcontent = true; |
648 | 672 | if( is_array( $wgForceUIMsgAsContentMsg ) && |
649 | 673 | in_array( $key, $wgForceUIMsgAsContentMsg ) ) |
| 674 | + { |
650 | 675 | $forcontent = false; |
| 676 | + } |
651 | 677 | return wfMsgReal( $key, $args, true, $forcontent, false ); |
652 | 678 | } |
653 | 679 | |
— | — | @@ -669,7 +695,9 @@ |
670 | 696 | $forcontent = true; |
671 | 697 | if( is_array( $wgForceUIMsgAsContentMsg ) && |
672 | 698 | in_array( $key, $wgForceUIMsgAsContentMsg ) ) |
| 699 | + { |
673 | 700 | $forcontent = false; |
| 701 | + } |
674 | 702 | return wfMsgReal( $key, $args, false, $forcontent ); |
675 | 703 | } |
676 | 704 | |
— | — | @@ -697,10 +725,11 @@ |
698 | 726 | */ |
699 | 727 | function wfMsgWeirdKey( $key ) { |
700 | 728 | $source = wfMsgGetKey( $key, false, true, false ); |
701 | | - if ( wfEmptyMsg( $key, $source ) ) |
702 | | - return ""; |
703 | | - else |
| 729 | + if ( wfEmptyMsg( $key, $source ) ) { |
| 730 | + return ''; |
| 731 | + } else { |
704 | 732 | return $source; |
| 733 | + } |
705 | 734 | } |
706 | 735 | |
707 | 736 | /** |
— | — | @@ -715,14 +744,14 @@ |
716 | 745 | function wfMsgGetKey( $key, $useDB, $langCode = false, $transform = true ) { |
717 | 746 | global $wgMessageCache; |
718 | 747 | |
719 | | - wfRunHooks('NormalizeMessageKey', array(&$key, &$useDB, &$langCode, &$transform)); |
| 748 | + wfRunHooks( 'NormalizeMessageKey', array( &$key, &$useDB, &$langCode, &$transform ) ); |
720 | 749 | |
721 | 750 | if ( !is_object( $wgMessageCache ) ) { |
722 | | - throw new MWException( "Trying to get message before message cache is initialised" ); |
| 751 | + throw new MWException( 'Trying to get message before message cache is initialised' ); |
723 | 752 | } |
724 | 753 | |
725 | 754 | $message = $wgMessageCache->get( $key, $useDB, $langCode ); |
726 | | - if( $message === false ){ |
| 755 | + if( $message === false ) { |
727 | 756 | $message = '<' . htmlspecialchars( $key ) . '>'; |
728 | 757 | } elseif ( $transform ) { |
729 | 758 | $message = $wgMessageCache->transform( $message ); |
— | — | @@ -750,7 +779,7 @@ |
751 | 780 | } |
752 | 781 | $replacementKeys = array(); |
753 | 782 | foreach( $args as $n => $param ) { |
754 | | - $replacementKeys['$' . ($n + 1)] = $param; |
| 783 | + $replacementKeys['$' . ( $n + 1 )] = $param; |
755 | 784 | } |
756 | 785 | $message = strtr( $message, $replacementKeys ); |
757 | 786 | } |
— | — | @@ -797,8 +826,8 @@ |
798 | 827 | * Returns message in the requested format |
799 | 828 | * @param $key String: key of the message |
800 | 829 | * @param $options Array: processing rules. Can take the following options: |
801 | | - * <i>parse</i>: parses wikitext to html |
802 | | - * <i>parseinline</i>: parses wikitext to html and removes the surrounding |
| 830 | + * <i>parse</i>: parses wikitext to HTML |
| 831 | + * <i>parseinline</i>: parses wikitext to HTML and removes the surrounding |
803 | 832 | * p's added by parser or tidy |
804 | 833 | * <i>escape</i>: filters message through htmlspecialchars |
805 | 834 | * <i>escapenoentities</i>: same, but allows entity references like   through |
— | — | @@ -831,10 +860,10 @@ |
832 | 861 | } |
833 | 862 | } |
834 | 863 | |
835 | | - if( in_array('content', $options, true ) ) { |
| 864 | + if( in_array( 'content', $options, true ) ) { |
836 | 865 | $forContent = true; |
837 | 866 | $langCode = true; |
838 | | - } elseif( array_key_exists('language', $options) ) { |
| 867 | + } elseif( array_key_exists( 'language', $options ) ) { |
839 | 868 | $forContent = false; |
840 | 869 | $langCode = wfGetLangObj( $options['language'] ); |
841 | 870 | } else { |
— | — | @@ -844,19 +873,19 @@ |
845 | 874 | |
846 | 875 | $string = wfMsgGetKey( $key, /*DB*/true, $langCode, /*Transform*/false ); |
847 | 876 | |
848 | | - if( !in_array('replaceafter', $options, true ) ) { |
| 877 | + if( !in_array( 'replaceafter', $options, true ) ) { |
849 | 878 | $string = wfMsgReplaceArgs( $string, $args ); |
850 | 879 | } |
851 | 880 | |
852 | | - if( in_array('parse', $options, true ) ) { |
| 881 | + if( in_array( 'parse', $options, true ) ) { |
853 | 882 | $string = $wgOut->parse( $string, true, !$forContent ); |
854 | | - } elseif ( in_array('parseinline', $options, true ) ) { |
| 883 | + } elseif ( in_array( 'parseinline', $options, true ) ) { |
855 | 884 | $string = $wgOut->parse( $string, true, !$forContent ); |
856 | 885 | $m = array(); |
857 | 886 | if( preg_match( '/^<p>(.*)\n?<\/p>\n?$/sU', $string, $m ) ) { |
858 | 887 | $string = $m[1]; |
859 | 888 | } |
860 | | - } elseif ( in_array('parsemag', $options, true ) ) { |
| 889 | + } elseif ( in_array( 'parsemag', $options, true ) ) { |
861 | 890 | global $wgMessageCache; |
862 | 891 | if ( isset( $wgMessageCache ) ) { |
863 | 892 | $string = $wgMessageCache->transform( $string, |
— | — | @@ -865,13 +894,13 @@ |
866 | 895 | } |
867 | 896 | } |
868 | 897 | |
869 | | - if ( in_array('escape', $options, true ) ) { |
| 898 | + if ( in_array( 'escape', $options, true ) ) { |
870 | 899 | $string = htmlspecialchars ( $string ); |
871 | | - } elseif ( in_array( 'escapenoentities', $options, true ) ) { |
| 900 | + } elseif ( in_array( 'escapenoentities', $options, true ) ) { |
872 | 901 | $string = Sanitizer::escapeHtmlAllowEntities( $string ); |
873 | 902 | } |
874 | 903 | |
875 | | - if( in_array('replaceafter', $options, true ) ) { |
| 904 | + if( in_array( 'replaceafter', $options, true ) ) { |
876 | 905 | $string = wfMsgReplaceArgs( $string, $args ); |
877 | 906 | } |
878 | 907 | |
— | — | @@ -885,22 +914,22 @@ |
886 | 915 | * |
887 | 916 | * @deprecated Please return control to the caller or throw an exception |
888 | 917 | */ |
889 | | -function wfAbruptExit( $error = false ){ |
| 918 | +function wfAbruptExit( $error = false ) { |
890 | 919 | static $called = false; |
891 | | - if ( $called ){ |
| 920 | + if ( $called ) { |
892 | 921 | exit( -1 ); |
893 | 922 | } |
894 | 923 | $called = true; |
895 | 924 | |
896 | 925 | $bt = wfDebugBacktrace(); |
897 | 926 | if( $bt ) { |
898 | | - for($i = 0; $i < count($bt) ; $i++){ |
899 | | - $file = isset($bt[$i]['file']) ? $bt[$i]['file'] : "unknown"; |
900 | | - $line = isset($bt[$i]['line']) ? $bt[$i]['line'] : "unknown"; |
901 | | - wfDebug("WARNING: Abrupt exit in $file at line $line\n"); |
| 927 | + for( $i = 0; $i < count( $bt ); $i++ ) { |
| 928 | + $file = isset( $bt[$i]['file'] ) ? $bt[$i]['file'] : 'unknown'; |
| 929 | + $line = isset( $bt[$i]['line'] ) ? $bt[$i]['line'] : 'unknown'; |
| 930 | + wfDebug( "WARNING: Abrupt exit in $file at line $line\n"); |
902 | 931 | } |
903 | 932 | } else { |
904 | | - wfDebug("WARNING: Abrupt exit\n"); |
| 933 | + wfDebug( "WARNING: Abrupt exit\n" ); |
905 | 934 | } |
906 | 935 | |
907 | 936 | wfLogProfilingData(); |
— | — | @@ -923,7 +952,7 @@ |
924 | 953 | * Plain die() fails to return nonzero to the shell if you pass a string. |
925 | 954 | * @param $msg String |
926 | 955 | */ |
927 | | -function wfDie( $msg='' ) { |
| 956 | +function wfDie( $msg = '' ) { |
928 | 957 | echo $msg; |
929 | 958 | die( 1 ); |
930 | 959 | } |
— | — | @@ -978,8 +1007,8 @@ |
979 | 1008 | $elapsed = $now - $wgRequestTime; |
980 | 1009 | |
981 | 1010 | return $wgShowHostnames |
982 | | - ? sprintf( "<!-- Served by %s in %01.3f secs. -->", wfHostname(), $elapsed ) |
983 | | - : sprintf( "<!-- Served in %01.3f secs. -->", $elapsed ); |
| 1011 | + ? sprintf( '<!-- Served by %s in %01.3f secs. -->', wfHostname(), $elapsed ) |
| 1012 | + : sprintf( '<!-- Served in %01.3f secs. -->', $elapsed ); |
984 | 1013 | } |
985 | 1014 | |
986 | 1015 | /** |
— | — | @@ -1032,7 +1061,7 @@ |
1033 | 1062 | foreach( $backtrace as $call ) { |
1034 | 1063 | if( isset( $call['file'] ) ) { |
1035 | 1064 | $f = explode( DIRECTORY_SEPARATOR, $call['file'] ); |
1036 | | - $file = $f[count($f)-1]; |
| 1065 | + $file = $f[count( $f ) - 1]; |
1037 | 1066 | } else { |
1038 | 1067 | $file = '-'; |
1039 | 1068 | } |
— | — | @@ -1046,7 +1075,9 @@ |
1047 | 1076 | } else { |
1048 | 1077 | $msg .= '<li>' . $file . ' line ' . $line . ' calls '; |
1049 | 1078 | } |
1050 | | - if( !empty( $call['class'] ) ) $msg .= $call['class'] . '::'; |
| 1079 | + if( !empty( $call['class'] ) ) { |
| 1080 | + $msg .= $call['class'] . '::'; |
| 1081 | + } |
1051 | 1082 | $msg .= $call['function'] . '()'; |
1052 | 1083 | |
1053 | 1084 | if ( $wgCommandLineMode ) { |
— | — | @@ -1073,8 +1104,12 @@ |
1074 | 1105 | */ |
1075 | 1106 | function wfShowingResults( $offset, $limit ) { |
1076 | 1107 | global $wgLang; |
1077 | | - return wfMsgExt( 'showingresults', array( 'parseinline' ), $wgLang->formatNum( $limit ), |
1078 | | - $wgLang->formatNum( $offset+1 ) ); |
| 1108 | + return wfMsgExt( |
| 1109 | + 'showingresults', |
| 1110 | + array( 'parseinline' ), |
| 1111 | + $wgLang->formatNum( $limit ), |
| 1112 | + $wgLang->formatNum( $offset + 1 ) |
| 1113 | + ); |
1079 | 1114 | } |
1080 | 1115 | |
1081 | 1116 | /** |
— | — | @@ -1082,8 +1117,13 @@ |
1083 | 1118 | */ |
1084 | 1119 | function wfShowingResultsNum( $offset, $limit, $num ) { |
1085 | 1120 | global $wgLang; |
1086 | | - return wfMsgExt( 'showingresultsnum', array( 'parseinline' ), $wgLang->formatNum( $limit ), |
1087 | | - $wgLang->formatNum( $offset+1 ), $wgLang->formatNum( $num ) ); |
| 1121 | + return wfMsgExt( |
| 1122 | + 'showingresultsnum', |
| 1123 | + array( 'parseinline' ), |
| 1124 | + $wgLang->formatNum( $limit ), |
| 1125 | + $wgLang->formatNum( $offset + 1 ), |
| 1126 | + $wgLang->formatNum( $num ) |
| 1127 | + ); |
1088 | 1128 | } |
1089 | 1129 | |
1090 | 1130 | /** |
— | — | @@ -1099,11 +1139,11 @@ |
1100 | 1140 | $fmtLimit = $wgLang->formatNum( $limit ); |
1101 | 1141 | // FIXME: Why on earth this needs one message for the text and another one for tooltip?? |
1102 | 1142 | # Get prev/next link display text |
1103 | | - $prev = wfMsgExt( 'prevn', array('parsemag','escape'), $fmtLimit ); |
1104 | | - $next = wfMsgExt( 'nextn', array('parsemag','escape'), $fmtLimit ); |
| 1143 | + $prev = wfMsgExt( 'prevn', array( 'parsemag', 'escape' ), $fmtLimit ); |
| 1144 | + $next = wfMsgExt( 'nextn', array( 'parsemag', 'escape' ), $fmtLimit ); |
1105 | 1145 | # Get prev/next link title text |
1106 | | - $pTitle = wfMsgExt( 'prevn-title', array('parsemag','escape'), $fmtLimit ); |
1107 | | - $nTitle = wfMsgExt( 'nextn-title', array('parsemag','escape'), $fmtLimit ); |
| 1146 | + $pTitle = wfMsgExt( 'prevn-title', array( 'parsemag', 'escape' ), $fmtLimit ); |
| 1147 | + $nTitle = wfMsgExt( 'nextn-title', array( 'parsemag', 'escape' ), $fmtLimit ); |
1108 | 1148 | # Fetch the title object |
1109 | 1149 | if( is_object( $link ) ) { |
1110 | 1150 | $title =& $link; |
— | — | @@ -1116,12 +1156,12 @@ |
1117 | 1157 | # Make 'previous' link |
1118 | 1158 | if( 0 != $offset ) { |
1119 | 1159 | $po = $offset - $limit; |
1120 | | - $po = max($po,0); |
| 1160 | + $po = max( $po, 0 ); |
1121 | 1161 | $q = "limit={$limit}&offset={$po}"; |
1122 | 1162 | if( $query != '' ) { |
1123 | | - $q .= '&'.$query; |
| 1163 | + $q .= '&' . $query; |
1124 | 1164 | } |
1125 | | - $plink = '<a href="' . $title->escapeLocalUrl( $q ) . "\" title=\"{$pTitle}\" class=\"mw-prevlink\">{$prev}</a>"; |
| 1165 | + $plink = '<a href="' . $title->escapeLocalURL( $q ) . "\" title=\"{$pTitle}\" class=\"mw-prevlink\">{$prev}</a>"; |
1126 | 1166 | } else { |
1127 | 1167 | $plink = $prev; |
1128 | 1168 | } |
— | — | @@ -1129,12 +1169,12 @@ |
1130 | 1170 | $no = $offset + $limit; |
1131 | 1171 | $q = "limit={$limit}&offset={$no}"; |
1132 | 1172 | if( $query != '' ) { |
1133 | | - $q .= '&'.$query; |
| 1173 | + $q .= '&' . $query; |
1134 | 1174 | } |
1135 | 1175 | if( $atend ) { |
1136 | 1176 | $nlink = $next; |
1137 | 1177 | } else { |
1138 | | - $nlink = '<a href="' . $title->escapeLocalUrl( $q ) . "\" title=\"{$nTitle}\" class=\"mw-nextlink\">{$next}</a>"; |
| 1178 | + $nlink = '<a href="' . $title->escapeLocalURL( $q ) . "\" title=\"{$nTitle}\" class=\"mw-nextlink\">{$next}</a>"; |
1139 | 1179 | } |
1140 | 1180 | # Make links to set number of items per page |
1141 | 1181 | $nums = $wgLang->pipeList( array( |
— | — | @@ -1163,8 +1203,8 @@ |
1164 | 1204 | } |
1165 | 1205 | $q .= "limit={$limit}&offset={$offset}"; |
1166 | 1206 | $fmtLimit = $wgLang->formatNum( $limit ); |
1167 | | - $lTitle = wfMsgExt('shown-title',array('parsemag','escape'),$limit); |
1168 | | - $s = '<a href="' . $title->escapeLocalUrl( $q ) . "\" title=\"{$lTitle}\" class=\"mw-numlink\">{$fmtLimit}</a>"; |
| 1207 | + $lTitle = wfMsgExt( 'shown-title', array( 'parsemag', 'escape' ), $limit ); |
| 1208 | + $s = '<a href="' . $title->escapeLocalURL( $q ) . "\" title=\"{$lTitle}\" class=\"mw-numlink\">{$fmtLimit}</a>"; |
1169 | 1209 | return $s; |
1170 | 1210 | } |
1171 | 1211 | |
— | — | @@ -1181,8 +1221,12 @@ |
1182 | 1222 | if( preg_match( |
1183 | 1223 | '/\bgzip(?:;(q)=([0-9]+(?:\.[0-9]+)))?\b/', |
1184 | 1224 | $_SERVER['HTTP_ACCEPT_ENCODING'], |
1185 | | - $m ) ) { |
1186 | | - if( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) return false; |
| 1225 | + $m ) |
| 1226 | + ) |
| 1227 | + { |
| 1228 | + if( isset( $m[2] ) && ( $m[1] == 'q' ) && ( $m[2] == 0 ) ) { |
| 1229 | + return false; |
| 1230 | + } |
1187 | 1231 | wfDebug( " accepts gzip\n" ); |
1188 | 1232 | return true; |
1189 | 1233 | } |
— | — | @@ -1218,7 +1262,8 @@ |
1219 | 1263 | $text = str_replace( |
1220 | 1264 | array( '[', '|', ']', '\'', 'ISBN ', 'RFC ', '://', "\n=", '{{' ), # }} |
1221 | 1265 | array( '[', '|', ']', ''', 'ISBN ', 'RFC ', '://', "\n=", '{{' ), |
1222 | | - htmlspecialchars($text) ); |
| 1266 | + htmlspecialchars( $text ) |
| 1267 | + ); |
1223 | 1268 | return $text; |
1224 | 1269 | } |
1225 | 1270 | |
— | — | @@ -1236,7 +1281,9 @@ |
1237 | 1282 | |
1238 | 1283 | $illegal = '\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\xff='; |
1239 | 1284 | $replace = $illegal . '\t ?_'; |
1240 | | - if( !preg_match( "/[$illegal]/", $string ) ) return $string; |
| 1285 | + if( !preg_match( "/[$illegal]/", $string ) ) { |
| 1286 | + return $string; |
| 1287 | + } |
1241 | 1288 | $out = "=?$charset?Q?"; |
1242 | 1289 | $out .= preg_replace( "/([$replace])/e", 'sprintf("=%02X",ord("$1"))', $string ); |
1243 | 1290 | $out .= '?='; |
— | — | @@ -1249,7 +1296,7 @@ |
1250 | 1297 | * @return float |
1251 | 1298 | */ |
1252 | 1299 | function wfTime() { |
1253 | | - return microtime(true); |
| 1300 | + return microtime( true ); |
1254 | 1301 | } |
1255 | 1302 | |
1256 | 1303 | /** |
— | — | @@ -1268,7 +1315,7 @@ |
1269 | 1316 | * As for wfSetVar except setting a bit |
1270 | 1317 | */ |
1271 | 1318 | function wfSetBit( &$dest, $bit, $state = true ) { |
1272 | | - $temp = (bool)($dest & $bit ); |
| 1319 | + $temp = (bool)( $dest & $bit ); |
1273 | 1320 | if ( !is_null( $state ) ) { |
1274 | 1321 | if ( $state ) { |
1275 | 1322 | $dest |= $bit; |
— | — | @@ -1284,8 +1331,7 @@ |
1285 | 1332 | * "days=7&limit=100". Options in the first array override options in the second. |
1286 | 1333 | * Options set to "" will not be output. |
1287 | 1334 | */ |
1288 | | -function wfArrayToCGI( $array1, $array2 = null ) |
1289 | | -{ |
| 1335 | +function wfArrayToCGI( $array1, $array2 = null ) { |
1290 | 1336 | if ( !is_null( $array2 ) ) { |
1291 | 1337 | $array1 = $array1 + $array2; |
1292 | 1338 | } |
— | — | @@ -1327,7 +1373,7 @@ |
1328 | 1374 | * @return array Array version of input |
1329 | 1375 | */ |
1330 | 1376 | function wfCgiToArray( $query ) { |
1331 | | - if( isset( $query[0] ) and $query[0] == '?' ) { |
| 1377 | + if( isset( $query[0] ) && $query[0] == '?' ) { |
1332 | 1378 | $query = substr( $query, 1 ); |
1333 | 1379 | } |
1334 | 1380 | $bits = explode( '&', $query ); |
— | — | @@ -1393,7 +1439,7 @@ |
1394 | 1440 | * This is obsolete, use SquidUpdate::purge() |
1395 | 1441 | * @deprecated |
1396 | 1442 | */ |
1397 | | -function wfPurgeSquidServers ($urlArr) { |
| 1443 | +function wfPurgeSquidServers( $urlArr ) { |
1398 | 1444 | SquidUpdate::purge( $urlArr ); |
1399 | 1445 | } |
1400 | 1446 | |
— | — | @@ -1429,7 +1475,7 @@ |
1430 | 1476 | if ( $iteration % 2 == 1 ) { |
1431 | 1477 | // Delimiter, a double quote preceded by zero or more slashes |
1432 | 1478 | $arg .= str_replace( '\\', '\\\\', substr( $token, 0, -1 ) ) . '\\"'; |
1433 | | - } else if ( $iteration % 4 == 2 ) { |
| 1479 | + } elseif ( $iteration % 4 == 2 ) { |
1434 | 1480 | // ^ in $token will be outside quotes, need to be escaped |
1435 | 1481 | $arg .= str_replace( '^', '^^', $token ); |
1436 | 1482 | } else { // $iteration % 4 == 0 |
— | — | @@ -1458,7 +1504,7 @@ |
1459 | 1505 | * wfMerge attempts to merge differences between three texts. |
1460 | 1506 | * Returns true for a clean merge and false for failure or a conflict. |
1461 | 1507 | */ |
1462 | | -function wfMerge( $old, $mine, $yours, &$result ){ |
| 1508 | +function wfMerge( $old, $mine, $yours, &$result ) { |
1463 | 1509 | global $wgDiff3; |
1464 | 1510 | |
1465 | 1511 | # This check may also protect against code injection in |
— | — | @@ -1474,18 +1520,21 @@ |
1475 | 1521 | $mytextFile = fopen( $mytextName = tempnam( $td, 'merge-mine-' ), 'w' ); |
1476 | 1522 | $yourtextFile = fopen( $yourtextName = tempnam( $td, 'merge-your-' ), 'w' ); |
1477 | 1523 | |
1478 | | - fwrite( $oldtextFile, $old ); fclose( $oldtextFile ); |
1479 | | - fwrite( $mytextFile, $mine ); fclose( $mytextFile ); |
1480 | | - fwrite( $yourtextFile, $yours ); fclose( $yourtextFile ); |
| 1524 | + fwrite( $oldtextFile, $old ); |
| 1525 | + fclose( $oldtextFile ); |
| 1526 | + fwrite( $mytextFile, $mine ); |
| 1527 | + fclose( $mytextFile ); |
| 1528 | + fwrite( $yourtextFile, $yours ); |
| 1529 | + fclose( $yourtextFile ); |
1481 | 1530 | |
1482 | 1531 | # Check for a conflict |
1483 | 1532 | $cmd = $wgDiff3 . ' -a --overlap-only ' . |
1484 | | - wfEscapeShellArg( $mytextName ) . ' ' . |
1485 | | - wfEscapeShellArg( $oldtextName ) . ' ' . |
1486 | | - wfEscapeShellArg( $yourtextName ); |
| 1533 | + wfEscapeShellArg( $mytextName ) . ' ' . |
| 1534 | + wfEscapeShellArg( $oldtextName ) . ' ' . |
| 1535 | + wfEscapeShellArg( $yourtextName ); |
1487 | 1536 | $handle = popen( $cmd, 'r' ); |
1488 | 1537 | |
1489 | | - if( fgets( $handle, 1024 ) ){ |
| 1538 | + if( fgets( $handle, 1024 ) ) { |
1490 | 1539 | $conflict = true; |
1491 | 1540 | } else { |
1492 | 1541 | $conflict = false; |
— | — | @@ -1494,7 +1543,7 @@ |
1495 | 1544 | |
1496 | 1545 | # Merge differences |
1497 | 1546 | $cmd = $wgDiff3 . ' -a -e --merge ' . |
1498 | | - wfEscapeShellArg( $mytextName, $oldtextName, $yourtextName ); |
| 1547 | + wfEscapeShellArg( $mytextName, $oldtextName, $yourtextName ); |
1499 | 1548 | $handle = popen( $cmd, 'r' ); |
1500 | 1549 | $result = ''; |
1501 | 1550 | do { |
— | — | @@ -1505,13 +1554,15 @@ |
1506 | 1555 | $result .= $data; |
1507 | 1556 | } while ( true ); |
1508 | 1557 | pclose( $handle ); |
1509 | | - unlink( $mytextName ); unlink( $oldtextName ); unlink( $yourtextName ); |
| 1558 | + unlink( $mytextName ); |
| 1559 | + unlink( $oldtextName ); |
| 1560 | + unlink( $yourtextName ); |
1510 | 1561 | |
1511 | 1562 | if ( $result === '' && $old !== '' && !$conflict ) { |
1512 | 1563 | wfDebug( "Unexpected null result from diff3. Command: $cmd\n" ); |
1513 | 1564 | $conflict = true; |
1514 | 1565 | } |
1515 | | - return ! $conflict; |
| 1566 | + return !$conflict; |
1516 | 1567 | } |
1517 | 1568 | |
1518 | 1569 | /** |
— | — | @@ -1523,7 +1574,7 @@ |
1524 | 1575 | * @return String: unified diff of $before and $after |
1525 | 1576 | */ |
1526 | 1577 | function wfDiff( $before, $after, $params = '-u' ) { |
1527 | | - if ($before == $after) { |
| 1578 | + if ( $before == $after ) { |
1528 | 1579 | return ''; |
1529 | 1580 | } |
1530 | 1581 | |
— | — | @@ -1531,7 +1582,7 @@ |
1532 | 1583 | |
1533 | 1584 | # This check may also protect against code injection in |
1534 | 1585 | # case of broken installations. |
1535 | | - if( !file_exists( $wgDiff ) ){ |
| 1586 | + if( !file_exists( $wgDiff ) ) { |
1536 | 1587 | wfDebug( "diff executable not found\n" ); |
1537 | 1588 | $diffs = new Diff( explode( "\n", $before ), explode( "\n", $after ) ); |
1538 | 1589 | $format = new UnifiedDiffFormatter(); |
— | — | @@ -1543,11 +1594,13 @@ |
1544 | 1595 | $oldtextFile = fopen( $oldtextName = tempnam( $td, 'merge-old-' ), 'w' ); |
1545 | 1596 | $newtextFile = fopen( $newtextName = tempnam( $td, 'merge-your-' ), 'w' ); |
1546 | 1597 | |
1547 | | - fwrite( $oldtextFile, $before ); fclose( $oldtextFile ); |
1548 | | - fwrite( $newtextFile, $after ); fclose( $newtextFile ); |
| 1598 | + fwrite( $oldtextFile, $before ); |
| 1599 | + fclose( $oldtextFile ); |
| 1600 | + fwrite( $newtextFile, $after ); |
| 1601 | + fclose( $newtextFile ); |
1549 | 1602 | |
1550 | 1603 | // Get the diff of the two files |
1551 | | - $cmd = "$wgDiff " . $params . ' ' .wfEscapeShellArg( $oldtextName, $newtextName ); |
| 1604 | + $cmd = "$wgDiff " . $params . ' ' . wfEscapeShellArg( $oldtextName, $newtextName ); |
1552 | 1605 | |
1553 | 1606 | $h = popen( $cmd, 'r' ); |
1554 | 1607 | |
— | — | @@ -1568,11 +1621,11 @@ |
1569 | 1622 | |
1570 | 1623 | // Kill the --- and +++ lines. They're not useful. |
1571 | 1624 | $diff_lines = explode( "\n", $diff ); |
1572 | | - if (strpos( $diff_lines[0], '---' ) === 0) { |
1573 | | - unset($diff_lines[0]); |
| 1625 | + if ( strpos( $diff_lines[0], '---' ) === 0 ) { |
| 1626 | + unset( $diff_lines[0] ); |
1574 | 1627 | } |
1575 | | - if (strpos( $diff_lines[1], '+++' ) === 0) { |
1576 | | - unset($diff_lines[1]); |
| 1628 | + if ( strpos( $diff_lines[1], '+++' ) === 0 ) { |
| 1629 | + unset( $diff_lines[1] ); |
1577 | 1630 | } |
1578 | 1631 | |
1579 | 1632 | $diff = implode( "\n", $diff_lines ); |
— | — | @@ -1588,7 +1641,7 @@ |
1589 | 1642 | */ |
1590 | 1643 | function wfVarDump( $var ) { |
1591 | 1644 | global $wgOut; |
1592 | | - $s = str_replace("\n","<br />\n", var_export( $var, true ) . "\n"); |
| 1645 | + $s = str_replace( "\n", "<br />\n", var_export( $var, true ) . "\n" ); |
1593 | 1646 | if ( headers_sent() || !@is_object( $wgOut ) ) { |
1594 | 1647 | print $s; |
1595 | 1648 | } else { |
— | — | @@ -1608,11 +1661,11 @@ |
1609 | 1662 | |
1610 | 1663 | header( 'Content-type: text/html; charset=utf-8' ); |
1611 | 1664 | print "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">". |
1612 | | - "<html><head><title>" . |
| 1665 | + '<html><head><title>' . |
1613 | 1666 | htmlspecialchars( $label ) . |
1614 | | - "</title></head><body><h1>" . |
| 1667 | + '</title></head><body><h1>' . |
1615 | 1668 | htmlspecialchars( $label ) . |
1616 | | - "</h1><p>" . |
| 1669 | + '</h1><p>' . |
1617 | 1670 | nl2br( htmlspecialchars( $desc ) ) . |
1618 | 1671 | "</p></body></html>\n"; |
1619 | 1672 | } |
— | — | @@ -1634,7 +1687,7 @@ |
1635 | 1688 | * |
1636 | 1689 | * @param $resetGzipEncoding Bool |
1637 | 1690 | */ |
1638 | | -function wfResetOutputBuffers( $resetGzipEncoding=true ) { |
| 1691 | +function wfResetOutputBuffers( $resetGzipEncoding = true ) { |
1639 | 1692 | if( $resetGzipEncoding ) { |
1640 | 1693 | // Suppress Content-Encoding and Content-Length |
1641 | 1694 | // headers from 1.10+s wfOutputHandler |
— | — | @@ -1703,7 +1756,7 @@ |
1704 | 1757 | if( !isset( $qpart ) ) { |
1705 | 1758 | $prefs[$value] = 1.0; |
1706 | 1759 | } elseif( preg_match( '/q\s*=\s*(\d*\.\d+)/', $qpart, $match ) ) { |
1707 | | - $prefs[$value] = floatval($match[1]); |
| 1760 | + $prefs[$value] = floatval( $match[1] ); |
1708 | 1761 | } |
1709 | 1762 | } |
1710 | 1763 | |
— | — | @@ -1723,7 +1776,7 @@ |
1724 | 1777 | * @private |
1725 | 1778 | */ |
1726 | 1779 | function mimeTypeMatch( $type, $avail ) { |
1727 | | - if( array_key_exists($type, $avail) ) { |
| 1780 | + if( array_key_exists( $type, $avail ) ) { |
1728 | 1781 | return $type; |
1729 | 1782 | } else { |
1730 | 1783 | $parts = explode( '/', $type ); |
— | — | @@ -1840,29 +1893,29 @@ |
1841 | 1894 | /** |
1842 | 1895 | * Unix time - the number of seconds since 1970-01-01 00:00:00 UTC |
1843 | 1896 | */ |
1844 | | -define('TS_UNIX', 0); |
| 1897 | +define( 'TS_UNIX', 0 ); |
1845 | 1898 | |
1846 | 1899 | /** |
1847 | 1900 | * MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS) |
1848 | 1901 | */ |
1849 | | -define('TS_MW', 1); |
| 1902 | +define( 'TS_MW', 1 ); |
1850 | 1903 | |
1851 | 1904 | /** |
1852 | 1905 | * MySQL DATETIME (YYYY-MM-DD HH:MM:SS) |
1853 | 1906 | */ |
1854 | | -define('TS_DB', 2); |
| 1907 | +define( 'TS_DB', 2 ); |
1855 | 1908 | |
1856 | 1909 | /** |
1857 | 1910 | * RFC 2822 format, for E-mail and HTTP headers |
1858 | 1911 | */ |
1859 | | -define('TS_RFC2822', 3); |
| 1912 | +define( 'TS_RFC2822', 3 ); |
1860 | 1913 | |
1861 | 1914 | /** |
1862 | 1915 | * ISO 8601 format with no timezone: 1986-02-09T20:00:00Z |
1863 | 1916 | * |
1864 | 1917 | * This is used by Special:Export |
1865 | 1918 | */ |
1866 | | -define('TS_ISO_8601', 4); |
| 1919 | +define( 'TS_ISO_8601', 4 ); |
1867 | 1920 | |
1868 | 1921 | /** |
1869 | 1922 | * An Exif timestamp (YYYY:MM:DD HH:MM:SS) |
— | — | @@ -1871,22 +1924,22 @@ |
1872 | 1925 | * DateTime tag and page 36 for the DateTimeOriginal and |
1873 | 1926 | * DateTimeDigitized tags. |
1874 | 1927 | */ |
1875 | | -define('TS_EXIF', 5); |
| 1928 | +define( 'TS_EXIF', 5 ); |
1876 | 1929 | |
1877 | 1930 | /** |
1878 | 1931 | * Oracle format time. |
1879 | 1932 | */ |
1880 | | -define('TS_ORACLE', 6); |
| 1933 | +define( 'TS_ORACLE', 6 ); |
1881 | 1934 | |
1882 | 1935 | /** |
1883 | 1936 | * Postgres format time. |
1884 | 1937 | */ |
1885 | | -define('TS_POSTGRES', 7); |
| 1938 | +define( 'TS_POSTGRES', 7 ); |
1886 | 1939 | |
1887 | 1940 | /** |
1888 | 1941 | * DB2 format time |
1889 | 1942 | */ |
1890 | | -define('TS_DB2', 8); |
| 1943 | +define( 'TS_DB2', 8 ); |
1891 | 1944 | |
1892 | 1945 | /** |
1893 | 1946 | * @param $outputtype Mixed: A timestamp in one of the supported formats, the |
— | — | @@ -1898,26 +1951,26 @@ |
1899 | 1952 | function wfTimestamp( $outputtype = TS_UNIX, $ts = 0 ) { |
1900 | 1953 | $uts = 0; |
1901 | 1954 | $da = array(); |
1902 | | - if ($ts==0) { |
1903 | | - $uts=time(); |
1904 | | - } elseif (preg_match('/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)$/D',$ts,$da)) { |
| 1955 | + if ( $ts == 0 ) { |
| 1956 | + $uts = time(); |
| 1957 | + } elseif ( preg_match( '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)$/D', $ts, $da ) ) { |
1905 | 1958 | # TS_DB |
1906 | | - } elseif (preg_match('/^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)$/D',$ts,$da)) { |
| 1959 | + } elseif ( preg_match( '/^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d):(\d\d)$/D', $ts, $da ) ) { |
1907 | 1960 | # TS_EXIF |
1908 | | - } elseif (preg_match('/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/D',$ts,$da)) { |
| 1961 | + } elseif ( preg_match( '/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/D', $ts, $da ) ) { |
1909 | 1962 | # TS_MW |
1910 | | - } elseif (preg_match('/^-?\d{1,13}$/D',$ts)) { |
| 1963 | + } elseif ( preg_match( '/^-?\d{1,13}$/D', $ts ) ) { |
1911 | 1964 | # TS_UNIX |
1912 | 1965 | $uts = $ts; |
1913 | | - } elseif (preg_match('/^\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}.\d{6}$/', $ts)) { |
| 1966 | + } elseif ( preg_match( '/^\d{2}-\d{2}-\d{4} \d{2}:\d{2}:\d{2}.\d{6}$/', $ts ) ) { |
1914 | 1967 | # TS_ORACLE // session altered to DD-MM-YYYY HH24:MI:SS.FF6 |
1915 | | - $uts = strtotime(preg_replace('/(\d\d)\.(\d\d)\.(\d\d)(\.(\d+))?/', "$1:$2:$3", |
1916 | | - str_replace("+00:00", "UTC", $ts))); |
1917 | | - } elseif (preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.*\d*)?Z$/', $ts, $da)) { |
| 1968 | + $uts = strtotime( preg_replace( '/(\d\d)\.(\d\d)\.(\d\d)(\.(\d+))?/', "$1:$2:$3", |
| 1969 | + str_replace( '+00:00', 'UTC', $ts ) ) ); |
| 1970 | + } elseif ( preg_match( '/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.*\d*)?Z$/', $ts, $da ) ) { |
1918 | 1971 | # TS_ISO_8601 |
1919 | | - } elseif (preg_match('/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d*[\+\- ](\d\d)$/',$ts,$da)) { |
| 1972 | + } elseif ( preg_match( '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d*[\+\- ](\d\d)$/', $ts, $da ) ) { |
1920 | 1973 | # TS_POSTGRES |
1921 | | - } elseif (preg_match('/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d* GMT$/',$ts,$da)) { |
| 1974 | + } elseif ( preg_match( '/^(\d{4})\-(\d\d)\-(\d\d) (\d\d):(\d\d):(\d\d)\.*\d* GMT$/', $ts, $da ) ) { |
1922 | 1975 | # TS_POSTGRES |
1923 | 1976 | } else { |
1924 | 1977 | # Bogus value; fall back to the epoch... |
— | — | @@ -1928,11 +1981,11 @@ |
1929 | 1982 | if (count( $da ) ) { |
1930 | 1983 | // Warning! gmmktime() acts oddly if the month or day is set to 0 |
1931 | 1984 | // We may want to handle that explicitly at some point |
1932 | | - $uts=gmmktime((int)$da[4],(int)$da[5],(int)$da[6], |
1933 | | - (int)$da[2],(int)$da[3],(int)$da[1]); |
| 1985 | + $uts = gmmktime( (int)$da[4], (int)$da[5], (int)$da[6], |
| 1986 | + (int)$da[2], (int)$da[3], (int)$da[1] ); |
1934 | 1987 | } |
1935 | 1988 | |
1936 | | - switch($outputtype) { |
| 1989 | + switch( $outputtype ) { |
1937 | 1990 | case TS_UNIX: |
1938 | 1991 | return $uts; |
1939 | 1992 | case TS_MW: |
— | — | @@ -1943,18 +1996,18 @@ |
1944 | 1997 | return gmdate( 'Y-m-d\TH:i:s\Z', $uts ); |
1945 | 1998 | // This shouldn't ever be used, but is included for completeness |
1946 | 1999 | case TS_EXIF: |
1947 | | - return gmdate( 'Y:m:d H:i:s', $uts ); |
| 2000 | + return gmdate( 'Y:m:d H:i:s', $uts ); |
1948 | 2001 | case TS_RFC2822: |
1949 | 2002 | return gmdate( 'D, d M Y H:i:s', $uts ) . ' GMT'; |
1950 | 2003 | case TS_ORACLE: |
1951 | | - return gmdate( 'd-m-Y H:i:s.000000', $uts); |
1952 | | - //return gmdate( 'd-M-y h.i.s A', $uts) . ' +00:00'; |
| 2004 | + return gmdate( 'd-m-Y H:i:s.000000', $uts ); |
| 2005 | + //return gmdate( 'd-M-y h.i.s A', $uts ) . ' +00:00'; |
1953 | 2006 | case TS_POSTGRES: |
1954 | | - return gmdate( 'Y-m-d H:i:s', $uts) . ' GMT'; |
| 2007 | + return gmdate( 'Y-m-d H:i:s', $uts ) . ' GMT'; |
1955 | 2008 | case TS_DB2: |
1956 | | - return gmdate( 'Y-m-d H:i:s', $uts); |
| 2009 | + return gmdate( 'Y-m-d H:i:s', $uts ); |
1957 | 2010 | default: |
1958 | | - throw new MWException( 'wfTimestamp() called with illegal output type.'); |
| 2011 | + throw new MWException( 'wfTimestamp() called with illegal output type.' ); |
1959 | 2012 | } |
1960 | 2013 | } |
1961 | 2014 | |
— | — | @@ -1979,7 +2032,7 @@ |
1980 | 2033 | * @return Bool: true if it's Windows, False otherwise. |
1981 | 2034 | */ |
1982 | 2035 | function wfIsWindows() { |
1983 | | - if (substr(php_uname(), 0, 7) == 'Windows') { |
| 2036 | + if ( substr( php_uname(), 0, 7 ) == 'Windows' ) { |
1984 | 2037 | return true; |
1985 | 2038 | } else { |
1986 | 2039 | return false; |
— | — | @@ -2037,11 +2090,11 @@ |
2038 | 2091 | $parserMemc->set( $key, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 ); |
2039 | 2092 | $notice = $parsed; |
2040 | 2093 | } else { |
2041 | | - wfDebug( 'wfGetCachedNotice called for ' . $name . ' with no $wgOut available'."\n" ); |
| 2094 | + wfDebug( 'wfGetCachedNotice called for ' . $name . ' with no $wgOut available' . "\n" ); |
2042 | 2095 | $notice = ''; |
2043 | 2096 | } |
2044 | 2097 | } |
2045 | | - $notice = '<div id="localNotice">'.$notice.'</div>'; |
| 2098 | + $notice = '<div id="localNotice">' .$notice . '</div>'; |
2046 | 2099 | wfProfileOut( $fname ); |
2047 | 2100 | return $notice; |
2048 | 2101 | } |
— | — | @@ -2050,18 +2103,19 @@ |
2051 | 2104 | global $wgTitle; |
2052 | 2105 | |
2053 | 2106 | # Paranoia |
2054 | | - if ( !isset( $wgTitle ) || !is_object( $wgTitle ) ) |
2055 | | - return ""; |
| 2107 | + if ( !isset( $wgTitle ) || !is_object( $wgTitle ) ) { |
| 2108 | + return ''; |
| 2109 | + } |
2056 | 2110 | |
2057 | 2111 | $fname = 'wfGetNamespaceNotice'; |
2058 | 2112 | wfProfileIn( $fname ); |
2059 | 2113 | |
2060 | | - $key = "namespacenotice-" . $wgTitle->getNsText(); |
| 2114 | + $key = 'namespacenotice-' . $wgTitle->getNsText(); |
2061 | 2115 | $namespaceNotice = wfGetCachedNotice( $key ); |
2062 | | - if ( $namespaceNotice && substr ( $namespaceNotice , 0 ,7 ) != "<p><" ) { |
2063 | | - $namespaceNotice = '<div id="namespacebanner">' . $namespaceNotice . "</div>"; |
| 2116 | + if ( $namespaceNotice && substr( $namespaceNotice, 0, 7 ) != '<p><' ) { |
| 2117 | + $namespaceNotice = '<div id="namespacebanner">' . $namespaceNotice . '</div>'; |
2064 | 2118 | } else { |
2065 | | - $namespaceNotice = ""; |
| 2119 | + $namespaceNotice = ''; |
2066 | 2120 | } |
2067 | 2121 | |
2068 | 2122 | wfProfileOut( $fname ); |
— | — | @@ -2145,17 +2199,19 @@ |
2146 | 2200 | wfDebug( "$caller: called wfMkdirParents($dir)" ); |
2147 | 2201 | } |
2148 | 2202 | |
2149 | | - if( strval( $dir ) === '' || file_exists( $dir ) ) |
| 2203 | + if( strval( $dir ) === '' || file_exists( $dir ) ) { |
2150 | 2204 | return true; |
| 2205 | + } |
2151 | 2206 | |
2152 | 2207 | $dir = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $dir ); |
2153 | 2208 | |
2154 | | - if ( is_null( $mode ) ) |
| 2209 | + if ( is_null( $mode ) ) { |
2155 | 2210 | $mode = $wgDirectoryMode; |
| 2211 | + } |
2156 | 2212 | |
2157 | 2213 | // Turn off the normal warning, we're doing our own below |
2158 | 2214 | wfSuppressWarnings(); |
2159 | | - $ok = mkdir( $dir, $mode, true ); // PHP5 <3 |
| 2215 | + $ok = mkdir( $dir, $mode, true ); // PHP5 <3 |
2160 | 2216 | wfRestoreWarnings(); |
2161 | 2217 | |
2162 | 2218 | if( !$ok ) { |
— | — | @@ -2174,13 +2230,27 @@ |
2175 | 2231 | if( $wgStatsMethod == 'udp' ) { |
2176 | 2232 | global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname; |
2177 | 2233 | static $socket; |
2178 | | - if (!$socket) { |
2179 | | - $socket=socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); |
2180 | | - $statline="stats/{$wgDBname} - 1 1 1 1 1 -total\n"; |
2181 | | - socket_sendto($socket,$statline,strlen($statline),0,$wgUDPProfilerHost,$wgUDPProfilerPort); |
| 2234 | + if ( !$socket ) { |
| 2235 | + $socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP ); |
| 2236 | + $statline = "stats/{$wgDBname} - 1 1 1 1 1 -total\n"; |
| 2237 | + socket_sendto( |
| 2238 | + $socket, |
| 2239 | + $statline, |
| 2240 | + strlen( $statline ), |
| 2241 | + 0, |
| 2242 | + $wgUDPProfilerHost, |
| 2243 | + $wgUDPProfilerPort |
| 2244 | + ); |
2182 | 2245 | } |
2183 | | - $statline="stats/{$wgDBname} - 1 1 1 1 1 {$key}\n"; |
2184 | | - @socket_sendto($socket,$statline,strlen($statline),0,$wgUDPProfilerHost,$wgUDPProfilerPort); |
| 2246 | + $statline = "stats/{$wgDBname} - 1 1 1 1 1 {$key}\n"; |
| 2247 | + @socket_sendto( |
| 2248 | + $socket, |
| 2249 | + $statline, |
| 2250 | + strlen( $statline ), |
| 2251 | + 0, |
| 2252 | + $wgUDPProfilerHost, |
| 2253 | + $wgUDPProfilerPort |
| 2254 | + ); |
2185 | 2255 | } elseif( $wgStatsMethod == 'cache' ) { |
2186 | 2256 | global $wgMemc; |
2187 | 2257 | $key = wfMemcKey( 'stats', $key ); |
— | — | @@ -2214,7 +2284,7 @@ |
2215 | 2285 | function wfEncryptPassword( $userid, $password ) { |
2216 | 2286 | wfDeprecated(__FUNCTION__); |
2217 | 2287 | # Just wrap around User::oldCrypt() |
2218 | | - return User::oldCrypt($password, $userid); |
| 2288 | + return User::oldCrypt( $password, $userid ); |
2219 | 2289 | } |
2220 | 2290 | |
2221 | 2291 | /** |
— | — | @@ -2222,7 +2292,7 @@ |
2223 | 2293 | */ |
2224 | 2294 | function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) { |
2225 | 2295 | if ( is_null( $changed ) ) { |
2226 | | - throw new MWException('GlobalFunctions::wfAppendToArrayIfNotDefault got null'); |
| 2296 | + throw new MWException( 'GlobalFunctions::wfAppendToArrayIfNotDefault got null' ); |
2227 | 2297 | } |
2228 | 2298 | if ( $default[$key] !== $value ) { |
2229 | 2299 | $changed[$key] = $value; |
— | — | @@ -2255,7 +2325,7 @@ |
2256 | 2326 | |
2257 | 2327 | function wfSpecialList( $page, $details ) { |
2258 | 2328 | global $wgContLang; |
2259 | | - $details = $details ? ' ' . $wgContLang->getDirMark() . "($details)" : ""; |
| 2329 | + $details = $details ? ' ' . $wgContLang->getDirMark() . "($details)" : ''; |
2260 | 2330 | return $page . $details; |
2261 | 2331 | } |
2262 | 2332 | |
— | — | @@ -2268,15 +2338,17 @@ |
2269 | 2339 | global $wgUrlProtocols; |
2270 | 2340 | |
2271 | 2341 | static $retval = null; |
2272 | | - if ( !is_null( $retval ) ) |
| 2342 | + if ( !is_null( $retval ) ) { |
2273 | 2343 | return $retval; |
| 2344 | + } |
2274 | 2345 | |
2275 | 2346 | // Support old-style $wgUrlProtocols strings, for backwards compatibility |
2276 | 2347 | // with LocalSettings files from 1.5 |
2277 | 2348 | if ( is_array( $wgUrlProtocols ) ) { |
2278 | 2349 | $protocols = array(); |
2279 | | - foreach ($wgUrlProtocols as $protocol) |
| 2350 | + foreach ( $wgUrlProtocols as $protocol ) { |
2280 | 2351 | $protocols[] = preg_quote( $protocol, '/' ); |
| 2352 | + } |
2281 | 2353 | |
2282 | 2354 | $retval = implode( '|', $protocols ); |
2283 | 2355 | } else { |
— | — | @@ -2349,7 +2421,7 @@ |
2350 | 2422 | * (non-zero is usually failure) |
2351 | 2423 | * @return collected stdout as a string (trailing newlines stripped) |
2352 | 2424 | */ |
2353 | | -function wfShellExec( $cmd, &$retval=null ) { |
| 2425 | +function wfShellExec( $cmd, &$retval = null ) { |
2354 | 2426 | global $IP, $wgMaxShellMemory, $wgMaxShellFileSize, $wgMaxShellTime; |
2355 | 2427 | |
2356 | 2428 | static $disabled; |
— | — | @@ -2369,7 +2441,7 @@ |
2370 | 2442 | } |
2371 | 2443 | if ( $disabled ) { |
2372 | 2444 | $retval = 1; |
2373 | | - return "Unable to run external programs in safe mode."; |
| 2445 | + return 'Unable to run external programs in safe mode.'; |
2374 | 2446 | } |
2375 | 2447 | |
2376 | 2448 | wfInitShellLocale(); |
— | — | @@ -2413,7 +2485,9 @@ |
2414 | 2486 | */ |
2415 | 2487 | function wfInitShellLocale() { |
2416 | 2488 | static $done = false; |
2417 | | - if ( $done ) return; |
| 2489 | + if ( $done ) { |
| 2490 | + return; |
| 2491 | + } |
2418 | 2492 | $done = true; |
2419 | 2493 | global $wgShellLocale; |
2420 | 2494 | if ( !wfIniGetBool( 'safe_mode' ) ) { |
— | — | @@ -2440,8 +2514,9 @@ |
2441 | 2515 | function wfUsePHP( $req_ver ) { |
2442 | 2516 | $php_ver = PHP_VERSION; |
2443 | 2517 | |
2444 | | - if ( version_compare( $php_ver, (string)$req_ver, '<' ) ) |
2445 | | - throw new MWException( "PHP $req_ver required--this is only $php_ver" ); |
| 2518 | + if ( version_compare( $php_ver, (string)$req_ver, '<' ) ) { |
| 2519 | + throw new MWException( "PHP $req_ver required--this is only $php_ver" ); |
| 2520 | + } |
2446 | 2521 | } |
2447 | 2522 | |
2448 | 2523 | /** |
— | — | @@ -2460,8 +2535,9 @@ |
2461 | 2536 | function wfUseMW( $req_ver ) { |
2462 | 2537 | global $wgVersion; |
2463 | 2538 | |
2464 | | - if ( version_compare( $wgVersion, (string)$req_ver, '<' ) ) |
| 2539 | + if ( version_compare( $wgVersion, (string)$req_ver, '<' ) ) { |
2465 | 2540 | throw new MWException( "MediaWiki $req_ver required--this is only $wgVersion" ); |
| 2541 | + } |
2466 | 2542 | } |
2467 | 2543 | |
2468 | 2544 | /** |
— | — | @@ -2476,8 +2552,8 @@ |
2477 | 2553 | * @param $suffix String: to remove if present |
2478 | 2554 | * @return String |
2479 | 2555 | */ |
2480 | | -function wfBaseName( $path, $suffix='' ) { |
2481 | | - $encSuffix = ($suffix == '') |
| 2556 | +function wfBaseName( $path, $suffix = '' ) { |
| 2557 | + $encSuffix = ( $suffix == '' ) |
2482 | 2558 | ? '' |
2483 | 2559 | : ( '(?:' . preg_quote( $suffix, '#' ) . ')?' ); |
2484 | 2560 | $matches = array(); |
— | — | @@ -2506,7 +2582,7 @@ |
2507 | 2583 | $path = rtrim( $path, DIRECTORY_SEPARATOR ); |
2508 | 2584 | $from = rtrim( $from, DIRECTORY_SEPARATOR ); |
2509 | 2585 | |
2510 | | - $pieces = explode( DIRECTORY_SEPARATOR, dirname( $path ) ); |
| 2586 | + $pieces = explode( DIRECTORY_SEPARATOR, dirname( $path ) ); |
2511 | 2587 | $against = explode( DIRECTORY_SEPARATOR, $from ); |
2512 | 2588 | |
2513 | 2589 | if( $pieces[0] !== $against[0] ) { |
— | — | @@ -2607,7 +2683,7 @@ |
2608 | 2684 | $bits['delimiter'] = ':'; |
2609 | 2685 | // parse_url detects for news: and mailto: the host part of an url as path |
2610 | 2686 | // We have to correct this wrong detection |
2611 | | - if ( isset ( $bits['path'] ) ) { |
| 2687 | + if ( isset( $bits['path'] ) ) { |
2612 | 2688 | $bits['host'] = $bits['path']; |
2613 | 2689 | $bits['path'] = ''; |
2614 | 2690 | } |
— | — | @@ -2628,7 +2704,7 @@ |
2629 | 2705 | // For emails reverse domainpart only |
2630 | 2706 | if ( $bits['scheme'] == 'mailto' ) { |
2631 | 2707 | $mailparts = explode( '@', $bits['host'], 2 ); |
2632 | | - if ( count($mailparts) === 2 ) { |
| 2708 | + if ( count( $mailparts ) === 2 ) { |
2633 | 2709 | $domainpart = strtolower( implode( '.', array_reverse( explode( '.', $mailparts[1] ) ) ) ); |
2634 | 2710 | } else { |
2635 | 2711 | // No domain specified, don't mangle it |
— | — | @@ -2647,14 +2723,20 @@ |
2648 | 2724 | $prot = $bits['scheme']; |
2649 | 2725 | $index = $prot . $bits['delimiter'] . $reversedHost; |
2650 | 2726 | // Leave out user and password. Add the port, path, query and fragment |
2651 | | - if ( isset( $bits['port'] ) ) $index .= ':' . $bits['port']; |
| 2727 | + if ( isset( $bits['port'] ) ) { |
| 2728 | + $index .= ':' . $bits['port']; |
| 2729 | + } |
2652 | 2730 | if ( isset( $bits['path'] ) ) { |
2653 | 2731 | $index .= $bits['path']; |
2654 | 2732 | } else { |
2655 | 2733 | $index .= '/'; |
2656 | 2734 | } |
2657 | | - if ( isset( $bits['query'] ) ) $index .= '?' . $bits['query']; |
2658 | | - if ( isset( $bits['fragment'] ) ) $index .= '#' . $bits['fragment']; |
| 2735 | + if ( isset( $bits['query'] ) ) { |
| 2736 | + $index .= '?' . $bits['query']; |
| 2737 | + } |
| 2738 | + if ( isset( $bits['fragment'] ) ) { |
| 2739 | + $index .= '#' . $bits['fragment']; |
| 2740 | + } |
2659 | 2741 | return $index; |
2660 | 2742 | } |
2661 | 2743 | |
— | — | @@ -2662,8 +2744,7 @@ |
2663 | 2745 | * Do any deferred updates and clear the list |
2664 | 2746 | * TODO: This could be in Wiki.php if that class made any sense at all |
2665 | 2747 | */ |
2666 | | -function wfDoUpdates() |
2667 | | -{ |
| 2748 | +function wfDoUpdates() { |
2668 | 2749 | global $wgPostCommitUpdateList, $wgDeferredUpdateList; |
2669 | 2750 | foreach ( $wgDeferredUpdateList as $update ) { |
2670 | 2751 | $update->doUpdate(); |
— | — | @@ -2689,7 +2770,7 @@ |
2690 | 2771 | * @param $lowercase Boolean |
2691 | 2772 | * @return String or false on invalid input |
2692 | 2773 | */ |
2693 | | -function wfBaseConvert( $input, $sourceBase, $destBase, $pad=1, $lowercase=true ) { |
| 2774 | +function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1, $lowercase = true ) { |
2694 | 2775 | $input = strval( $input ); |
2695 | 2776 | if( $sourceBase < 2 || |
2696 | 2777 | $sourceBase > 36 || |
— | — | @@ -2703,7 +2784,7 @@ |
2704 | 2785 | $input == '' ) { |
2705 | 2786 | return false; |
2706 | 2787 | } |
2707 | | - $digitChars = ( $lowercase ) ? '0123456789abcdefghijklmnopqrstuvwxyz' : '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
| 2788 | + $digitChars = ( $lowercase ) ? '0123456789abcdefghijklmnopqrstuvwxyz' : '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
2708 | 2789 | $inDigits = array(); |
2709 | 2790 | $outChars = ''; |
2710 | 2791 | |
— | — | @@ -2767,7 +2848,7 @@ |
2768 | 2849 | * @param $name String |
2769 | 2850 | * @param $p Array: parameters |
2770 | 2851 | */ |
2771 | | -function wfCreateObject( $name, $p ){ |
| 2852 | +function wfCreateObject( $name, $p ) { |
2772 | 2853 | $p = array_values( $p ); |
2773 | 2854 | switch ( count( $p ) ) { |
2774 | 2855 | case 0: |
— | — | @@ -2785,14 +2866,15 @@ |
2786 | 2867 | case 6: |
2787 | 2868 | return new $name( $p[0], $p[1], $p[2], $p[3], $p[4], $p[5] ); |
2788 | 2869 | default: |
2789 | | - throw new MWException( "Too many arguments to construtor in wfCreateObject" ); |
| 2870 | + throw new MWException( 'Too many arguments to construtor in wfCreateObject' ); |
2790 | 2871 | } |
2791 | 2872 | } |
2792 | 2873 | |
2793 | 2874 | function wfHttpOnlySafe() { |
2794 | 2875 | global $wgHttpOnlyBlacklist; |
2795 | | - if( !version_compare("5.2", PHP_VERSION, "<") ) |
| 2876 | + if( !version_compare( '5.2', PHP_VERSION, '<' ) ) { |
2796 | 2877 | return false; |
| 2878 | + } |
2797 | 2879 | |
2798 | 2880 | if( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { |
2799 | 2881 | foreach( $wgHttpOnlyBlacklist as $regex ) { |
— | — | @@ -2816,7 +2898,7 @@ |
2817 | 2899 | } elseif( $wgSessionHandler && $wgSessionHandler != ini_get( 'session.save_handler' ) ) { |
2818 | 2900 | # Only set this if $wgSessionHandler isn't null and session.save_handler |
2819 | 2901 | # hasn't already been set to the desired value (that causes errors) |
2820 | | - ini_set ( 'session.save_handler', $wgSessionHandler ); |
| 2902 | + ini_set( 'session.save_handler', $wgSessionHandler ); |
2821 | 2903 | } |
2822 | 2904 | $httpOnlySafe = wfHttpOnlySafe(); |
2823 | 2905 | wfDebugLog( 'cookie', |
— | — | @@ -2860,7 +2942,7 @@ |
2861 | 2943 | function wfGetCaller( $level = 2 ) { |
2862 | 2944 | $backtrace = wfDebugBacktrace(); |
2863 | 2945 | if ( isset( $backtrace[$level] ) ) { |
2864 | | - return wfFormatStackFrame($backtrace[$level]); |
| 2946 | + return wfFormatStackFrame( $backtrace[$level] ); |
2865 | 2947 | } else { |
2866 | 2948 | $caller = 'unknown'; |
2867 | 2949 | } |
— | — | @@ -2886,10 +2968,10 @@ |
2887 | 2969 | /** |
2888 | 2970 | * Return a string representation of frame |
2889 | 2971 | */ |
2890 | | -function wfFormatStackFrame($frame) { |
2891 | | - return isset( $frame["class"] )? |
2892 | | - $frame["class"]."::".$frame["function"]: |
2893 | | - $frame["function"]; |
| 2972 | +function wfFormatStackFrame( $frame ) { |
| 2973 | + return isset( $frame['class'] ) ? |
| 2974 | + $frame['class'] . '::' . $frame['function'] : |
| 2975 | + $frame['function']; |
2894 | 2976 | } |
2895 | 2977 | |
2896 | 2978 | /** |
— | — | @@ -2939,7 +3021,7 @@ |
2940 | 3022 | return $bits; |
2941 | 3023 | } |
2942 | 3024 | |
2943 | | -/* |
| 3025 | +/** |
2944 | 3026 | * Get a Database object. |
2945 | 3027 | * @param $db Integer: index of the connection to get. May be DB_MASTER for the |
2946 | 3028 | * master (for write queries), DB_SLAVE for potentially lagged read |
— | — | @@ -2954,7 +3036,7 @@ |
2955 | 3037 | * Note: multiple calls to wfGetDB(DB_SLAVE) during the course of one request |
2956 | 3038 | * will always return the same object, unless the underlying connection or load |
2957 | 3039 | * balancer is manually destroyed. |
2958 | | - * |
| 3040 | + * |
2959 | 3041 | * @return DatabaseBase |
2960 | 3042 | */ |
2961 | 3043 | function &wfGetDB( $db, $groups = array(), $wiki = false ) { |
— | — | @@ -3035,12 +3117,13 @@ |
3036 | 3118 | global $wgScriptPath, $wgScriptExtension; |
3037 | 3119 | return "{$wgScriptPath}/{$script}{$wgScriptExtension}"; |
3038 | 3120 | } |
| 3121 | + |
3039 | 3122 | /** |
3040 | | - * Get the script url. |
| 3123 | + * Get the script URL. |
3041 | 3124 | * |
3042 | | - * @return script url |
| 3125 | + * @return script URL |
3043 | 3126 | */ |
3044 | | -function wfGetScriptUrl(){ |
| 3127 | +function wfGetScriptUrl() { |
3045 | 3128 | if( isset( $_SERVER['SCRIPT_NAME'] ) ) { |
3046 | 3129 | # |
3047 | 3130 | # as it was called, minus the query string. |
— | — | @@ -3133,17 +3216,18 @@ |
3134 | 3217 | */ |
3135 | 3218 | function wfWarn( $msg, $callerOffset = 1, $level = E_USER_NOTICE ) { |
3136 | 3219 | $callers = wfDebugBacktrace(); |
3137 | | - if( isset( $callers[$callerOffset+1] ) ){ |
3138 | | - $callerfunc = $callers[$callerOffset+1]; |
| 3220 | + if( isset( $callers[$callerOffset + 1] ) ){ |
| 3221 | + $callerfunc = $callers[$callerOffset + 1]; |
3139 | 3222 | $callerfile = $callers[$callerOffset]; |
3140 | | - if( isset( $callerfile['file'] ) && isset( $callerfile['line'] ) ){ |
| 3223 | + if( isset( $callerfile['file'] ) && isset( $callerfile['line'] ) ) { |
3141 | 3224 | $file = $callerfile['file'] . ' at line ' . $callerfile['line']; |
3142 | 3225 | } else { |
3143 | 3226 | $file = '(internal function)'; |
3144 | 3227 | } |
3145 | 3228 | $func = ''; |
3146 | | - if( isset( $callerfunc['class'] ) ) |
| 3229 | + if( isset( $callerfunc['class'] ) ) { |
3147 | 3230 | $func .= $callerfunc['class'] . '::'; |
| 3231 | + } |
3148 | 3232 | $func .= @$callerfunc['function']; |
3149 | 3233 | $msg .= " [Called from $func in $file]"; |
3150 | 3234 | } |
— | — | @@ -3180,7 +3264,7 @@ |
3181 | 3265 | $host = $name; |
3182 | 3266 | } |
3183 | 3267 | print "Waiting for $host (lagged $lag seconds)...\n"; |
3184 | | - sleep($maxLag); |
| 3268 | + sleep( $maxLag ); |
3185 | 3269 | list( $host, $lag ) = $lb->getMaxLag(); |
3186 | 3270 | } |
3187 | 3271 | } |
— | — | @@ -3218,12 +3302,13 @@ |
3219 | 3303 | echo "\n"; |
3220 | 3304 | } |
3221 | 3305 | |
3222 | | -/** Generate a random 32-character hexadecimal token. |
| 3306 | +/** |
| 3307 | + * Generate a random 32-character hexadecimal token. |
3223 | 3308 | * @param $salt Mixed: some sort of salt, if necessary, to add to random |
3224 | 3309 | * characters before hashing. |
3225 | 3310 | */ |
3226 | 3311 | function wfGenerateToken( $salt = '' ) { |
3227 | | - $salt = serialize($salt); |
| 3312 | + $salt = serialize( $salt ); |
3228 | 3313 | |
3229 | 3314 | return md5( mt_rand( 0, 0x7fffffff ) . $salt ); |
3230 | 3315 | } |
— | — | @@ -3235,7 +3320,13 @@ |
3236 | 3321 | function wfStripIllegalFilenameChars( $name ) { |
3237 | 3322 | global $wgIllegalFileChars; |
3238 | 3323 | $name = wfBaseName( $name ); |
3239 | | - $name = preg_replace("/[^".Title::legalChars()."]".($wgIllegalFileChars ? "|[".$wgIllegalFileChars."]":"")."/",'-',$name); |
| 3324 | + $name = preg_replace( |
| 3325 | + "/[^" . Title::legalChars() . "]" . |
| 3326 | + ( $wgIllegalFileChars ? "|[" . $wgIllegalFileChars . "]" : '' ) . |
| 3327 | + "/", |
| 3328 | + '-', |
| 3329 | + $name |
| 3330 | + ); |
3240 | 3331 | return $name; |
3241 | 3332 | } |
3242 | 3333 | |
— | — | @@ -3247,14 +3338,14 @@ |
3248 | 3339 | */ |
3249 | 3340 | function wfArrayInsertAfter( $array, $insert, $after ) { |
3250 | 3341 | // Find the offset of the element to insert after. |
3251 | | - $keys = array_keys($array); |
| 3342 | + $keys = array_keys( $array ); |
3252 | 3343 | $offsetByKey = array_flip( $keys ); |
3253 | 3344 | |
3254 | 3345 | $offset = $offsetByKey[$after]; |
3255 | 3346 | |
3256 | 3347 | // Insert at the specified offset |
3257 | 3348 | $before = array_slice( $array, 0, $offset + 1, true ); |
3258 | | - $after = array_slice( $array, $offset + 1, count($array)-$offset, true ); |
| 3349 | + $after = array_slice( $array, $offset + 1, count( $array ) - $offset, true ); |
3259 | 3350 | |
3260 | 3351 | $output = $before + $insert + $after; |
3261 | 3352 | |
— | — | @@ -3281,19 +3372,19 @@ |
3282 | 3373 | */ |
3283 | 3374 | function wfMemoryLimit() { |
3284 | 3375 | global $wgMemoryLimit; |
3285 | | - $memlimit = wfShorthandToInteger( ini_get( "memory_limit" ) ); |
| 3376 | + $memlimit = wfShorthandToInteger( ini_get( 'memory_limit' ) ); |
3286 | 3377 | $conflimit = wfShorthandToInteger( $wgMemoryLimit ); |
3287 | 3378 | if( $memlimit != -1 ) { |
3288 | 3379 | if( $conflimit == -1 ) { |
3289 | 3380 | wfDebug( "Removing PHP's memory limit\n" ); |
3290 | 3381 | wfSuppressWarnings(); |
3291 | | - ini_set( "memory_limit", $conflimit ); |
| 3382 | + ini_set( 'memory_limit', $conflimit ); |
3292 | 3383 | wfRestoreWarnings(); |
3293 | 3384 | return $conflimit; |
3294 | 3385 | } elseif ( $conflimit > $memlimit ) { |
3295 | 3386 | wfDebug( "Raising PHP's memory limit to $conflimit bytes\n" ); |
3296 | 3387 | wfSuppressWarnings(); |
3297 | | - ini_set( "memory_limit", $conflimit ); |
| 3388 | + ini_set( 'memory_limit', $conflimit ); |
3298 | 3389 | wfRestoreWarnings(); |
3299 | 3390 | return $conflimit; |
3300 | 3391 | } |
— | — | @@ -3306,12 +3397,14 @@ |
3307 | 3398 | * @param $string String |
3308 | 3399 | * @return Integer |
3309 | 3400 | */ |
3310 | | -function wfShorthandToInteger ( $string = '' ) { |
3311 | | - $string = trim($string); |
3312 | | - if( empty($string) ) { return -1; } |
3313 | | - $last = strtolower($string[strlen($string)-1]); |
3314 | | - $val = intval($string); |
3315 | | - switch($last) { |
| 3401 | +function wfShorthandToInteger( $string = '' ) { |
| 3402 | + $string = trim( $string ); |
| 3403 | + if( empty( $string ) ) { |
| 3404 | + return -1; |
| 3405 | + } |
| 3406 | + $last = strtolower( $string[strlen( $string ) - 1] ); |
| 3407 | + $val = intval( $string ); |
| 3408 | + switch( $last ) { |
3316 | 3409 | case 'g': |
3317 | 3410 | $val *= 1024; |
3318 | 3411 | case 'm': |
— | — | @@ -3323,7 +3416,8 @@ |
3324 | 3417 | return $val; |
3325 | 3418 | } |
3326 | 3419 | |
3327 | | -/* Get the normalised IETF language tag |
| 3420 | +/** |
| 3421 | + * Get the normalised IETF language tag |
3328 | 3422 | * @param $code String: The language code. |
3329 | 3423 | * @return $langCode String: The language code which complying with BCP 47 standards. |
3330 | 3424 | */ |
— | — | @@ -3332,20 +3426,21 @@ |
3333 | 3427 | foreach ( $codeSegment as $segNo => $seg ) { |
3334 | 3428 | if ( count( $codeSegment ) > 0 ) { |
3335 | 3429 | // ISO 3166 country code |
3336 | | - if ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) |
| 3430 | + if ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) { |
3337 | 3431 | $codeBCP[$segNo] = strtoupper( $seg ); |
3338 | 3432 | // ISO 15924 script code |
3339 | | - else if ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) |
| 3433 | + } elseif ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) { |
3340 | 3434 | $codeBCP[$segNo] = ucfirst( $seg ); |
3341 | 3435 | // Use lowercase for other cases |
3342 | | - else |
| 3436 | + } else { |
3343 | 3437 | $codeBCP[$segNo] = strtolower( $seg ); |
| 3438 | + } |
3344 | 3439 | } else { |
3345 | 3440 | // Use lowercase for single segment |
3346 | 3441 | $codeBCP[$segNo] = strtolower( $seg ); |
3347 | 3442 | } |
3348 | 3443 | } |
3349 | | - $langCode = implode ( '-' , $codeBCP ); |
| 3444 | + $langCode = implode( '-', $codeBCP ); |
3350 | 3445 | return $langCode; |
3351 | 3446 | } |
3352 | 3447 | |