r44976 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44975‎ | r44976 | r44977 >
Date:21:30, 23 December 2008
Author:brion
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -9,6 +9,7 @@
1010 */
1111
1212 require_once dirname(__FILE__) . '/normal/UtfNormalUtil.php';
 13+require_once dirname(__FILE__) . '/XmlFunctions.php';
1314
1415 // Hide compatibility functions from Doxygen
1516 /// @cond
@@ -748,7 +749,47 @@
749750 return $string;
750751 }
751752
 753+
752754 /**
 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+/**
753794 * Print a simple message and die, returning nonzero to the shell if any.
754795 * Plain die() fails to return nonzero to the shell if you pass a string.
755796 * @param string $msg
@@ -796,20 +837,22 @@
797838 return $host;
798839 }
799840
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;
813848
 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+
814857 /**
815858 * Safety wrapper for debug_backtrace().
816859 *
@@ -1165,6 +1208,14 @@
11661209 }
11671210
11681211 /**
 1212+ * This is obsolete, use SquidUpdate::purge()
 1213+ * @deprecated
 1214+ */
 1215+function wfPurgeSquidServers ($urlArr) {
 1216+ SquidUpdate::purge( $urlArr );
 1217+}
 1218+
 1219+/**
11691220 * Windows-compatible version of escapeshellarg()
11701221 * Windows doesn't recognise single-quotes in the shell, but the escapeshellarg()
11711222 * function puts single quotes in regardless of OS.
@@ -2344,6 +2395,13 @@
23452396 }
23462397
23472398 /**
 2399+ * @deprecated use StringUtils::explodeMarkup
 2400+ */
 2401+function wfExplodeMarkup( $separator, $text ) {
 2402+ return StringUtils::explodeMarkup( $separator, $text );
 2403+}
 2404+
 2405+/**
23482406 * Convert an arbitrarily-long digit string from one numeric base
23492407 * to another, optionally zero-padding to a minimum column width.
23502408 *
@@ -2457,10 +2515,29 @@
24582516 }
24592517 }
24602518
 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+
24612537 function wfHttpOnlySafe() {
24622538 global $wgHttpOnlyBlacklist;
24632539 if( !version_compare("5.2", PHP_VERSION, "<") )
24642540 return false;
 2541+
24652542 if( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
24662543 foreach( $wgHttpOnlyBlacklist as $regex ) {
24672544 if( preg_match( $regex, $_SERVER['HTTP_USER_AGENT'] ) ) {
@@ -2468,6 +2545,7 @@
24692546 }
24702547 }
24712548 }
 2549+
24722550 return true;
24732551 }
24742552
@@ -2644,7 +2722,7 @@
26452723 * @return File, or false if the file does not exist
26462724 */
26472725 function wfFindFile( $title, $time = false, $flags = 0, $bypass = false ) {
2648 - if( !$time && !$flags && !$bypass ) {
 2726+ if( !$time && !$flags && !$bypass ) {
26492727 return FileCache::singleton()->findFile( $title );
26502728 } else {
26512729 return RepoGroup::singleton()->findFile( $title, $time, $flags );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r44918Remove unused functionsaaron22:56, 22 December 2008

Status & tagging log