Merge "Remove "successfully" from specialmute-success and add a link title"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 4 Jul 2019 19:04:26 +0000 (19:04 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 4 Jul 2019 19:04:26 +0000 (19:04 +0000)
RELEASE-NOTES-1.34
includes/libs/objectcache/BagOStuff.php
includes/libs/rdbms/database/IDatabase.php
includes/objectcache/SqlBagOStuff.php
resources/src/startup/mediawiki.js

index d708dd6..3223948 100644 (file)
@@ -260,6 +260,9 @@ because of Phabricator reports.
   removed.
 * The JavaScript global variable wgLoadScript has been removed. Use
   mw.util.wikiScript( 'load' ) instead.
+* ResourceLoader no longer creates the 'mw.legacy' placeholder object. It has
+  been unused since 1.16 and was deprecated in 1.22. To deprecate a property
+  in JavaScript, use mw.log.deprecate() instead.
 * …
 
 === Deprecations in 1.34 ===
index 50441c5..7759947 100644 (file)
@@ -590,7 +590,11 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface {
         * @return bool Success
         */
        public function unlock( $key ) {
-               if ( isset( $this->locks[$key] ) && --$this->locks[$key]['depth'] <= 0 ) {
+               if ( !isset( $this->locks[$key] ) ) {
+                       return false;
+               }
+
+               if ( --$this->locks[$key]['depth'] <= 0 ) {
                        unset( $this->locks[$key] );
 
                        $ok = $this->doDelete( "{$key}:lock" );
index fca2c00..ad6d4d2 100644 (file)
@@ -2112,7 +2112,7 @@ interface IDatabase {
         *
         * @param string $lockName Name of lock to aquire
         * @param string $method Name of the calling method
-        * @param int $timeout Acquisition timeout in seconds
+        * @param int $timeout Acquisition timeout in seconds (0 means non-blocking)
         * @return bool
         * @throws DBError
         */
index 8a5f591..39d0353 100644 (file)
@@ -338,6 +338,7 @@ class SqlBagOStuff extends BagOStuff {
 
                $result = true;
                $exptime = (int)$expiry;
+               /** @noinspection PhpUnusedLocalVariableInspection */
                $silenceScope = $this->silenceTransactionProfiler();
                foreach ( $keysByTable as $serverIndex => $serverKeys ) {
                        $db = null;
@@ -406,6 +407,7 @@ class SqlBagOStuff extends BagOStuff {
        protected function cas( $casToken, $key, $value, $exptime = 0, $flags = 0 ) {
                list( $serverIndex, $tableName ) = $this->getTableByKey( $key );
                $db = null;
+               /** @noinspection PhpUnusedLocalVariableInspection */
                $silenceScope = $this->silenceTransactionProfiler();
                try {
                        $db = $this->getDB( $serverIndex );
@@ -457,6 +459,7 @@ class SqlBagOStuff extends BagOStuff {
                }
 
                $result = true;
+               /** @noinspection PhpUnusedLocalVariableInspection */
                $silenceScope = $this->silenceTransactionProfiler();
                foreach ( $keysByTable as $serverIndex => $serverKeys ) {
                        $db = null;
@@ -495,6 +498,7 @@ class SqlBagOStuff extends BagOStuff {
        public function incr( $key, $step = 1 ) {
                list( $serverIndex, $tableName ) = $this->getTableByKey( $key );
                $db = null;
+               /** @noinspection PhpUnusedLocalVariableInspection */
                $silenceScope = $this->silenceTransactionProfiler();
                try {
                        $db = $this->getDB( $serverIndex );
@@ -553,6 +557,7 @@ class SqlBagOStuff extends BagOStuff {
        public function changeTTL( $key, $exptime = 0, $flags = 0 ) {
                list( $serverIndex, $tableName ) = $this->getTableByKey( $key );
                $db = null;
+               /** @noinspection PhpUnusedLocalVariableInspection */
                $silenceScope = $this->silenceTransactionProfiler();
                try {
                        $db = $this->getDB( $serverIndex );
@@ -635,6 +640,7 @@ class SqlBagOStuff extends BagOStuff {
         * @return bool
         */
        public function deleteObjectsExpiringBefore( $timestamp, $progressCallback = false ) {
+               /** @noinspection PhpUnusedLocalVariableInspection */
                $silenceScope = $this->silenceTransactionProfiler();
                for ( $serverIndex = 0; $serverIndex < $this->numServers; $serverIndex++ ) {
                        $db = null;
@@ -713,6 +719,7 @@ class SqlBagOStuff extends BagOStuff {
         * @return bool
         */
        public function deleteAll() {
+               /** @noinspection PhpUnusedLocalVariableInspection */
                $silenceScope = $this->silenceTransactionProfiler();
                for ( $serverIndex = 0; $serverIndex < $this->numServers; $serverIndex++ ) {
                        $db = null;
@@ -729,6 +736,68 @@ class SqlBagOStuff extends BagOStuff {
                return true;
        }
 
+       public function lock( $key, $timeout = 6, $expiry = 6, $rclass = '' ) {
+               // Avoid deadlocks and allow lock reentry if specified
+               if ( isset( $this->locks[$key] ) ) {
+                       if ( $rclass != '' && $this->locks[$key]['class'] === $rclass ) {
+                               ++$this->locks[$key]['depth'];
+                               return true;
+                       } else {
+                               return false;
+                       }
+               }
+
+               list( $serverIndex ) = $this->getTableByKey( $key );
+               try {
+                       $db = $this->getDB( $serverIndex );
+                       $ok = $db->lock( $key, __METHOD__, $timeout );
+                       if ( $ok ) {
+                               $this->locks[$key] = [ 'class' => $rclass, 'depth' => 1 ];
+                       }
+
+                       $this->logger->warning(
+                               __METHOD__ . " failed due to timeout for {key}.",
+                               [ 'key' => $key, 'timeout' => $timeout ]
+                       );
+
+                       return $ok;
+               } catch ( DBError $e ) {
+                       $this->handleWriteError( $e, $db, $serverIndex );
+                       $ok = false;
+               }
+
+               return $ok;
+       }
+
+       public function unlock( $key ) {
+               if ( !isset( $this->locks[$key] ) ) {
+                       return false;
+               }
+
+               if ( --$this->locks[$key]['depth'] <= 0 ) {
+                       unset( $this->locks[$key] );
+
+                       list( $serverIndex ) = $this->getTableByKey( $key );
+                       try {
+                               $db = $this->getDB( $serverIndex );
+                               $ok = $db->unlock( $key, __METHOD__ );
+                               if ( !$ok ) {
+                                       $this->logger->warning(
+                                               __METHOD__ . ' failed to release lock for {key}.',
+                                               [ 'key' => $key ]
+                                       );
+                               }
+                       } catch ( DBError $e ) {
+                               $this->handleWriteError( $e, $db, $serverIndex );
+                               $ok = false;
+                       }
+               } else {
+                       $ok = false;
+               }
+
+               return $ok;
+       }
+
        /**
         * Serialize an object and, if possible, compress the representation.
         * On typical message and page data, this can provide a 3X decrease
@@ -790,8 +859,8 @@ class SqlBagOStuff extends BagOStuff {
         * @param int $serverIndex
         * @throws Exception
         */
-       protected function handleWriteError( DBError $exception, IDatabase $db = null, $serverIndex ) {
-               if ( !$db ) {
+       protected function handleWriteError( DBError $exception, $db, $serverIndex ) {
+               if ( !( $db instanceof IDatabase ) ) {
                        $this->markServerDown( $exception, $serverIndex );
                }
 
index 2976dca..d339704 100644 (file)
                 */
                libs: {},
 
-               /**
-                * Access container for deprecated functionality that can be moved from
-                * from their legacy location and attached to this object (e.g. a global
-                * function that is deprecated and as stop-gap can be exposed through here).
-                *
-                * This was reserved for future use but never ended up being used.
-                *
-                * @deprecated since 1.22 Let deprecated identifiers keep their original name
-                *  and use mw.log#deprecate to create an access container for tracking.
-                * @property
-                */
-               legacy: {},
-
                /**
                 * Store for messages.
                 *