Merge "Revision: Interpret a NULL rev_content_model as the default model"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 2 Jul 2015 15:02:08 +0000 (15:02 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 2 Jul 2015 15:02:08 +0000 (15:02 +0000)
12 files changed:
includes/DefaultSettings.php
includes/GlobalFunctions.php
includes/User.php
includes/api/ApiBase.php
includes/api/i18n/en.json
includes/context/RequestContext.php
includes/libs/objectcache/WANObjectCache.php
includes/objectcache/SqlBagOStuff.php
includes/specialpage/ChangesListSpecialPage.php
includes/specials/SpecialDoubleRedirects.php
resources/src/mediawiki.less/mediawiki.ui/variables.less
tests/phpunit/includes/objectcache/WANObjectCacheTest.php

index a239e68..7dbe35a 100644 (file)
@@ -5693,6 +5693,29 @@ $wgAggregateStatsID = false;
  */
 $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
index c618426..97042fd 100644 (file)
@@ -1248,7 +1248,7 @@ function wfLogProfilingData() {
        $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;
index 46d53b8..63c0d37 100644 (file)
@@ -2326,6 +2326,10 @@ class User implements IDBAccessObject {
 
        /**
         * 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() {
@@ -2334,14 +2338,9 @@ class User implements IDBAccessObject {
                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 );
index 4b76e65..393ff49 100644 (file)
@@ -2481,7 +2481,7 @@ abstract class ApiBase extends ContextSource {
         * 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
@@ -2495,7 +2495,7 @@ abstract class ApiBase extends ContextSource {
         *
         * 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().
         *
index 680f9ae..c0633bc 100644 (file)
        "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.",
index d1bc597..e676ec9 100644 (file)
@@ -131,7 +131,7 @@ class RequestContext implements IContextSource {
        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 );
index 5d9557a..c32efb9 100644 (file)
@@ -279,13 +279,32 @@ class WANObjectCache {
        /**
         * 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;
        }
 
        /**
index 1ed8ef5..3b46249 100644 (file)
@@ -370,37 +370,7 @@ class SqlBagOStuff extends BagOStuff {
         * @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 );
        }
 
        /**
index b913235..23bd394 100644 (file)
@@ -434,7 +434,8 @@ abstract class ChangesListSpecialPage extends SpecialPage {
                        $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";
                }
index c364f70..47b426d 100644 (file)
@@ -156,7 +156,6 @@ class DoubleRedirectsPage extends QueryPage {
                        $this->msg( 'parentheses', $this->msg( 'editlink' )->text() )->escaped(),
                        array(),
                        array(
-                               'redirect' => 'no',
                                'action' => 'edit'
                        )
                );
index 47a83b3..10f64be 100644 (file)
@@ -229,8 +229,10 @@ class WANObjectCacheTest extends MediaWikiTestCase {
        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 );