Merge "StringUtils: Add a utility for checking if a string is a valid regex"
[lhc/web/wiklou.git] / includes / libs / objectcache / MultiWriteBagOStuff.php
index 31d73e1..77a7883 100644 (file)
@@ -46,7 +46,7 @@ class MultiWriteBagOStuff extends BagOStuff {
        /**
         * $params include:
         *   - caches: A numbered array of either ObjectFactory::getObjectFromSpec
-        *      arrays yeilding BagOStuff objects or direct BagOStuff objects.
+        *      arrays yielding BagOStuff objects or direct BagOStuff objects.
         *      If using the former, the 'args' field *must* be set.
         *      The first cache is the primary one, being the first to
         *      be read in the fallback chain. Writes happen to all stores
@@ -61,6 +61,7 @@ class MultiWriteBagOStuff extends BagOStuff {
         *      invalidation uses logical TTLs, invalidation uses etag/timestamp
         *      validation against the DB, or merge() is used to handle races.
         * @param array $params
+        * @phan-param array{caches:array<int,array|BagOStuff>,replication:string} $params
         * @throws InvalidArgumentException
         */
        public function __construct( $params ) {
@@ -123,9 +124,10 @@ class MultiWriteBagOStuff extends BagOStuff {
                        $missIndexes[] = $i;
                }
 
-               if ( $value !== false
-                       && $missIndexes
-                       && $this->fieldHasFlags( $flags, self::READ_VERIFIED )
+               if (
+                       $value !== false &&
+                       $this->fieldHasFlags( $flags, self::READ_VERIFIED ) &&
+                       $missIndexes
                ) {
                        // Backfill the value to the higher (and often faster/smaller) cache tiers
                        $this->doWrite(
@@ -265,7 +267,7 @@ class MultiWriteBagOStuff extends BagOStuff {
                );
        }
 
-       public function incr( $key, $value = 1 ) {
+       public function incr( $key, $value = 1, $flags = 0 ) {
                return $this->doWrite(
                        $this->cacheIndexes,
                        $this->asyncWrites,
@@ -274,7 +276,7 @@ class MultiWriteBagOStuff extends BagOStuff {
                );
        }
 
-       public function decr( $key, $value = 1 ) {
+       public function decr( $key, $value = 1, $flags = 0 ) {
                return $this->doWrite(
                        $this->cacheIndexes,
                        $this->asyncWrites,
@@ -283,7 +285,7 @@ class MultiWriteBagOStuff extends BagOStuff {
                );
        }
 
-       public function incrWithInit( $key, $ttl, $value = 1, $init = 1 ) {
+       public function incrWithInit( $key, $exptime, $value = 1, $init = null, $flags = 0 ) {
                return $this->doWrite(
                        $this->cacheIndexes,
                        $this->asyncWrites,