Index: branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php |
— | — | @@ -8,7 +8,8 @@ |
9 | 9 | /** |
10 | 10 | * This class defines a multi-write backend. Multiple backends can |
11 | 11 | * be registered to this proxy backend it will act as a single backend. |
12 | | - * Use this only if all access to the backends is through an instance of this class. |
| 12 | + * Use this when all access to the backends is through this proxy backend. |
| 13 | + * At least one of the backends must be declared the "master" backend. |
13 | 14 | * |
14 | 15 | * The order that the backends are defined sets the priority of which |
15 | 16 | * backend is read from or written to first. Functions like fileExists() |
— | — | @@ -16,8 +17,10 @@ |
17 | 18 | * that has the file (normally both should have it anyway). Special cases: |
18 | 19 | * a) getFileList() will return results from the first backend that is |
19 | 20 | * not declared as non-persistent cache. This is for correctness. |
20 | | - * b) getFileHash() will always check only the master backend to keep the |
21 | | - * result format consistent. |
| 21 | + * b) getFileTimestamp() will always check only the master backend to |
| 22 | + * avoid confusing and inconsistent results. |
| 23 | + * c) getFileHash() will always check only the master backend to keep |
| 24 | + * the result format consistent. |
22 | 25 | * |
23 | 26 | * All write operations are performed on all backends. |
24 | 27 | * If an operation fails on one backend it will be rolled back from the others. |
— | — | @@ -171,11 +174,19 @@ |
172 | 175 | function secure( array $params ) { |
173 | 176 | $status = Status::newGood(); |
174 | 177 | foreach ( $this->backends as $backend ) { |
175 | | - $status->merge( $backend->prepare( $params ) ); |
| 178 | + $status->merge( $backend->secure( $params ) ); |
176 | 179 | } |
177 | 180 | return $status; |
178 | 181 | } |
179 | 182 | |
| 183 | + function clean( array $params ) { |
| 184 | + $status = Status::newGood(); |
| 185 | + foreach ( $this->backends as $backend ) { |
| 186 | + $status->merge( $backend->clean( $params ) ); |
| 187 | + } |
| 188 | + return $status; |
| 189 | + } |
| 190 | + |
180 | 191 | function fileExists( array $params ) { |
181 | 192 | foreach ( $this->backends as $backend ) { |
182 | 193 | if ( $backend->fileExists( $params ) ) { |
— | — | @@ -185,6 +196,11 @@ |
186 | 197 | return false; |
187 | 198 | } |
188 | 199 | |
| 200 | + function getFileTimestamp( array $params ) { |
| 201 | + // Skip non-master for consistent timestamps |
| 202 | + return $this->backends[$this->masterIndex]->getFileTimestamp( $params ); |
| 203 | + } |
| 204 | + |
189 | 205 | function getFileHash( array $params ) { |
190 | 206 | // Skip non-master for consistent hash formats |
191 | 207 | return $this->backends[$this->masterIndex]->getFileHash( $params ); |