Index: trunk/extensions/InterfaceConcurrency/tests/phpunit/ConcurrencyCheckTest.php |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | |
61 | 61 | // tests |
62 | 62 | $this->assertTrue( $first->checkout( $testKey ), "Initial checkout" ); |
63 | | - $res = $first->checkoutResult(); |
| 63 | + $res = $first->getCheckoutResult(); |
64 | 64 | $this->assertEquals( $firstId, $res['userId'], "User matches on success"); |
65 | 65 | $this->assertTrue( array_key_exists( 'expiration', $res ), "Expiration is present"); |
66 | 66 | $this->assertTrue( $res['expiration'] > 0, "Expiration is a positive integer"); |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | $wgMemc->delete($cacheKey); |
73 | 73 | $first->lastCheckout = array(); |
74 | 74 | $this->assertTrue( $first->checkout( $testKey ), "Cache miss" ); |
75 | | - $res = $first->checkoutResult(); |
| 75 | + $res = $first->getCheckoutResult(); |
76 | 76 | $this->assertEquals( $firstId, $res['userId'], "User matches on success (nocache)"); |
77 | 77 | $this->assertTrue( array_key_exists( 'expiration', $res ), "Expiration is present (nocache)"); |
78 | 78 | $this->assertTrue( $res['expiration'] > 0, "Expiration is a positive integer (nocache)"); |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | $second->checkout( $testKey ), |
82 | 82 | "Checkout of locked resource fails as different user" |
83 | 83 | ); |
84 | | - $res = $second->checkoutResult(); |
| 84 | + $res = $second->getCheckoutResult(); |
85 | 85 | $this->assertEquals( $firstId, $res['userId'], "Actual owner matches on failure"); |
86 | 86 | $this->assertTrue( $res['expiration'] > 0, "Expiration is a positive integer"); |
87 | 87 | |
Index: trunk/extensions/InterfaceConcurrency/includes/ConcurrencyCheck.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | $cached['expiration'] > time() |
74 | 74 | ) { |
75 | 75 | // this is already checked out. |
76 | | - $this->checkoutResult( $cached ); |
| 76 | + $this->setCheckoutResult( $cached ); |
77 | 77 | return false; |
78 | 78 | } |
79 | 79 | } |
— | — | @@ -105,7 +105,7 @@ |
106 | 106 | $wgMemc->set( $cacheKey, $toCache, $this->expirationTime ); |
107 | 107 | |
108 | 108 | $dbw->commit( __METHOD__ ); |
109 | | - $this->checkoutResult( $toCache ); |
| 109 | + $this->setCheckoutResult( $toCache ); |
110 | 110 | return true; |
111 | 111 | } |
112 | 112 | |
— | — | @@ -145,7 +145,7 @@ |
146 | 146 | ); |
147 | 147 | |
148 | 148 | $dbw->rollback( __METHOD__ ); |
149 | | - $this->checkoutResult( $toCache ); |
| 149 | + $this->setCheckoutResult( $toCache ); |
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
— | — | @@ -172,7 +172,7 @@ |
173 | 173 | ); |
174 | 174 | |
175 | 175 | $dbw->commit( __METHOD__ ); |
176 | | - $this->checkoutResult( $toCache ); |
| 176 | + $this->setCheckoutResult( $toCache ); |
177 | 177 | return true; |
178 | 178 | } |
179 | 179 | |
— | — | @@ -401,15 +401,22 @@ |
402 | 402 | /** |
403 | 403 | * Return information about the owner of the record on which a checkout was last |
404 | 404 | * attempted. |
| 405 | + * |
| 406 | + * @return array |
| 407 | + */ |
| 408 | + public function getCheckoutResult() { |
| 409 | + return $this->lastCheckout; |
| 410 | + } |
| 411 | + |
| 412 | + /** |
| 413 | + * Set information about the owner of the record on which a checkout was last |
| 414 | + * attempted. |
405 | 415 | * |
406 | 416 | * @param $checkoutInfo array (optional) of checkout information to store |
407 | 417 | * @return array |
408 | 418 | */ |
409 | | - public function checkoutResult( $checkoutInfo = null ) { |
410 | | - if( isset( $checkoutInfo ) ) { // true on empty array |
411 | | - $this->lastCheckout = $checkoutInfo; |
412 | | - } |
413 | | - return $this->lastCheckout; |
| 419 | + protected function setCheckoutResult( $checkoutInfo = array() ) { |
| 420 | + $this->lastCheckout = $checkoutInfo; |
414 | 421 | } |
415 | 422 | |
416 | 423 | /** |
Index: trunk/extensions/InterfaceConcurrency/ApiConcurrency.php |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | |
32 | 32 | // data to be utilized by the caller for checkout |
33 | 33 | if ( $params['ccaction'] === 'checkout' ) { |
34 | | - $lastCheckout = $concurrencyCheck->checkoutResult(); |
| 34 | + $lastCheckout = $concurrencyCheck->getCheckoutResult(); |
35 | 35 | |
36 | 36 | if ( $res['result'] === 'success' ) { |
37 | 37 | $user = $wgUser; |