Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -9,6 +9,7 @@ |
10 | 10 | */ |
11 | 11 | |
12 | 12 | require_once dirname(__FILE__) . '/normal/UtfNormalUtil.php'; |
| 13 | +require_once dirname(__FILE__) . '/XmlFunctions.php'; |
13 | 14 | |
14 | 15 | // Hide compatibility functions from Doxygen |
15 | 16 | /// @cond |
— | — | @@ -748,7 +749,47 @@ |
749 | 750 | return $string; |
750 | 751 | } |
751 | 752 | |
| 753 | + |
752 | 754 | /** |
| 755 | + * Just like exit() but makes a note of it. |
| 756 | + * Commits open transactions except if the error parameter is set |
| 757 | + * |
| 758 | + * @deprecated Please return control to the caller or throw an exception |
| 759 | + */ |
| 760 | +function wfAbruptExit( $error = false ){ |
| 761 | + static $called = false; |
| 762 | + if ( $called ){ |
| 763 | + exit( -1 ); |
| 764 | + } |
| 765 | + $called = true; |
| 766 | + |
| 767 | + $bt = wfDebugBacktrace(); |
| 768 | + if( $bt ) { |
| 769 | + for($i = 0; $i < count($bt) ; $i++){ |
| 770 | + $file = isset($bt[$i]['file']) ? $bt[$i]['file'] : "unknown"; |
| 771 | + $line = isset($bt[$i]['line']) ? $bt[$i]['line'] : "unknown"; |
| 772 | + wfDebug("WARNING: Abrupt exit in $file at line $line\n"); |
| 773 | + } |
| 774 | + } else { |
| 775 | + wfDebug('WARNING: Abrupt exit\n'); |
| 776 | + } |
| 777 | + |
| 778 | + wfLogProfilingData(); |
| 779 | + |
| 780 | + if ( !$error ) { |
| 781 | + wfGetLB()->closeAll(); |
| 782 | + } |
| 783 | + exit( -1 ); |
| 784 | +} |
| 785 | + |
| 786 | +/** |
| 787 | + * @deprecated Please return control the caller or throw an exception |
| 788 | + */ |
| 789 | +function wfErrorExit() { |
| 790 | + wfAbruptExit( true ); |
| 791 | +} |
| 792 | + |
| 793 | +/** |
753 | 794 | * Print a simple message and die, returning nonzero to the shell if any. |
754 | 795 | * Plain die() fails to return nonzero to the shell if you pass a string. |
755 | 796 | * @param string $msg |
— | — | @@ -796,20 +837,22 @@ |
797 | 838 | return $host; |
798 | 839 | } |
799 | 840 | |
800 | | -/** |
801 | | - * Returns a HTML comment with the elapsed time since request. |
802 | | - * This method has no side effects. |
803 | | - * @return string |
804 | | - */ |
805 | | -function wfReportTime() { |
806 | | - global $wgRequestTime, $wgShowHostnames; |
807 | | - $now = wfTime(); |
808 | | - $elapsed = $now - $wgRequestTime; |
809 | | - return $wgShowHostnames |
810 | | - ? sprintf( "<!-- Served by %s in %01.3f secs. -->", wfHostname(), $elapsed ) |
811 | | - : sprintf( "<!-- Served in %01.3f secs. -->", $elapsed ); |
812 | | -} |
| 841 | + /** |
| 842 | + * Returns a HTML comment with the elapsed time since request. |
| 843 | + * This method has no side effects. |
| 844 | + * @return string |
| 845 | + */ |
| 846 | + function wfReportTime() { |
| 847 | + global $wgRequestTime, $wgShowHostnames; |
813 | 848 | |
| 849 | + $now = wfTime(); |
| 850 | + $elapsed = $now - $wgRequestTime; |
| 851 | + |
| 852 | + return $wgShowHostnames |
| 853 | + ? sprintf( "<!-- Served by %s in %01.3f secs. -->", wfHostname(), $elapsed ) |
| 854 | + : sprintf( "<!-- Served in %01.3f secs. -->", $elapsed ); |
| 855 | + } |
| 856 | + |
814 | 857 | /** |
815 | 858 | * Safety wrapper for debug_backtrace(). |
816 | 859 | * |
— | — | @@ -1165,6 +1208,14 @@ |
1166 | 1209 | } |
1167 | 1210 | |
1168 | 1211 | /** |
| 1212 | + * This is obsolete, use SquidUpdate::purge() |
| 1213 | + * @deprecated |
| 1214 | + */ |
| 1215 | +function wfPurgeSquidServers ($urlArr) { |
| 1216 | + SquidUpdate::purge( $urlArr ); |
| 1217 | +} |
| 1218 | + |
| 1219 | +/** |
1169 | 1220 | * Windows-compatible version of escapeshellarg() |
1170 | 1221 | * Windows doesn't recognise single-quotes in the shell, but the escapeshellarg() |
1171 | 1222 | * function puts single quotes in regardless of OS. |
— | — | @@ -2344,6 +2395,13 @@ |
2345 | 2396 | } |
2346 | 2397 | |
2347 | 2398 | /** |
| 2399 | + * @deprecated use StringUtils::explodeMarkup |
| 2400 | + */ |
| 2401 | +function wfExplodeMarkup( $separator, $text ) { |
| 2402 | + return StringUtils::explodeMarkup( $separator, $text ); |
| 2403 | +} |
| 2404 | + |
| 2405 | +/** |
2348 | 2406 | * Convert an arbitrarily-long digit string from one numeric base |
2349 | 2407 | * to another, optionally zero-padding to a minimum column width. |
2350 | 2408 | * |
— | — | @@ -2457,10 +2515,29 @@ |
2458 | 2516 | } |
2459 | 2517 | } |
2460 | 2518 | |
| 2519 | +/** |
| 2520 | + * Alias for modularized function |
| 2521 | + * @deprecated Use Http::get() instead |
| 2522 | + */ |
| 2523 | +function wfGetHTTP( $url, $timeout = 'default' ) { |
| 2524 | + wfDeprecated(__FUNCTION__); |
| 2525 | + return Http::get( $url, $timeout ); |
| 2526 | +} |
| 2527 | + |
| 2528 | +/** |
| 2529 | + * Alias for modularized function |
| 2530 | + * @deprecated Use Http::isLocalURL() instead |
| 2531 | + */ |
| 2532 | +function wfIsLocalURL( $url ) { |
| 2533 | + wfDeprecated(__FUNCTION__); |
| 2534 | + return Http::isLocalURL( $url ); |
| 2535 | +} |
| 2536 | + |
2461 | 2537 | function wfHttpOnlySafe() { |
2462 | 2538 | global $wgHttpOnlyBlacklist; |
2463 | 2539 | if( !version_compare("5.2", PHP_VERSION, "<") ) |
2464 | 2540 | return false; |
| 2541 | + |
2465 | 2542 | if( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { |
2466 | 2543 | foreach( $wgHttpOnlyBlacklist as $regex ) { |
2467 | 2544 | if( preg_match( $regex, $_SERVER['HTTP_USER_AGENT'] ) ) { |
— | — | @@ -2468,6 +2545,7 @@ |
2469 | 2546 | } |
2470 | 2547 | } |
2471 | 2548 | } |
| 2549 | + |
2472 | 2550 | return true; |
2473 | 2551 | } |
2474 | 2552 | |
— | — | @@ -2644,7 +2722,7 @@ |
2645 | 2723 | * @return File, or false if the file does not exist |
2646 | 2724 | */ |
2647 | 2725 | function wfFindFile( $title, $time = false, $flags = 0, $bypass = false ) { |
2648 | | - if( !$time && !$flags && !$bypass ) { |
| 2726 | + if( !$time && !$flags && !$bypass ) { |
2649 | 2727 | return FileCache::singleton()->findFile( $title ); |
2650 | 2728 | } else { |
2651 | 2729 | return RepoGroup::singleton()->findFile( $title, $time, $flags ); |