Fixed spacing in actions/cache/filebackend/filerepo/job folder
[mediawiki.git] / includes / filebackend / FileBackendMultiWrite.php
blob17b060c37111541c15ea1259c9ac638f944a88fa
1 <?php
2 /**
3 * Proxy backend that mirrors writes to several internal backends.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup FileBackend
22 * @author Aaron Schulz
25 /**
26 * @brief Proxy backend that mirrors writes to several internal backends.
28 * This class defines a multi-write backend. Multiple backends can be
29 * registered to this proxy backend and it will act as a single backend.
30 * Use this when all access to those backends is through this proxy backend.
31 * At least one of the backends must be declared the "master" backend.
33 * Only use this class when transitioning from one storage system to another.
35 * Read operations are only done on the 'master' backend for consistency.
36 * Write operations are performed on all backends, in the order defined.
37 * If an operation fails on one backend it will be rolled back from the others.
39 * @ingroup FileBackend
40 * @since 1.19
42 class FileBackendMultiWrite extends FileBackend {
43 /** @var Array Prioritized list of FileBackendStore objects */
44 protected $backends = array(); // array of (backend index => backends)
45 protected $masterIndex = -1; // integer; index of master backend
46 protected $syncChecks = 0; // integer; bitfield
47 protected $autoResync = false; // boolean
49 /** @var Array */
50 protected $noPushDirConts = array();
51 protected $noPushQuickOps = false; // boolean
53 /* Possible internal backend consistency checks */
54 const CHECK_SIZE = 1;
55 const CHECK_TIME = 2;
56 const CHECK_SHA1 = 4;
58 /**
59 * Construct a proxy backend that consists of several internal backends.
60 * Locking, journaling, and read-only checks are handled by the proxy backend.
62 * Additional $config params include:
63 * - backends : Array of backend config and multi-backend settings.
64 * Each value is the config used in the constructor of a
65 * FileBackendStore class, but with these additional settings:
66 * - class : The name of the backend class
67 * - isMultiMaster : This must be set for one backend.
68 * - template: : If given a backend name, this will use
69 * the config of that backend as a template.
70 * Values specified here take precedence.
71 * - syncChecks : Integer bitfield of internal backend sync checks to perform.
72 * Possible bits include the FileBackendMultiWrite::CHECK_* constants.
73 * There are constants for SIZE, TIME, and SHA1.
74 * The checks are done before allowing any file operations.
75 * - autoResync : Automatically resync the clone backends to the master backend
76 * when pre-operation sync checks fail. This should only be used
77 * if the master backend is stable and not missing any files.
78 * - noPushQuickOps : (hack) Only apply doQuickOperations() to the master backend.
79 * - noPushDirConts : (hack) Only apply directory functions to the master backend.
81 * @param $config Array
82 * @throws MWException
84 public function __construct( array $config ) {
85 parent::__construct( $config );
86 $this->syncChecks = isset( $config['syncChecks'] )
87 ? $config['syncChecks']
88 : self::CHECK_SIZE;
89 $this->autoResync = !empty( $config['autoResync'] );
90 $this->noPushQuickOps = isset( $config['noPushQuickOps'] )
91 ? $config['noPushQuickOps']
92 : false;
93 $this->noPushDirConts = isset( $config['noPushDirConts'] )
94 ? $config['noPushDirConts']
95 : array();
96 // Construct backends here rather than via registration
97 // to keep these backends hidden from outside the proxy.
98 $namesUsed = array();
99 foreach ( $config['backends'] as $index => $config ) {
100 if ( isset( $config['template'] ) ) {
101 // Config is just a modified version of a registered backend's.
102 // This should only be used when that config is used only by this backend.
103 $config = $config + FileBackendGroup::singleton()->config( $config['template'] );
105 $name = $config['name'];
106 if ( isset( $namesUsed[$name] ) ) { // don't break FileOp predicates
107 throw new MWException( "Two or more backends defined with the name $name." );
109 $namesUsed[$name] = 1;
110 // Alter certain sub-backend settings for sanity
111 unset( $config['readOnly'] ); // use proxy backend setting
112 unset( $config['fileJournal'] ); // use proxy backend journal
113 $config['wikiId'] = $this->wikiId; // use the proxy backend wiki ID
114 $config['lockManager'] = 'nullLockManager'; // lock under proxy backend
115 if ( !empty( $config['isMultiMaster'] ) ) {
116 if ( $this->masterIndex >= 0 ) {
117 throw new MWException( 'More than one master backend defined.' );
119 $this->masterIndex = $index; // this is the "master"
120 $config['fileJournal'] = $this->fileJournal; // log under proxy backend
122 // Create sub-backend object
123 if ( !isset( $config['class'] ) ) {
124 throw new MWException( 'No class given for a backend config.' );
126 $class = $config['class'];
127 $this->backends[$index] = new $class( $config );
129 if ( $this->masterIndex < 0 ) { // need backends and must have a master
130 throw new MWException( 'No master backend defined.' );
135 * @see FileBackend::doOperationsInternal()
136 * @return Status
138 final protected function doOperationsInternal( array $ops, array $opts ) {
139 $status = Status::newGood();
141 $mbe = $this->backends[$this->masterIndex]; // convenience
143 // Get the paths to lock from the master backend
144 $realOps = $this->substOpBatchPaths( $ops, $mbe );
145 $paths = $mbe->getPathsToLockForOpsInternal( $mbe->getOperationsInternal( $realOps ) );
146 // Get the paths under the proxy backend's name
147 $paths['sh'] = $this->unsubstPaths( $paths['sh'] );
148 $paths['ex'] = $this->unsubstPaths( $paths['ex'] );
149 // Try to lock those files for the scope of this function...
150 if ( empty( $opts['nonLocking'] ) ) {
151 // Try to lock those files for the scope of this function...
152 $scopeLockS = $this->getScopedFileLocks( $paths['sh'], LockManager::LOCK_UW, $status );
153 $scopeLockE = $this->getScopedFileLocks( $paths['ex'], LockManager::LOCK_EX, $status );
154 if ( !$status->isOK() ) {
155 return $status; // abort
158 // Clear any cache entries (after locks acquired)
159 $this->clearCache();
160 $opts['preserveCache'] = true; // only locked files are cached
161 // Get the list of paths to read/write...
162 $relevantPaths = $this->fileStoragePathsForOps( $ops );
163 // Check if the paths are valid and accessible on all backends...
164 $status->merge( $this->accessibilityCheck( $relevantPaths ) );
165 if ( !$status->isOK() ) {
166 return $status; // abort
168 // Do a consistency check to see if the backends are consistent...
169 $syncStatus = $this->consistencyCheck( $relevantPaths );
170 if ( !$syncStatus->isOK() ) {
171 wfDebugLog( 'FileOperation', get_class( $this ) .
172 " failed sync check: " . FormatJson::encode( $relevantPaths ) );
173 // Try to resync the clone backends to the master on the spot...
174 if ( !$this->autoResync || !$this->resyncFiles( $relevantPaths )->isOK() ) {
175 $status->merge( $syncStatus );
176 return $status; // abort
179 // Actually attempt the operation batch on the master backend...
180 $masterStatus = $mbe->doOperations( $realOps, $opts );
181 $status->merge( $masterStatus );
182 // Propagate the operations to the clone backends if there were no unexpected errors
183 // and if there were either no expected errors or if the 'force' option was used.
184 // However, if nothing succeeded at all, then don't replicate any of the operations.
185 // If $ops only had one operation, this might avoid backend sync inconsistencies.
186 if ( $masterStatus->isOK() && $masterStatus->successCount > 0 ) {
187 foreach ( $this->backends as $index => $backend ) {
188 if ( $index !== $this->masterIndex ) { // not done already
189 $realOps = $this->substOpBatchPaths( $ops, $backend );
190 $status->merge( $backend->doOperations( $realOps, $opts ) );
194 // Make 'success', 'successCount', and 'failCount' fields reflect
195 // the overall operation, rather than all the batches for each backend.
196 // Do this by only using success values from the master backend's batch.
197 $status->success = $masterStatus->success;
198 $status->successCount = $masterStatus->successCount;
199 $status->failCount = $masterStatus->failCount;
201 return $status;
205 * Check that a set of files are consistent across all internal backends
207 * @param array $paths List of storage paths
208 * @return Status
210 public function consistencyCheck( array $paths ) {
211 $status = Status::newGood();
212 if ( $this->syncChecks == 0 || count( $this->backends ) <= 1 ) {
213 return $status; // skip checks
216 $mBackend = $this->backends[$this->masterIndex];
217 foreach ( $paths as $path ) {
218 $params = array( 'src' => $path, 'latest' => true );
219 $mParams = $this->substOpPaths( $params, $mBackend );
220 // Stat the file on the 'master' backend
221 $mStat = $mBackend->getFileStat( $mParams );
222 if ( $this->syncChecks & self::CHECK_SHA1 ) {
223 $mSha1 = $mBackend->getFileSha1Base36( $mParams );
224 } else {
225 $mSha1 = false;
227 // Check if all clone backends agree with the master...
228 foreach ( $this->backends as $index => $cBackend ) {
229 if ( $index === $this->masterIndex ) {
230 continue; // master
232 $cParams = $this->substOpPaths( $params, $cBackend );
233 $cStat = $cBackend->getFileStat( $cParams );
234 if ( $mStat ) { // file is in master
235 if ( !$cStat ) { // file should exist
236 $status->fatal( 'backend-fail-synced', $path );
237 continue;
239 if ( $this->syncChecks & self::CHECK_SIZE ) {
240 if ( $cStat['size'] != $mStat['size'] ) { // wrong size
241 $status->fatal( 'backend-fail-synced', $path );
242 continue;
245 if ( $this->syncChecks & self::CHECK_TIME ) {
246 $mTs = wfTimestamp( TS_UNIX, $mStat['mtime'] );
247 $cTs = wfTimestamp( TS_UNIX, $cStat['mtime'] );
248 if ( abs( $mTs - $cTs ) > 30 ) { // outdated file somewhere
249 $status->fatal( 'backend-fail-synced', $path );
250 continue;
253 if ( $this->syncChecks & self::CHECK_SHA1 ) {
254 if ( $cBackend->getFileSha1Base36( $cParams ) !== $mSha1 ) { // wrong SHA1
255 $status->fatal( 'backend-fail-synced', $path );
256 continue;
259 } else { // file is not in master
260 if ( $cStat ) { // file should not exist
261 $status->fatal( 'backend-fail-synced', $path );
267 return $status;
271 * Check that a set of file paths are usable across all internal backends
273 * @param array $paths List of storage paths
274 * @return Status
276 public function accessibilityCheck( array $paths ) {
277 $status = Status::newGood();
278 if ( count( $this->backends ) <= 1 ) {
279 return $status; // skip checks
282 foreach ( $paths as $path ) {
283 foreach ( $this->backends as $backend ) {
284 $realPath = $this->substPaths( $path, $backend );
285 if ( !$backend->isPathUsableInternal( $realPath ) ) {
286 $status->fatal( 'backend-fail-usable', $path );
291 return $status;
295 * Check that a set of files are consistent across all internal backends
296 * and re-synchronize those files againt the "multi master" if needed.
298 * @param array $paths List of storage paths
299 * @return Status
301 public function resyncFiles( array $paths ) {
302 $status = Status::newGood();
304 $mBackend = $this->backends[$this->masterIndex];
305 foreach ( $paths as $path ) {
306 $mPath = $this->substPaths( $path, $mBackend );
307 $mSha1 = $mBackend->getFileSha1Base36( array( 'src' => $mPath ) );
308 $mExist = $mBackend->fileExists( array( 'src' => $mPath ) );
309 // Check if the master backend is available...
310 if ( $mExist === null ) {
311 $status->fatal( 'backend-fail-internal', $this->name );
313 // Check of all clone backends agree with the master...
314 foreach ( $this->backends as $index => $cBackend ) {
315 if ( $index === $this->masterIndex ) {
316 continue; // master
318 $cPath = $this->substPaths( $path, $cBackend );
319 $cSha1 = $cBackend->getFileSha1Base36( array( 'src' => $cPath ) );
320 if ( $mSha1 === $cSha1 ) {
321 // already synced; nothing to do
322 } elseif ( $mSha1 ) { // file is in master
323 $fsFile = $mBackend->getLocalReference( array( 'src' => $mPath ) );
324 $status->merge( $cBackend->quickStore(
325 array( 'src' => $fsFile->getPath(), 'dst' => $cPath )
326 ) );
327 } elseif ( $mExist === false ) { // file is not in master
328 $status->merge( $cBackend->quickDelete( array( 'src' => $cPath ) ) );
333 return $status;
337 * Get a list of file storage paths to read or write for a list of operations
339 * @param array $ops Same format as doOperations()
340 * @return Array List of storage paths to files (does not include directories)
342 protected function fileStoragePathsForOps( array $ops ) {
343 $paths = array();
344 foreach ( $ops as $op ) {
345 if ( isset( $op['src'] ) ) {
346 // For things like copy/move/delete with "ignoreMissingSource" and there
347 // is no source file, nothing should happen and there should be no errors.
348 if ( empty( $op['ignoreMissingSource'] )
349 || $this->fileExists( array( 'src' => $op['src'] ) ) )
351 $paths[] = $op['src'];
354 if ( isset( $op['srcs'] ) ) {
355 $paths = array_merge( $paths, $op['srcs'] );
357 if ( isset( $op['dst'] ) ) {
358 $paths[] = $op['dst'];
361 return array_values( array_unique( array_filter( $paths, 'FileBackend::isStoragePath' ) ) );
365 * Substitute the backend name in storage path parameters
366 * for a set of operations with that of a given internal backend.
368 * @param array $ops List of file operation arrays
369 * @param $backend FileBackendStore
370 * @return Array
372 protected function substOpBatchPaths( array $ops, FileBackendStore $backend ) {
373 $newOps = array(); // operations
374 foreach ( $ops as $op ) {
375 $newOp = $op; // operation
376 foreach ( array( 'src', 'srcs', 'dst', 'dir' ) as $par ) {
377 if ( isset( $newOp[$par] ) ) { // string or array
378 $newOp[$par] = $this->substPaths( $newOp[$par], $backend );
381 $newOps[] = $newOp;
383 return $newOps;
387 * Same as substOpBatchPaths() but for a single operation
389 * @param array $ops File operation array
390 * @param $backend FileBackendStore
391 * @return Array
393 protected function substOpPaths( array $ops, FileBackendStore $backend ) {
394 $newOps = $this->substOpBatchPaths( array( $ops ), $backend );
395 return $newOps[0];
399 * Substitute the backend of storage paths with an internal backend's name
401 * @param array|string $paths List of paths or single string path
402 * @param $backend FileBackendStore
403 * @return Array|string
405 protected function substPaths( $paths, FileBackendStore $backend ) {
406 return preg_replace(
407 '!^mwstore://' . preg_quote( $this->name ) . '/!',
408 StringUtils::escapeRegexReplacement( "mwstore://{$backend->getName()}/" ),
409 $paths // string or array
414 * Substitute the backend of internal storage paths with the proxy backend's name
416 * @param array|string $paths List of paths or single string path
417 * @return Array|string
419 protected function unsubstPaths( $paths ) {
420 return preg_replace(
421 '!^mwstore://([^/]+)!',
422 StringUtils::escapeRegexReplacement( "mwstore://{$this->name}" ),
423 $paths // string or array
428 * @see FileBackend::doQuickOperationsInternal()
429 * @return Status
431 protected function doQuickOperationsInternal( array $ops ) {
432 $status = Status::newGood();
433 // Do the operations on the master backend; setting Status fields...
434 $realOps = $this->substOpBatchPaths( $ops, $this->backends[$this->masterIndex] );
435 $masterStatus = $this->backends[$this->masterIndex]->doQuickOperations( $realOps );
436 $status->merge( $masterStatus );
437 // Propagate the operations to the clone backends...
438 if ( !$this->noPushQuickOps ) {
439 foreach ( $this->backends as $index => $backend ) {
440 if ( $index !== $this->masterIndex ) { // not done already
441 $realOps = $this->substOpBatchPaths( $ops, $backend );
442 $status->merge( $backend->doQuickOperations( $realOps ) );
446 // Make 'success', 'successCount', and 'failCount' fields reflect
447 // the overall operation, rather than all the batches for each backend.
448 // Do this by only using success values from the master backend's batch.
449 $status->success = $masterStatus->success;
450 $status->successCount = $masterStatus->successCount;
451 $status->failCount = $masterStatus->failCount;
452 return $status;
456 * @param string $path Storage path
457 * @return bool Path container should have dir changes pushed to all backends
459 protected function replicateContainerDirChanges( $path ) {
460 list( , $shortCont, ) = self::splitStoragePath( $path );
461 return !in_array( $shortCont, $this->noPushDirConts );
465 * @see FileBackend::doPrepare()
466 * @return Status
468 protected function doPrepare( array $params ) {
469 $status = Status::newGood();
470 $replicate = $this->replicateContainerDirChanges( $params['dir'] );
471 foreach ( $this->backends as $index => $backend ) {
472 if ( $replicate || $index == $this->masterIndex ) {
473 $realParams = $this->substOpPaths( $params, $backend );
474 $status->merge( $backend->doPrepare( $realParams ) );
477 return $status;
481 * @see FileBackend::doSecure()
482 * @param $params array
483 * @return Status
485 protected function doSecure( array $params ) {
486 $status = Status::newGood();
487 $replicate = $this->replicateContainerDirChanges( $params['dir'] );
488 foreach ( $this->backends as $index => $backend ) {
489 if ( $replicate || $index == $this->masterIndex ) {
490 $realParams = $this->substOpPaths( $params, $backend );
491 $status->merge( $backend->doSecure( $realParams ) );
494 return $status;
498 * @see FileBackend::doPublish()
499 * @param $params array
500 * @return Status
502 protected function doPublish( array $params ) {
503 $status = Status::newGood();
504 $replicate = $this->replicateContainerDirChanges( $params['dir'] );
505 foreach ( $this->backends as $index => $backend ) {
506 if ( $replicate || $index == $this->masterIndex ) {
507 $realParams = $this->substOpPaths( $params, $backend );
508 $status->merge( $backend->doPublish( $realParams ) );
511 return $status;
515 * @see FileBackend::doClean()
516 * @param $params array
517 * @return Status
519 protected function doClean( array $params ) {
520 $status = Status::newGood();
521 $replicate = $this->replicateContainerDirChanges( $params['dir'] );
522 foreach ( $this->backends as $index => $backend ) {
523 if ( $replicate || $index == $this->masterIndex ) {
524 $realParams = $this->substOpPaths( $params, $backend );
525 $status->merge( $backend->doClean( $realParams ) );
528 return $status;
532 * @see FileBackend::concatenate()
533 * @param $params array
534 * @return Status
536 public function concatenate( array $params ) {
537 // We are writing to an FS file, so we don't need to do this per-backend
538 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
539 return $this->backends[$this->masterIndex]->concatenate( $realParams );
543 * @see FileBackend::fileExists()
544 * @param $params array
545 * @return bool|null
547 public function fileExists( array $params ) {
548 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
549 return $this->backends[$this->masterIndex]->fileExists( $realParams );
553 * @see FileBackend::getFileTimestamp()
554 * @param $params array
555 * @return bool|string
557 public function getFileTimestamp( array $params ) {
558 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
559 return $this->backends[$this->masterIndex]->getFileTimestamp( $realParams );
563 * @see FileBackend::getFileSize()
564 * @param $params array
565 * @return bool|int
567 public function getFileSize( array $params ) {
568 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
569 return $this->backends[$this->masterIndex]->getFileSize( $realParams );
573 * @see FileBackend::getFileStat()
574 * @param $params array
575 * @return Array|bool|null
577 public function getFileStat( array $params ) {
578 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
579 return $this->backends[$this->masterIndex]->getFileStat( $realParams );
583 * @see FileBackend::getFileContentsMulti()
584 * @param $params array
585 * @return bool|string
587 public function getFileContentsMulti( array $params ) {
588 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
589 $contentsM = $this->backends[$this->masterIndex]->getFileContentsMulti( $realParams );
591 $contents = array(); // (path => FSFile) mapping using the proxy backend's name
592 foreach ( $contentsM as $path => $data ) {
593 $contents[$this->unsubstPaths( $path )] = $data;
595 return $contents;
599 * @see FileBackend::getFileSha1Base36()
600 * @param $params array
601 * @return bool|string
603 public function getFileSha1Base36( array $params ) {
604 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
605 return $this->backends[$this->masterIndex]->getFileSha1Base36( $realParams );
609 * @see FileBackend::getFileProps()
610 * @param $params array
611 * @return Array
613 public function getFileProps( array $params ) {
614 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
615 return $this->backends[$this->masterIndex]->getFileProps( $realParams );
619 * @see FileBackend::streamFile()
620 * @param $params array
621 * @return \Status
623 public function streamFile( array $params ) {
624 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
625 return $this->backends[$this->masterIndex]->streamFile( $realParams );
629 * @see FileBackend::getLocalReferenceMulti()
630 * @param $params array
631 * @return FSFile|null
633 public function getLocalReferenceMulti( array $params ) {
634 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
635 $fsFilesM = $this->backends[$this->masterIndex]->getLocalReferenceMulti( $realParams );
637 $fsFiles = array(); // (path => FSFile) mapping using the proxy backend's name
638 foreach ( $fsFilesM as $path => $fsFile ) {
639 $fsFiles[$this->unsubstPaths( $path )] = $fsFile;
641 return $fsFiles;
645 * @see FileBackend::getLocalCopyMulti()
646 * @param $params array
647 * @return null|TempFSFile
649 public function getLocalCopyMulti( array $params ) {
650 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
651 $tempFilesM = $this->backends[$this->masterIndex]->getLocalCopyMulti( $realParams );
653 $tempFiles = array(); // (path => TempFSFile) mapping using the proxy backend's name
654 foreach ( $tempFilesM as $path => $tempFile ) {
655 $tempFiles[$this->unsubstPaths( $path )] = $tempFile;
657 return $tempFiles;
661 * @see FileBackend::getFileHttpUrl()
662 * @return string|null
664 public function getFileHttpUrl( array $params ) {
665 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
666 return $this->backends[$this->masterIndex]->getFileHttpUrl( $realParams );
670 * @see FileBackend::directoryExists()
671 * @param $params array
672 * @return bool|null
674 public function directoryExists( array $params ) {
675 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
676 return $this->backends[$this->masterIndex]->directoryExists( $realParams );
680 * @see FileBackend::getSubdirectoryList()
681 * @param $params array
682 * @return Array|null|Traversable
684 public function getDirectoryList( array $params ) {
685 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
686 return $this->backends[$this->masterIndex]->getDirectoryList( $realParams );
690 * @see FileBackend::getFileList()
691 * @param $params array
692 * @return Array|null|\Traversable
694 public function getFileList( array $params ) {
695 $realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
696 return $this->backends[$this->masterIndex]->getFileList( $realParams );
700 * @see FileBackend::clearCache()
702 public function clearCache( array $paths = null ) {
703 foreach ( $this->backends as $backend ) {
704 $realPaths = is_array( $paths ) ? $this->substPaths( $paths, $backend ) : null;
705 $backend->clearCache( $realPaths );
710 * @see FileBackend::getScopedLocksForOps()
712 public function getScopedLocksForOps( array $ops, Status $status ) {
713 $fileOps = $this->backends[$this->masterIndex]->getOperationsInternal( $ops );
714 // Get the paths to lock from the master backend
715 $paths = $this->backends[$this->masterIndex]->getPathsToLockForOpsInternal( $fileOps );
716 // Get the paths under the proxy backend's name
717 $paths['sh'] = $this->unsubstPaths( $paths['sh'] );
718 $paths['ex'] = $this->unsubstPaths( $paths['ex'] );
719 return array(
720 $this->getScopedFileLocks( $paths['sh'], LockManager::LOCK_UW, $status ),
721 $this->getScopedFileLocks( $paths['ex'], LockManager::LOCK_EX, $status )