Index: trunk/phase3/maintenance/sqlite/archives/patch-concurrencycheck.sql |
— | — | @@ -0,0 +1,25 @@ |
| 2 | +-- |
| 3 | +-- Store atomic locking information for web resources, to permit |
| 4 | +-- UI that warns users when concurrently editing things that aren't |
| 5 | +-- concurrently editable. |
| 6 | +-- |
| 7 | +CREATE TABLE /*_*/concurrencycheck ( |
| 8 | + -- a string describing the resource or application being checked out. |
| 9 | + cc_resource_type varchar(255) NOT NULL, |
| 10 | + |
| 11 | + -- the (numeric) ID of the record that's being checked out. |
| 12 | + cc_record int unsigned NOT NULL, |
| 13 | + |
| 14 | + -- the user who has control of the resource |
| 15 | + cc_user int unsigned NOT NULL, |
| 16 | + |
| 17 | + -- the date/time on which this record expires |
| 18 | + cc_expiration varbinary(14) not null |
| 19 | + |
| 20 | +) /*$wgDBTableOptions*/; |
| 21 | +-- composite pk. |
| 22 | +CREATE UNIQUE INDEX /*i*/cc_resource_record ON /*_*/concurrencycheck (cc_resource_type, cc_record); |
| 23 | +-- sometimes there's a delete based on userid. |
| 24 | +CREATE INDEX /*i*/cc_user ON /*_*/concurrencycheck (cc_user); |
| 25 | +-- sometimes there's a delete based on expiration |
| 26 | +CREATE INDEX /*i*/cc_expiration ON /*_*/concurrencycheck (cc_expiration); |
Property changes on: trunk/phase3/maintenance/sqlite/archives/patch-concurrencycheck.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 27 | + native |
Index: trunk/phase3/includes/installer/SqliteUpdater.php |
— | — | @@ -71,6 +71,7 @@ |
72 | 72 | array( 'modifyField', 'user', 'ug_group', 'patch-ug_group-length-increase.sql' ), |
73 | 73 | array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ), |
74 | 74 | array( 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ), |
| 75 | + array( 'addTable', 'concurrencycheck', 'patch-concurrencycheck.sql'), |
75 | 76 | ); |
76 | 77 | } |
77 | 78 | |
Index: trunk/phase3/includes/ConcurrencyCheck.php |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | 'cc_resource_type' => $this->resourceType, |
82 | 82 | 'cc_record' => $record, |
83 | 83 | 'cc_user' => $userId, |
84 | | - 'cc_expiration' => time() + $this->expirationTime, |
| 84 | + 'cc_expiration' => wfTimestamp( TS_MW, time() + $this->expirationTime ), |
85 | 85 | ), |
86 | 86 | __METHOD__, |
87 | 87 | array( 'IGNORE' ) |
— | — | @@ -108,11 +108,11 @@ |
109 | 109 | ); |
110 | 110 | |
111 | 111 | // not checked out by current user, checkout is unexpired, override is unset |
112 | | - if( ! ( $override || $row->cc_user == $userId || $row->cc_expiration <= time() ) ) { |
| 112 | + if( ! ( $override || $row->cc_user == $userId || wfTimestamp( TS_UNIX, $row->cc_expiration ) <= time() ) ) { |
113 | 113 | // this was a cache miss. populate the cache with data from the db. |
114 | 114 | // cache is set to expire at the same time as the checkout, since it'll become invalid then anyway. |
115 | 115 | // inside this transaction, a row-level lock is established which ensures cache concurrency |
116 | | - $memc->set( $cacheKey, array( 'userId' => $row->cc_user, 'expiration' => $row->cc_expiration ), $row->cc_expiration - time() ); |
| 116 | + $memc->set( $cacheKey, array( 'userId' => $row->cc_user, 'expiration' => $row->cc_expiration ), wfTimestamp( TS_UNIX, $row->cc_expiration ) - time() ); |
117 | 117 | $dbw->rollback(); |
118 | 118 | return false; |
119 | 119 | } |
— | — | @@ -127,7 +127,7 @@ |
128 | 128 | 'cc_resource_type' => $this->resourceType, |
129 | 129 | 'cc_record' => $record, |
130 | 130 | 'cc_user' => $userId, |
131 | | - 'cc_expiration' => $expiration, |
| 131 | + 'cc_expiration' => wfTimestamp( TS_MW, $expiration ), |
132 | 132 | ), |
133 | 133 | __METHOD__ |
134 | 134 | ); |
— | — | @@ -187,7 +187,7 @@ |
188 | 188 | 'concurrencycheck', |
189 | 189 | array( '*' ), |
190 | 190 | array( |
191 | | - 'cc_expiration <= ' . $now, |
| 191 | + 'cc_expiration <= ' . $dbw->addQuotes( wfTimestamp( TS_MW, $now ) ), |
192 | 192 | ), |
193 | 193 | __METHOD__, |
194 | 194 | array() |
— | — | @@ -203,7 +203,7 @@ |
204 | 204 | $dbw->delete( |
205 | 205 | 'concurrencycheck', |
206 | 206 | array( |
207 | | - 'cc_expiration <= ' . $now, |
| 207 | + 'cc_expiration <= ' . $dbw->addQuotes( wfTimestamp( TS_MW, $now ) ), |
208 | 208 | ), |
209 | 209 | __METHOD__, |
210 | 210 | array() |
— | — | @@ -238,7 +238,7 @@ |
239 | 239 | 'cc_resource_type' => $this->resourceType, |
240 | 240 | 'cc_record' => $key, |
241 | 241 | 'cc_user' => $cached['userId'], |
242 | | - 'cc_expiration' => $cached['expiration'], |
| 242 | + 'cc_expiration' => wfTimestamp( TS_MW, $cached['expiration'] ), |
243 | 243 | 'cache' => 'cached', |
244 | 244 | ); |
245 | 245 | } else { |
— | — | @@ -259,7 +259,7 @@ |
260 | 260 | array( |
261 | 261 | 'cc_resource_type' => $this->resourceType, |
262 | 262 | 'cc_record IN (' . implode( ',', $toSelect ) . ')', |
263 | | - 'cc_expiration > unix_timestamp(now())' |
| 263 | + 'cc_expiration > ' . $dbw->addQuotes( wfTimestamp( TS_MW ) ), |
264 | 264 | ), |
265 | 265 | __METHOD__, |
266 | 266 | array() |