Merge "UserCSSPrefsModule: Remove redundant inline text-decoration:none css rules"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 23 Dec 2015 09:28:40 +0000 (09:28 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 23 Dec 2015 09:28:40 +0000 (09:28 +0000)
includes/DefaultSettings.php
includes/Sanitizer.php
includes/diff/DifferenceEngine.php
includes/libs/objectcache/BagOStuff.php
includes/utils/UIDGenerator.php
languages/i18n/en.json
resources/src/mediawiki.legacy/commonPrint.css
tests/parser/parserTests.txt
tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
tests/phpunit/includes/libs/objectcache/BagOStuffTest.php

index 54216fd..36b6533 100644 (file)
@@ -2609,7 +2609,14 @@ $wgCdnMaxageLagged = 30;
 /**
  * If set, any SquidPurge call on a URL or URLs will send a second purge no less than
  * this many seconds later via the job queue. This requires delayed job support.
- * This should be safely higher than the 'max lag' value in $wgLBFactoryConf.
+ * This should be safely higher than the 'max lag' value in $wgLBFactoryConf, so that
+ * slave lag does not cause page to be stuck in stales states in CDN.
+ *
+ * This also fixes race conditions in two-tiered CDN setups (e.g. cdn2 => cdn1 => MediaWiki).
+ * If a purge for a URL reaches cdn2 before cdn1 and a request reaches cdn2 for that URL,
+ * it will populate the response from the stale cdn1 value. When cdn1 gets the purge, cdn2
+ * will still be stale. If the rebound purge delay is safely higher than the time to relay
+ * a purge to all nodes, then the rebound puge will clear cdn2 after cdn1 was cleared.
  *
  * @since 1.27
  */
index 4fc775f..5242856 100644 (file)
@@ -756,7 +756,9 @@ class Sanitizer {
                        # * data-mw-<name here> is reserved for extensions (or core) if
                        #   they need to communicate some data to the client and want to be
                        #   sure that it isn't coming from an untrusted user.
-                       if ( !preg_match( '/^data-(?!ooui|mw|parsoid)/i', $attribute )
+                       # * Ensure that the attribute is not namespaced by banning
+                       #   colons.
+                       if ( !preg_match( '/^data-(?!ooui|mw|parsoid)[^:]*$/i', $attribute )
                                && !isset( $whitelist[$attribute] )
                        ) {
                                continue;
index 781b6a6..5e37663 100644 (file)
@@ -459,74 +459,93 @@ class DifferenceEngine extends ContextSource {
        }
 
        /**
-        * Get a link to mark the change as patrolled, or '' if there's either no
-        * revision to patrol or the user is not allowed to to it.
+        * Build a link to mark a change as patrolled.
+        *
+        * Returns empty string if there's either no revision to patrol or the user is not allowed to.
         * Side effect: When the patrol link is build, this method will call
         * OutputPage::preventClickjacking() and load mediawiki.page.patrol.ajax.
         *
-        * @return string
+        * @return string HTML or empty string
         */
        protected function markPatrolledLink() {
+               if ( $this->mMarkPatrolledLink === null ) {
+                       $linkInfo = $this->getMarkPatrolledLinkInfo();
+                       // If false, there is no patrol link needed/allowed
+                       if ( !$linkInfo ) {
+                               $this->mMarkPatrolledLink = '';
+                       } else {
+                               $this->mMarkPatrolledLink = ' <span class="patrollink">[' . Linker::linkKnown(
+                                       $this->mNewPage,
+                                       $this->msg( 'markaspatrolleddiff' )->escaped(),
+                                       array(),
+                                       array(
+                                               'action' => 'markpatrolled',
+                                               'rcid' => $linkInfo['rcid'],
+                                               'token' => $linkInfo['token'],
+                                       )
+                               ) . ']</span>';
+                       }
+               }
+               return $this->mMarkPatrolledLink;
+       }
+
+       /**
+        * Returns an array of meta data needed to build a "mark as patrolled" link and
+        * adds the mediawiki.page.patrol.ajax to the output.
+        *
+        * @return array|false An array of meta data for a patrol link (rcid & token)
+        *  or false if no link is needed
+        */
+       protected function getMarkPatrolledLinkInfo() {
                global $wgUseRCPatrol, $wgEnableAPI, $wgEnableWriteAPI;
+
                $user = $this->getUser();
 
-               if ( $this->mMarkPatrolledLink === null ) {
-                       // Prepare a change patrol link, if applicable
-                       if (
-                               // Is patrolling enabled and the user allowed to?
-                               $wgUseRCPatrol && $this->mNewPage->quickUserCan( 'patrol', $user ) &&
-                               // Only do this if the revision isn't more than 6 hours older
-                               // than the Max RC age (6h because the RC might not be cleaned out regularly)
-                               RecentChange::isInRCLifespan( $this->mNewRev->getTimestamp(), 21600 )
-                       ) {
-                               // Look for an unpatrolled change corresponding to this diff
-
-                               $db = wfGetDB( DB_SLAVE );
-                               $change = RecentChange::newFromConds(
-                                       array(
-                                               'rc_timestamp' => $db->timestamp( $this->mNewRev->getTimestamp() ),
-                                               'rc_this_oldid' => $this->mNewid,
-                                               'rc_patrolled' => 0
-                                       ),
-                                       __METHOD__
-                               );
+               // Prepare a change patrol link, if applicable
+               if (
+                       // Is patrolling enabled and the user allowed to?
+                       $wgUseRCPatrol && $this->mNewPage->quickUserCan( 'patrol', $user ) &&
+                       // Only do this if the revision isn't more than 6 hours older
+                       // than the Max RC age (6h because the RC might not be cleaned out regularly)
+                       RecentChange::isInRCLifespan( $this->mNewRev->getTimestamp(), 21600 )
+               ) {
+                       // Look for an unpatrolled change corresponding to this diff
+                       $db = wfGetDB( DB_SLAVE );
+                       $change = RecentChange::newFromConds(
+                               array(
+                                       'rc_timestamp' => $db->timestamp( $this->mNewRev->getTimestamp() ),
+                                       'rc_this_oldid' => $this->mNewid,
+                                       'rc_patrolled' => 0
+                               ),
+                               __METHOD__
+                       );
 
-                               if ( $change && !$change->getPerformer()->equals( $user ) ) {
-                                       $rcid = $change->getAttribute( 'rc_id' );
-                               } else {
-                                       // None found or the page has been created by the current user.
-                                       // If the user could patrol this it already would be patrolled
-                                       $rcid = 0;
+                       if ( $change && !$change->getPerformer()->equals( $user ) ) {
+                               $rcid = $change->getAttribute( 'rc_id' );
+                       } else {
+                               // None found or the page has been created by the current user.
+                               // If the user could patrol this it already would be patrolled
+                               $rcid = 0;
+                       }
+                       // Build the link
+                       if ( $rcid ) {
+                               $this->getOutput()->preventClickjacking();
+                               if ( $wgEnableAPI && $wgEnableWriteAPI
+                                       && $user->isAllowed( 'writeapi' )
+                               ) {
+                                       $this->getOutput()->addModules( 'mediawiki.page.patrol.ajax' );
                                }
-                               // Build the link
-                               if ( $rcid ) {
-                                       $this->getOutput()->preventClickjacking();
-                                       if ( $wgEnableAPI && $wgEnableWriteAPI
-                                               && $user->isAllowed( 'writeapi' )
-                                       ) {
-                                               $this->getOutput()->addModules( 'mediawiki.page.patrol.ajax' );
-                                       }
 
-                                       $token = $user->getEditToken( $rcid );
-                                       $this->mMarkPatrolledLink = ' <span class="patrollink">[' . Linker::linkKnown(
-                                               $this->mNewPage,
-                                               $this->msg( 'markaspatrolleddiff' )->escaped(),
-                                               array(),
-                                               array(
-                                                       'action' => 'markpatrolled',
-                                                       'rcid' => $rcid,
-                                                       'token' => $token,
-                                               )
-                                       ) . ']</span>';
-                               } else {
-                                       $this->mMarkPatrolledLink = '';
-                               }
-                       } else {
-                               $this->mMarkPatrolledLink = '';
+                               $token = $user->getEditToken( $rcid );
+                               return array(
+                                       'rcid' => $rcid,
+                                       'token' => $token,
+                               );
                        }
                }
 
-               return $this->mMarkPatrolledLink;
+               // No mark as patrolled link applicable
+               return false;
        }
 
        /**
index 703c195..b9be43d 100644 (file)
@@ -507,18 +507,27 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface {
        /**
         * Increase stored value of $key by $value while preserving its TTL
         *
-        * This will create the key with value $init and TTL $ttl if not present
+        * This will create the key with value $init and TTL $ttl instead if not present
         *
         * @param string $key
         * @param int $ttl
         * @param int $value
         * @param int $init
-        * @return bool
+        * @return int|bool New value or false on failure
         * @since 1.24
         */
        public function incrWithInit( $key, $ttl, $value = 1, $init = 1 ) {
-               return $this->incr( $key, $value ) ||
-                       $this->add( $key, (int)$init, $ttl ) || $this->incr( $key, $value );
+               $newValue = $this->incr( $key, $value );
+               if ( $newValue === false ) {
+                       // No key set; initialize
+                       $newValue = $this->add( $key, (int)$init, $ttl ) ? $init : false;
+               }
+               if ( $newValue === false ) {
+                       // Raced out initializing; increment
+                       $newValue = $this->incr( $key, $value );
+               }
+
+               return $newValue;
        }
 
        /**
index e2de900..ed7ddb8 100644 (file)
@@ -373,12 +373,9 @@ class UIDGenerator {
                        $cache = ObjectCache::getLocalServerInstance();
                }
                if ( $cache ) {
-                       $counter = $cache->incr( $bucket, $count );
+                       $counter = $cache->incrWithInit( $bucket, $cache::TTL_INDEFINITE, $count, $count );
                        if ( $counter === false ) {
-                               if ( !$cache->add( $bucket, (int)$count ) ) {
-                                       throw new RuntimeException( 'Unable to set value to ' . get_class( $cache ) );
-                               }
-                               $counter = $count;
+                               throw new RuntimeException( 'Unable to set value to ' . get_class( $cache ) );
                        }
                }
 
index 3f761f6..779b8b7 100644 (file)
        "unprotectthispage": "Change protection of this page",
        "newpage": "New page",
        "talkpage": "Discuss this page",
-       "talkpagelinktext": "Talk",
+       "talkpagelinktext": "talk",
        "specialpage": "Special page",
        "personaltools": "Personal tools",
        "addsection": "+",
index 453d928..4803a0a 100644 (file)
@@ -117,22 +117,16 @@ pre, .mw-code {
        border: 1px solid #aaaaaa;
        background-color: #f9f9f9;
        padding: 5px;
-       display: inline-block;
        display: table;
-       /* IE7 and earlier */
-       zoom: 1;
-       *display: inline;
 }
 
 /* Separate columns for tocnumber and toctext */
-/* Ignored by IE7 and lower */
 .tocnumber,
 .toctext {
        display: table-cell;
 }
 
 /* Space between the columns for tocnumber and toctext */
-/* Ignored by IE7 and lower */
 .tocnumber:after {
        content: "";
        padding-right: 0.5em;
@@ -326,7 +320,6 @@ a.sortheader {
        list-style: none;
        list-style-type: none;
        list-style-image: none;
-       vertical-align: middle !ie;
 }
 
 .catlinks li {
@@ -335,8 +328,6 @@ a.sortheader {
        padding: 0 .4em;
        border-left: 1px solid #AAA;
        margin: 0.1em 0;
-       zoom: 1;
-       display: inline !ie;
 }
 
 .catlinks li:first-child {
index a0e0b3a..0ed8270 100644 (file)
@@ -20544,7 +20544,7 @@ HTML5 data attributes
 !! test
 Strip reserved data attributes
 !! wikitext
-<div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy">d</div>
+<div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
 !! html
 <div data-ok="fred">d</div>
 
index 0b87727..552dacb 100644 (file)
@@ -212,7 +212,7 @@ class RCCacheEntryFactoryTest extends MediaWikiLangTestCase {
                                ),
                                'child' => array(
                                        'tag' => 'a',
-                                       'content' => 'Talk',
+                                       'content' => 'talk',
                                )
                        ),
                        $cacheEntry->usertalklink,
index 94b74cb..b9fd6ab 100644 (file)
@@ -183,6 +183,18 @@ class BagOStuffTest extends MediaWikiTestCase {
                $this->assertEquals( $expectedValue, $actualValue, 'Value should be 1 after incrementing' );
        }
 
+       /**
+        * @covers BagOStuff::incrWithInit
+        */
+       public function testIncrWithInit() {
+               $key = wfMemcKey( 'test' );
+               $val = $this->cache->incrWithInit( $key, 0, 1, 3 );
+               $this->assertEquals( 3, $val, "Correct init value" );
+
+               $val = $this->cache->incrWithInit( $key, 0, 1, 3 );
+               $this->assertEquals( 4, $val, "Correct init value" );
+       }
+
        /**
         * @covers BagOStuff::getMulti
         */