global $wgDebugLogGroups, $wgDBname;
if( $text{strlen( $text ) - 1} != "\n" ) $text .= "\n";
if( isset( $wgDebugLogGroups[$logGroup] ) ) {
- @error_log( "$wgDBname: $text", 3, $wgDebugLogGroups[$logGroup] );
+ $time = wfTimestamp( TS_DB );
+ @error_log( "$time $wgDBname: $text", 3, $wgDebugLogGroups[$logGroup] );
} else if ( $public === true ) {
wfDebug( $text, true );
}
*/
function wfMsgReal( $key, $args, $useDB, $forContent=false, $transform = true ) {
$fname = 'wfMsgReal';
- wfProfileIn( $fname );
$message = wfMsgGetKey( $key, $useDB, $forContent, $transform );
$message = wfMsgReplaceArgs( $message, $args );
- wfProfileOut( $fname );
return $message;
}
}
if ( wfIsWindows() ) {
- $retVal .= '"' . str_replace( '"','\"', $arg ) . '"';
+ // Escaping for an MSVC-style command line parser
+ // Ref: http://mailman.lyra.org/pipermail/scite-interest/2002-March/000436.html
+ // Double the backslashes before any double quotes. Escape the double quotes.
+ $tokens = preg_split( '/(\\\\*")/', $arg, -1, PREG_SPLIT_DELIM_CAPTURE );
+ $arg = '';
+ $delim = false;
+ foreach ( $tokens as $token ) {
+ if ( $delim ) {
+ $arg .= str_replace( '\\', '\\\\', substr( $token, 0, -1 ) ) . '\\"';
+ } else {
+ $arg .= $token;
+ }
+ $delim = !$delim;
+ }
+ // Double the backslashes before the end of the string, because
+ // we will soon add a quote
+ if ( preg_match( '/^(.*?)(\\\\+)$/', $arg, $m ) ) {
+ $arg = $m[1] . str_replace( '\\', '\\\\', $m[2] );
+ }
+
+ // Add surrounding quotes
+ $retVal .= '"' . $arg . '"';
} else {
$retVal .= escapeshellarg( $arg );
}
return $notice;
}
+function wfGetNamespaceNotice() {
+ global $wgTitle;
+
+ # Paranoia
+ if ( !isset( $wgTitle ) || !is_object( $wgTitle ) )
+ return "";
+
+ $fname = 'wfGetNamespaceNotice';
+ wfProfileIn( $fname );
+
+ $key = "namespacenotice-" . $wgTitle->getNsText();
+ $namespaceNotice = wfGetCachedNotice( $key );
+ if ( $namespaceNotice && substr ( $namespaceNotice , 0 ,7 ) != "<p><" ) {
+ $namespaceNotice = '<div id="namespacebanner">' . $namespaceNotice . "</div>";
+ } else {
+ $namespaceNotice = "";
+ }
+
+ wfProfileOut( $fname );
+ return $namespaceNotice;
+}
+
function wfGetSiteNotice() {
global $wgUser, $wgSiteNotice;
$fname = 'wfGetSiteNotice';
$siteNotice = $anonNotice;
}
}
-
+
wfProfileOut( $fname );
return( $siteNotice );
}
$selected = intval( $selected );
}
}
- $s = "<select name='namespace' class='namespaceselector'>\n\t";
+ $s = "<select id='namespace' name='namespace' class='namespaceselector'>\n\t";
$arr = $wgContLang->getFormattedNamespaces();
if( !is_null($allnamespaces) ) {
$arr = array($allnamespaces => wfMsgHtml('namespacesall')) + $arr;
*/
function wfIncrStats( $key ) {
global $wgDBname, $wgMemc;
+ /* LIVE HACK AVOID MEMCACHED ACCESSES DURING HIGH LOAD */
+ if ($wgDBname != 'enwiki' and $wgDBname != 'dewiki' and $wgDBname != 'commonswiki' and $wgDBname != 'testwiki')
+ return true;
+ static $socket;
+ if (!$socket) {
+ $socket=socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
+ $statline="{$wgDBname} - 1 1 1 1 1 -total\n";
+ socket_sendto($socket,$statline,strlen($statline),0,"webster","3811");
+ }
+ $statline="{$wgDBname} - 1 1 1 1 1 {$key}\n";
+ socket_sendto($socket,$statline,strlen($statline),0,"webster","3811");
+ return true;
+
$key = "$wgDBname:stats:$key";
if ( is_null( $wgMemc->incr( $key ) ) ) {
$wgMemc->add( $key, 1 );
function wfUrlProtocols() {
global $wgUrlProtocols;
- $protocols = array();
- foreach ($wgUrlProtocols as $protocol)
- $protocols[] = preg_quote( $protocol, '/' );
+ // Support old-style $wgUrlProtocols strings, for backwards compatibility
+ // with LocalSettings files from 1.5
+ if ( is_array( $wgUrlProtocols ) ) {
+ $protocols = array();
+ foreach ($wgUrlProtocols as $protocol)
+ $protocols[] = preg_quote( $protocol, '/' );
- return implode( '|', $protocols );
+ return implode( '|', $protocols );
+ } else {
+ return $wgUrlProtocols;
+ }
}
/**
$cmd = escapeshellarg( $script ) . " $time $memKB $cmd";
}
}
+ } elseif ( php_uname( 's' ) == 'Windows NT' ) {
+ # This is a hack to work around PHP's flawed invocation of cmd.exe
+ # http://news.php.net/php.internals/21796
+ $cmd = '"' . $cmd . '"';
}
return shell_exec( $cmd );
}
// Reverse the labels in the hostname, convert to lower case
$reversedHost = strtolower( implode( '.', array_reverse( explode( '.', $bits['host'] ) ) ) );
// Add an extra dot to the end
- if ( substr( $reversedHost, -1 ) !== '.' ) {
+ if ( substr( $reversedHost, -1, 1 ) !== '.' ) {
$reversedHost .= '.';
}
// Reconstruct the pseudo-URL
return $index;
}
+/**
+ * Do any deferred updates and clear the list
+ * TODO: This could be in Wiki.php if that class made any sense at all
+ */
+function wfDoUpdates()
+{
+ global $wgPostCommitUpdateList, $wgDeferredUpdateList;
+ foreach ( $wgDeferredUpdateList as $update ) {
+ $update->doUpdate();
+ }
+ foreach ( $wgPostCommitUpdateList as $update ) {
+ $update->doUpdate();
+ }
+ $wgDeferredUpdateList = array();
+ $wgPostCommitUpdateList = array();
+}
+
?>