Matthias Mullie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/189487

Change subject: Stop cas support
......................................................................

Stop cas support

I3ef82226231f7e03f7493ae042cad22339f4c869 makes all BagOStuff
cas implementations protected.
Flow wasn't really using that, so let's remove support for it.
Well, it is using it as part of it's merge, but that part still
has access to the BagOStuff's cas methods, so we're good there!

Change-Id: I566f5d70f14ffe4c6f0c290f0666cff9637908bb
---
M includes/Data/BagOStuff/BufferedBagOStuff.php
M includes/Data/BufferedCache.php
M tests/phpunit/Data/BagOStuff/BufferedBagOStuffTest.php
3 files changed, 9 insertions(+), 84 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/87/189487/1

diff --git a/includes/Data/BagOStuff/BufferedBagOStuff.php 
b/includes/Data/BagOStuff/BufferedBagOStuff.php
index 680d023..09432aa 100644
--- a/includes/Data/BagOStuff/BufferedBagOStuff.php
+++ b/includes/Data/BagOStuff/BufferedBagOStuff.php
@@ -231,7 +231,7 @@
         * @param int $exptime
         * @return bool
         */
-       public function cas( $casToken, $key, $value, $exptime = 0 ) {
+       protected function cas( $casToken, $key, $value, $exptime = 0 ) {
                $cache = $this->cache;
                $originalValue = isset( $this->casTokens[$casToken] ) ? 
$this->casTokens[$casToken] : null;
 
@@ -254,6 +254,14 @@
                        // Check if the value we just read from real cache is 
still the same
                        // as the one we saved when doing the original fetch
                        if ( serialize( $current ) === $originalValue ) {
+                               /*
+                                * Note that all BagOStuff::cas implementations 
are protected!
+                                * We can still call it from here because this 
class too extends
+                                * from BagOStuff, where the cas method is 
defined. PHP will
+                                * allow us access because "because the 
implementation specific
+                                * details are already known."
+                                */
+
                                // Everything still checked out, let's CAS the 
value for real now
                                return $cache->cas( $casToken, $key, $value, 
$exptime );
                        }
diff --git a/includes/Data/BufferedCache.php b/includes/Data/BufferedCache.php
index 12c73f8..94cf5ee 100644
--- a/includes/Data/BufferedCache.php
+++ b/includes/Data/BufferedCache.php
@@ -74,16 +74,6 @@
        }
 
        /**
-        * @param mixed $casToken
-        * @param string $key
-        * @param mixed $value
-        * @return bool
-        */
-       public function cas( $casToken, $key, $value ) {
-               return $this->cache->cas( $casToken, $key, $value, 
$this->exptime );
-       }
-
-       /**
         * @param string $key
         * @param int $time
         * @return bool
diff --git a/tests/phpunit/Data/BagOStuff/BufferedBagOStuffTest.php 
b/tests/phpunit/Data/BagOStuff/BufferedBagOStuffTest.php
index 30c7aa3..1b5368e 100644
--- a/tests/phpunit/Data/BagOStuff/BufferedBagOStuffTest.php
+++ b/tests/phpunit/Data/BagOStuff/BufferedBagOStuffTest.php
@@ -114,79 +114,6 @@
                $this->assertEquals( false, $this->cache->get( 'key' ) );
        }
 
-       public function testCas() {
-               $this->cache->set( 'key', 'value' );
-
-               $casToken = null;
-               $this->bufferedCache->get( 'key', $casToken );
-               $this->bufferedCache->cas( $casToken, 'key', 'updated-value' );
-
-               // check that the value has been CAS'ed to bufferedcache (only)
-               $this->assertEquals( 'updated-value', 
$this->bufferedCache->get( 'key' ) );
-               $this->assertEquals( 'value', $this->cache->get( 'key' ) );
-
-               $this->bufferedCache->commit();
-
-               // check that the value has also been CAS'ed to real cache
-               $this->assertEquals( 'updated-value', 
$this->bufferedCache->get( 'key' ) );
-               $this->assertEquals( 'updated-value', $this->cache->get( 'key' 
) );
-       }
-
-       public function testConsecutiveCas() {
-               $this->cache->set( 'key', 'value' );
-
-               $casToken = null;
-               $this->bufferedCache->get( 'key', $casToken );
-               $this->bufferedCache->cas( $casToken, 'key', 'updated-value' );
-               $this->bufferedCache->get( 'key', $casToken );
-               $this->bufferedCache->cas( $casToken, 'key', 'updated-value-2' 
);
-
-               // check that the value has been CAS'ed to bufferedcache (only)
-               $this->assertEquals( 'updated-value-2', 
$this->bufferedCache->get( 'key' ) );
-               $this->assertEquals( 'value', $this->cache->get( 'key' ) );
-
-               $this->bufferedCache->commit();
-
-               // check that the value has also been CAS'ed to real cache
-               $this->assertEquals( 'updated-value-2', 
$this->bufferedCache->get( 'key' ) );
-               $this->assertEquals( 'updated-value-2', $this->cache->get( 
'key' ) );
-       }
-
-       public function testCasFailImmediately() {
-               $this->cache->set( 'key', 'value' );
-
-               $casToken = null;
-               $this->bufferedCache->get( 'key', $casToken );
-               $this->bufferedCache->cas( 'wrong-token', 'key', 
'updated-value' );
-
-               $this->bufferedCache->commit();
-
-               // check that the value hasn't been CAS'ed anywhere
-               $this->assertEquals( 'value', $this->bufferedCache->get( 'key' 
) );
-               $this->assertEquals( 'value', $this->cache->get( 'key' ) );
-       }
-
-       public function testCasFailDeferred() {
-               $this->cache->set( 'key', 'value' );
-
-               $casToken = null;
-               $this->bufferedCache->get( 'key', $casToken );
-               $this->bufferedCache->cas( $casToken, 'key', 'updated-value' );
-
-               // something else directly overwrites key in the meantime...
-               $this->cache->set( 'key', 'conflicting-value' );
-
-               // check that the value has been CAS'ed to buffered cache but 
not yet to real cache
-               $this->assertEquals( 'updated-value', 
$this->bufferedCache->get( 'key' ) );
-               $this->assertEquals( 'conflicting-value', $this->cache->get( 
'key' ) );
-
-               $this->bufferedCache->commit();
-
-               // check that the value failed to CAS
-               $this->assertEquals( false, $this->bufferedCache->get( 'key' ) 
);
-               $this->assertEquals( false, $this->cache->get( 'key' ) );
-       }
-
        public function testDelete() {
                $this->cache->set( 'key', 'value' );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/189487
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I566f5d70f14ffe4c6f0c290f0666cff9637908bb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to