Revert r44918 "Remove unused functions"
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 23 Dec 2008 21:30:19 +0000 (21:30 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 23 Dec 2008 21:30:19 +0000 (21:30 +0000)
We keep these things for backwards compatibility, as they may be in use by extensions even if not in core code.

includes/GlobalFunctions.php

index f47a41e..2b23802 100644 (file)
@@ -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( "<!-- Served by %s in %01.3f secs. -->", wfHostname(), $elapsed )
-               : sprintf( "<!-- Served in %01.3f secs. -->", $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( "<!-- Served by %s in %01.3f secs. -->", wfHostname(), $elapsed )
+                       : sprintf( "<!-- Served in %01.3f secs. -->", $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 );