Wikia code/includes/GlobalFunctions.php
< Wikia code | includes
This page is obsolete. It is being retained for archival purposes. It may document extensions or features that are obsolete and/or no longer supported. Do not rely on the information here being up-to-date. The information shown below refers to the now unmaintained 1.16 MediaWiki release. The current stable release number is 1.42.1. |
--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\GlobalFunctions.php 2011-07-18 22:31:28.024414100 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\GlobalFunctions.php 2011-08-17 15:28:46.386718700 +0100
@@ -539,11 +539,13 @@
return false;
}
// Set $wgReadOnly for faster access next time
+ /**
if ( is_file( $wgReadOnlyFile ) ) {
$wgReadOnly = file_get_contents( $wgReadOnlyFile );
} else {
$wgReadOnly = false;
}
+ **/
return (bool)$wgReadOnly;
}
@@ -1003,13 +1005,30 @@
*/
function wfReportTime() {
global $wgRequestTime, $wgShowHostnames;
+ global $wgRUstart;
+ wfProfileIn( __METHOD__ );
$now = wfTime();
$elapsed = $now - $wgRequestTime;
+ if( isset( $wgRUstart['ru_utime.tv_sec'] ) ) {
+ $rcputime = ( $wgRUstart['ru_utime.tv_sec'] + $wgRUstart['ru_stime.tv_sec']
+ + ($wgRUstart['ru_utime.tv_usec'] + $wgRUstart['ru_stime.tv_usec']) * 1e-6);
+ $ru = getrusage();
+ $ncputime = ( $ru['ru_utime.tv_sec'] + $ru['ru_stime.tv_sec']
+ + ($ru['ru_utime.tv_usec'] + $ru['ru_stime.tv_usec']) * 1e-6);
+ $elapsedcpu = $ncputime - $rcputime;
+ } else {
+ $elapsedcpu = 0;
+ }
+ if( $wgShowHostnames) header( sprintf( "X-Served-By-Backend: %s", wfHostname() ) );
+ /* Wikia change -- log elapsed and cpu times in X-Timer header */
+// wfAppendTimerHeader('ED', $elapsed);
+ wfAppendTimerHeader('CD', $elapsedcpu);
+ wfProfileOut( __METHOD__ );
return $wgShowHostnames
- ? sprintf( "<!-- Served by %s in %01.3f secs. -->", wfHostname(), $elapsed )
- : sprintf( "<!-- Served in %01.3f secs. -->", $elapsed );
+ ? sprintf( "<!-- Served by %s in %01.3f secs. cpu: %01.3f -->", wfHostname(), $elapsed, $elapsedcpu )
+ : sprintf( "<!-- Served in %01.3f secs. cpu: %01.3f -->", $elapsed, $elapsedcpu );
}
/**
@@ -2064,6 +2083,12 @@
}
}
+ global $wgWikiaUseNoFollow;
+ if( !empty( $wgWikiaUseNoFollow ) ) {
+ // not very subtle but tidy(?) gonna sort out multiple nofollows later on
+ $notice = preg_replace('/<a /', '<a rel="nofollow" ', $notice);
+ }
+
wfProfileOut( $fname );
return $notice;
}
@@ -2771,7 +2796,7 @@
* @param $name String
* @param $p Array: parameters
*/
-function wfCreateObject( $name, $p ){
+function wfCreateObject( $name, $p = array() ){
$p = array_values( $p );
switch ( count( $p ) ) {
case 0:
@@ -2833,6 +2858,8 @@
function wfSetupSession() {
global $wgSessionsInMemcached, $wgCookiePath, $wgCookieDomain,
$wgCookieSecure, $wgCookieHttpOnly, $wgSessionHandler;
+ global $wgSessionsInRiak;
+
if( $wgSessionsInMemcached ) {
require_once( 'MemcachedSessions.php' );
} elseif( $wgSessionHandler && $wgSessionHandler != ini_get( 'session.save_handler' ) ) {
@@ -2968,8 +2995,23 @@
* Note: multiple calls to wfGetDB(DB_SLAVE) during the course of one request
* will always return the same object, unless the underlying connection or load
* balancer is manually destroyed.
+ * @return Databases
*/
function &wfGetDB( $db, $groups = array(), $wiki = false ) {
+
+ // wikia change begin -- SMW DB separation project, @author Krzysztof Krzy┼╝aniak (eloy)
+ global $smwgUseExternalDB, $wgDBname;
+ if( $smwgUseExternalDB === true ) {
+ if( ( is_array( $groups ) && in_array( 'smw', $groups ) ) || $groups === 'smw' ) {
+ if( $wiki === false ) {
+ $wiki = $wgDBname;
+ }
+ $wiki = "smw+" . $wiki;
+ wfDebugLog( "connect", __METHOD__ . ": smw+ cluster is active, requesting $wiki\n", true );
+ }
+ }
+ // wikia change end
+//echo $wiki;
return wfGetLB( $wiki )->getConnection( $db, $groups, $wiki );
}