*/
$wgStatsFormatString = "stats/%s - %s 1 1 1 1 %s\n";
+/**
+ * Destination of statsd metrics.
+ *
+ * A host or host:port of a statsd server. Port defaults to 8125.
+ *
+ * If not set, statsd metrics will not be collected.
+ *
+ * @see wfLogProfilingData
+ * @since 1.25
+ */
+$wgStatsdServer = false;
+
+/**
+ * Prefix for metric names sent to wgStatsdServer.
+ *
+ * Defaults to "MediaWiki".
+ *
+ * @see RequestContext::getStats
+ * @see BufferingStatsdDataFactory
+ * @since 1.25
+ */
+$wgStatsdMetricPrefix = false;
+
/**
* InfoAction retrieves a list of transclusion links (both to and from).
* This number puts a limit on that query in the case of highly transcluded
$profiler->logData();
$config = $context->getConfig();
- if ( $config->has( 'StatsdServer' ) ) {
+ if ( $config->get( 'StatsdServer' ) ) {
$statsdServer = explode( ':', $config->get( 'StatsdServer' ) );
$statsdHost = $statsdServer[0];
$statsdPort = isset( $statsdServer[1] ) ? $statsdServer[1] : 8125;
/**
* Get the user touched timestamp
+ *
+ * Use this value only to validate caches via inequalities
+ * such as in the case of HTTP If-Modified-Since response logic
+ *
* @return string TS_MW Timestamp
*/
public function getTouched() {
if ( $this->mId ) {
if ( $this->mQuickTouched === null ) {
$key = wfMemcKey( 'user-quicktouched', 'id', $this->mId );
+ $cache = ObjectCache::getMainWANInstance();
- $timestamp = ObjectCache::getMainWANInstance()->getCheckKeyTime( $key );
- if ( $timestamp ) {
- $this->mQuickTouched = wfTimestamp( TS_MW, (int)$timestamp );
- } else {
- # Set the timestamp to get HTTP 304 cache hits
- $this->touch();
- }
+ $this->mQuickTouched = wfTimestamp( TS_MW, $cache->getCheckKeyTime( $key ) );
}
return max( $this->mTouched, $this->mQuickTouched );
* Returns the description string for this module
*
* Ignored if an i18n message exists for
- * "apihelp-{$this->getModulePathString()}-description".
+ * "apihelp-{$this->getModulePath()}-description".
*
* @deprecated since 1.25
* @return Message|string|array
*
* For each parameter, ignored if an i18n message exists for the parameter.
* By default that message is
- * "apihelp-{$this->getModulePathString()}-param-{$param}", but it may be
+ * "apihelp-{$this->getModulePath()}-param-{$param}", but it may be
* overridden using ApiBase::PARAM_HELP_MSG in the data returned by
* self::getFinalParams().
*
"apihelp-watch-example-unwatch": "Unwatch the page <kbd>Main Page</kbd>.",
"apihelp-watch-example-generator": "Watch the first few pages in the main namespace.",
- "apihelp-format-example-generic": "Format the query result in the $1 format.",
+ "apihelp-format-example-generic": "Return the query result in the $1 format.",
"apihelp-dbg-description": "Output data in PHP's <code>var_export()</code> format.",
"apihelp-dbgfm-description": "Output data in PHP's <code>var_export()</code> format (pretty-print in HTML).",
"apihelp-json-description": "Output data in JSON format.",
public function getStats() {
if ( $this->stats === null ) {
$config = $this->getConfig();
- $prefix = $config->has( 'StatsdMetricPrefix' )
+ $prefix = $config->get( 'StatsdMetricPrefix' )
? rtrim( $config->get( 'StatsdMetricPrefix' ), '.' )
: 'MediaWiki';
$this->stats = new BufferingStatsdDataFactory( $prefix );
/**
* Fetch the value of a timestamp "check" key
*
+ * The key will be *initialized* to the current time if not set,
+ * so only call this method if this behavior is actually desired
+ *
+ * The timestamp can be used to check whether a cached value is valid.
+ * Callers should not assume that this returns the same timestamp in
+ * all datacenters due to relay delays.
+ *
+ * The level of staleness can roughly be estimated from this key, but
+ * if the key was evicted from cache, such calculations may show the
+ * time since expiry as ~0 seconds.
+ *
* Note that "check" keys won't collide with other regular keys
*
* @param string $key
- * @return float|bool TS_UNIX timestamp of the key; false if not present
+ * @return float UNIX timestamp of the key
*/
final public function getCheckKeyTime( $key ) {
- return self::parsePurgeValue( $this->cache->get( self::TIME_KEY_PREFIX . $key ) );
+ $key = self::TIME_KEY_PREFIX . $key;
+
+ $time = self::parsePurgeValue( $this->cache->get( $key ) );
+ if ( $time === false ) {
+ $time = microtime( true );
+ $this->cache->add( $key, self::PURGE_VAL_PREFIX . $time, self::CHECK_KEY_TTL );
+ }
+
+ return $time;
}
/**
* @return bool
*/
public function set( $key, $value, $exptime = 0 ) {
- list( $serverIndex, $tableName ) = $this->getTableByKey( $key );
- try {
- $db = $this->getDB( $serverIndex );
- $exptime = intval( $exptime );
-
- if ( $exptime < 0 ) {
- $exptime = 0;
- }
-
- if ( $exptime == 0 ) {
- $encExpiry = $this->getMaxDateTime( $db );
- } else {
- $exptime = $this->convertExpiry( $exptime );
- $encExpiry = $db->timestamp( $exptime );
- }
- // (bug 24425) use a replace if the db supports it instead of
- // delete/insert to avoid clashes with conflicting keynames
- $db->replace(
- $tableName,
- array( 'keyname' ),
- array(
- 'keyname' => $key,
- 'value' => $db->encodeBlob( $this->serialize( $value ) ),
- 'exptime' => $encExpiry
- ), __METHOD__ );
- } catch ( DBError $e ) {
- $this->handleWriteError( $e, $serverIndex );
- return false;
- }
-
- return true;
+ return $this->setMulti( array( $key => $value ), $exptime );
}
/**
$legend .= Html::element( 'dt',
array( 'class' => $cssClass ), $context->msg( $letter )->text()
) . "\n" .
- Html::rawElement( 'dd', array(),
+ Html::rawElement( 'dd',
+ array( 'class' => Sanitizer::escapeClass( 'mw-changeslist-legend-' . $key ) ),
$context->msg( $label )->parse()
) . "\n";
}
$this->msg( 'parentheses', $this->msg( 'editlink' )->text() )->escaped(),
array(),
array(
- 'redirect' => 'no',
'action' => 'edit'
)
);
// Icon related variables
-@iconSize: 1.4em;
+@iconSize: 1.5em;
@iconGutterWidth: 1em;
public function testTouchKeys() {
$key = wfRandomString();
+ $priorTime = microtime( true );
+ usleep( 1 );
$t0 = $this->cache->getCheckKeyTime( $key );
- $this->assertFalse( $t0, 'Check key time is false' );
+ $this->assertGreaterThanOrEqual( $priorTime, $t0, 'Check key auto-created' );
$priorTime = microtime( true );
usleep( 1 );