From 4e4431d76b2541573a4956a3b2d68a4087796cc0 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 23 Dec 2008 21:30:19 +0000 Subject: [PATCH] Revert r44918 "Remove unused functions" We keep these things for backwards compatibility, as they may be in use by extensions even if not in core code. --- includes/GlobalFunctions.php | 106 ++++++++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 14 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index f47a41efac..2b23802bba 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -9,6 +9,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { */ require_once dirname(__FILE__) . '/normal/UtfNormalUtil.php'; +require_once dirname(__FILE__) . '/XmlFunctions.php'; // Hide compatibility functions from Doxygen /// @cond @@ -748,6 +749,46 @@ function wfMsgExt( $key, $options ) { return $string; } + +/** + * Just like exit() but makes a note of it. + * Commits open transactions except if the error parameter is set + * + * @deprecated Please return control to the caller or throw an exception + */ +function wfAbruptExit( $error = false ){ + static $called = false; + if ( $called ){ + exit( -1 ); + } + $called = true; + + $bt = wfDebugBacktrace(); + if( $bt ) { + for($i = 0; $i < count($bt) ; $i++){ + $file = isset($bt[$i]['file']) ? $bt[$i]['file'] : "unknown"; + $line = isset($bt[$i]['line']) ? $bt[$i]['line'] : "unknown"; + wfDebug("WARNING: Abrupt exit in $file at line $line\n"); + } + } else { + wfDebug('WARNING: Abrupt exit\n'); + } + + wfLogProfilingData(); + + if ( !$error ) { + wfGetLB()->closeAll(); + } + exit( -1 ); +} + +/** + * @deprecated Please return control the caller or throw an exception + */ +function wfErrorExit() { + wfAbruptExit( true ); +} + /** * Print a simple message and die, returning nonzero to the shell if any. * Plain die() fails to return nonzero to the shell if you pass a string. @@ -796,19 +837,21 @@ function wfHostname() { return $host; } -/** - * Returns a HTML comment with the elapsed time since request. - * This method has no side effects. - * @return string - */ -function wfReportTime() { - global $wgRequestTime, $wgShowHostnames; - $now = wfTime(); - $elapsed = $now - $wgRequestTime; - return $wgShowHostnames - ? sprintf( "", wfHostname(), $elapsed ) - : sprintf( "", $elapsed ); -} + /** + * Returns a HTML comment with the elapsed time since request. + * This method has no side effects. + * @return string + */ + function wfReportTime() { + global $wgRequestTime, $wgShowHostnames; + + $now = wfTime(); + $elapsed = $now - $wgRequestTime; + + return $wgShowHostnames + ? sprintf( "", wfHostname(), $elapsed ) + : sprintf( "", $elapsed ); + } /** * Safety wrapper for debug_backtrace(). @@ -1164,6 +1207,14 @@ function wfExpandUrl( $url ) { } } +/** + * This is obsolete, use SquidUpdate::purge() + * @deprecated + */ +function wfPurgeSquidServers ($urlArr) { + SquidUpdate::purge( $urlArr ); +} + /** * Windows-compatible version of escapeshellarg() * Windows doesn't recognise single-quotes in the shell, but the escapeshellarg() @@ -2343,6 +2394,13 @@ function wfDoUpdates() $wgPostCommitUpdateList = array(); } +/** + * @deprecated use StringUtils::explodeMarkup + */ +function wfExplodeMarkup( $separator, $text ) { + return StringUtils::explodeMarkup( $separator, $text ); +} + /** * Convert an arbitrarily-long digit string from one numeric base * to another, optionally zero-padding to a minimum column width. @@ -2457,10 +2515,29 @@ function wfCreateObject( $name, $p ){ } } +/** + * Alias for modularized function + * @deprecated Use Http::get() instead + */ +function wfGetHTTP( $url, $timeout = 'default' ) { + wfDeprecated(__FUNCTION__); + return Http::get( $url, $timeout ); +} + +/** + * Alias for modularized function + * @deprecated Use Http::isLocalURL() instead + */ +function wfIsLocalURL( $url ) { + wfDeprecated(__FUNCTION__); + return Http::isLocalURL( $url ); +} + function wfHttpOnlySafe() { global $wgHttpOnlyBlacklist; if( !version_compare("5.2", PHP_VERSION, "<") ) return false; + if( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { foreach( $wgHttpOnlyBlacklist as $regex ) { if( preg_match( $regex, $_SERVER['HTTP_USER_AGENT'] ) ) { @@ -2468,6 +2545,7 @@ function wfHttpOnlySafe() { } } } + return true; } @@ -2644,7 +2722,7 @@ function &wfGetLBFactory() { * @return File, or false if the file does not exist */ function wfFindFile( $title, $time = false, $flags = 0, $bypass = false ) { - if( !$time && !$flags && !$bypass ) { + if( !$time && !$flags && !$bypass ) { return FileCache::singleton()->findFile( $title ); } else { return RepoGroup::singleton()->findFile( $title, $time, $flags ); -- 2.20.1