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
21 * @ingroup FileBackend
22 * @author Aaron Schulz
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
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
50 protected $noPushDirConts = array();
51 protected $noPushQuickOps = false; // boolean
53 /* Possible internal backend consistency checks */
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 * Use "conservative" to limit resyncing to copying newer master
79 * backend files over older (or non-existing) clone backend files.
80 * Cases that cannot be handled will result in operation abortion.
81 * - noPushQuickOps : (hack) Only apply doQuickOperations() to the master backend.
82 * - noPushDirConts : (hack) Only apply directory functions to the master backend.
84 * @param $config Array
87 public function __construct( array $config ) {
88 parent
::__construct( $config );
89 $this->syncChecks
= isset( $config['syncChecks'] )
90 ?
$config['syncChecks']
92 $this->autoResync
= isset( $config['autoResync'] )
93 ?
$config['autoResync']
95 $this->noPushQuickOps
= isset( $config['noPushQuickOps'] )
96 ?
$config['noPushQuickOps']
98 $this->noPushDirConts
= isset( $config['noPushDirConts'] )
99 ?
$config['noPushDirConts']
101 // Construct backends here rather than via registration
102 // to keep these backends hidden from outside the proxy.
103 $namesUsed = array();
104 foreach ( $config['backends'] as $index => $config ) {
105 if ( isset( $config['template'] ) ) {
106 // Config is just a modified version of a registered backend's.
107 // This should only be used when that config is used only by this backend.
108 $config = $config + FileBackendGroup
::singleton()->config( $config['template'] );
110 $name = $config['name'];
111 if ( isset( $namesUsed[$name] ) ) { // don't break FileOp predicates
112 throw new MWException( "Two or more backends defined with the name $name." );
114 $namesUsed[$name] = 1;
115 // Alter certain sub-backend settings for sanity
116 unset( $config['readOnly'] ); // use proxy backend setting
117 unset( $config['fileJournal'] ); // use proxy backend journal
118 $config['wikiId'] = $this->wikiId
; // use the proxy backend wiki ID
119 $config['lockManager'] = 'nullLockManager'; // lock under proxy backend
120 if ( !empty( $config['isMultiMaster'] ) ) {
121 if ( $this->masterIndex
>= 0 ) {
122 throw new MWException( 'More than one master backend defined.' );
124 $this->masterIndex
= $index; // this is the "master"
125 $config['fileJournal'] = $this->fileJournal
; // log under proxy backend
127 // Create sub-backend object
128 if ( !isset( $config['class'] ) ) {
129 throw new MWException( 'No class given for a backend config.' );
131 $class = $config['class'];
132 $this->backends
[$index] = new $class( $config );
134 if ( $this->masterIndex
< 0 ) { // need backends and must have a master
135 throw new MWException( 'No master backend defined.' );
140 * @see FileBackend::doOperationsInternal()
143 final protected function doOperationsInternal( array $ops, array $opts ) {
144 $status = Status
::newGood();
146 $mbe = $this->backends
[$this->masterIndex
]; // convenience
148 // Get the paths to lock from the master backend
149 $realOps = $this->substOpBatchPaths( $ops, $mbe );
150 $paths = $mbe->getPathsToLockForOpsInternal( $mbe->getOperationsInternal( $realOps ) );
151 // Get the paths under the proxy backend's name
152 $paths['sh'] = $this->unsubstPaths( $paths['sh'] );
153 $paths['ex'] = $this->unsubstPaths( $paths['ex'] );
154 // Try to lock those files for the scope of this function...
155 if ( empty( $opts['nonLocking'] ) ) {
156 // Try to lock those files for the scope of this function...
157 $scopeLockS = $this->getScopedFileLocks( $paths['sh'], LockManager
::LOCK_UW
, $status );
158 $scopeLockE = $this->getScopedFileLocks( $paths['ex'], LockManager
::LOCK_EX
, $status );
159 if ( !$status->isOK() ) {
160 return $status; // abort
163 // Clear any cache entries (after locks acquired)
165 $opts['preserveCache'] = true; // only locked files are cached
166 // Get the list of paths to read/write...
167 $relevantPaths = $this->fileStoragePathsForOps( $ops );
168 // Check if the paths are valid and accessible on all backends...
169 $status->merge( $this->accessibilityCheck( $relevantPaths ) );
170 if ( !$status->isOK() ) {
171 return $status; // abort
173 // Do a consistency check to see if the backends are consistent...
174 $syncStatus = $this->consistencyCheck( $relevantPaths );
175 if ( !$syncStatus->isOK() ) {
176 wfDebugLog( 'FileOperation', get_class( $this ) .
177 " failed sync check: " . FormatJson
::encode( $relevantPaths ) );
178 // Try to resync the clone backends to the master on the spot...
179 if ( !$this->autoResync ||
!$this->resyncFiles( $relevantPaths )->isOK() ) {
180 $status->merge( $syncStatus );
181 return $status; // abort
184 // Actually attempt the operation batch on the master backend...
185 $masterStatus = $mbe->doOperations( $realOps, $opts );
186 $status->merge( $masterStatus );
187 // Propagate the operations to the clone backends if there were no unexpected errors
188 // and if there were either no expected errors or if the 'force' option was used.
189 // However, if nothing succeeded at all, then don't replicate any of the operations.
190 // If $ops only had one operation, this might avoid backend sync inconsistencies.
191 if ( $masterStatus->isOK() && $masterStatus->successCount
> 0 ) {
192 foreach ( $this->backends
as $index => $backend ) {
193 if ( $index !== $this->masterIndex
) { // not done already
194 $realOps = $this->substOpBatchPaths( $ops, $backend );
195 $status->merge( $backend->doOperations( $realOps, $opts ) );
199 // Make 'success', 'successCount', and 'failCount' fields reflect
200 // the overall operation, rather than all the batches for each backend.
201 // Do this by only using success values from the master backend's batch.
202 $status->success
= $masterStatus->success
;
203 $status->successCount
= $masterStatus->successCount
;
204 $status->failCount
= $masterStatus->failCount
;
210 * Check that a set of files are consistent across all internal backends
212 * @param array $paths List of storage paths
215 public function consistencyCheck( array $paths ) {
216 $status = Status
::newGood();
217 if ( $this->syncChecks
== 0 ||
count( $this->backends
) <= 1 ) {
218 return $status; // skip checks
221 $mBackend = $this->backends
[$this->masterIndex
];
222 foreach ( $paths as $path ) {
223 $params = array( 'src' => $path, 'latest' => true );
224 $mParams = $this->substOpPaths( $params, $mBackend );
225 // Stat the file on the 'master' backend
226 $mStat = $mBackend->getFileStat( $mParams );
227 if ( $this->syncChecks
& self
::CHECK_SHA1
) {
228 $mSha1 = $mBackend->getFileSha1Base36( $mParams );
232 // Check if all clone backends agree with the master...
233 foreach ( $this->backends
as $index => $cBackend ) {
234 if ( $index === $this->masterIndex
) {
237 $cParams = $this->substOpPaths( $params, $cBackend );
238 $cStat = $cBackend->getFileStat( $cParams );
239 if ( $mStat ) { // file is in master
240 if ( !$cStat ) { // file should exist
241 $status->fatal( 'backend-fail-synced', $path );
244 if ( $this->syncChecks
& self
::CHECK_SIZE
) {
245 if ( $cStat['size'] != $mStat['size'] ) { // wrong size
246 $status->fatal( 'backend-fail-synced', $path );
250 if ( $this->syncChecks
& self
::CHECK_TIME
) {
251 $mTs = wfTimestamp( TS_UNIX
, $mStat['mtime'] );
252 $cTs = wfTimestamp( TS_UNIX
, $cStat['mtime'] );
253 if ( abs( $mTs - $cTs ) > 30 ) { // outdated file somewhere
254 $status->fatal( 'backend-fail-synced', $path );
258 if ( $this->syncChecks
& self
::CHECK_SHA1
) {
259 if ( $cBackend->getFileSha1Base36( $cParams ) !== $mSha1 ) { // wrong SHA1
260 $status->fatal( 'backend-fail-synced', $path );
264 } else { // file is not in master
265 if ( $cStat ) { // file should not exist
266 $status->fatal( 'backend-fail-synced', $path );
276 * Check that a set of file paths are usable across all internal backends
278 * @param array $paths List of storage paths
281 public function accessibilityCheck( array $paths ) {
282 $status = Status
::newGood();
283 if ( count( $this->backends
) <= 1 ) {
284 return $status; // skip checks
287 foreach ( $paths as $path ) {
288 foreach ( $this->backends
as $backend ) {
289 $realPath = $this->substPaths( $path, $backend );
290 if ( !$backend->isPathUsableInternal( $realPath ) ) {
291 $status->fatal( 'backend-fail-usable', $path );
300 * Check that a set of files are consistent across all internal backends
301 * and re-synchronize those files againt the "multi master" if needed.
303 * @param array $paths List of storage paths
306 public function resyncFiles( array $paths ) {
307 $status = Status
::newGood();
309 $mBackend = $this->backends
[$this->masterIndex
];
310 foreach ( $paths as $path ) {
311 $mPath = $this->substPaths( $path, $mBackend );
312 $mSha1 = $mBackend->getFileSha1Base36( array( 'src' => $mPath, 'latest' => true ) );
313 $mStat = $mBackend->getFileStat( array( 'src' => $mPath, 'latest' => true ) );
314 if ( $mStat === null ||
( $mSha1 !== false && !$mStat ) ) { // sanity
315 $status->fatal( 'backend-fail-internal', $this->name
);
316 continue; // file is not available on the master backend...
318 // Check of all clone backends agree with the master...
319 foreach ( $this->backends
as $index => $cBackend ) {
320 if ( $index === $this->masterIndex
) {
323 $cPath = $this->substPaths( $path, $cBackend );
324 $cSha1 = $cBackend->getFileSha1Base36( array( 'src' => $cPath, 'latest' => true ) );
325 $cStat = $cBackend->getFileStat( array( 'src' => $cPath, 'latest' => true ) );
326 if ( $cStat === null ||
( $cSha1 !== false && !$cStat ) ) { // sanity
327 $status->fatal( 'backend-fail-internal', $cBackend->getName() );
328 continue; // file is not available on the clone backend...
330 if ( $mSha1 === $cSha1 ) {
331 // already synced; nothing to do
332 } elseif ( $mSha1 !== false ) { // file is in master
333 if ( $this->autoResync
=== 'conservative'
334 && $cStat && $cStat['mtime'] > $mStat['mtime'] )
336 $status->fatal( 'backend-fail-synced', $path );
337 continue; // don't rollback data
339 $fsFile = $mBackend->getLocalReference(
340 array( 'src' => $mPath, 'latest' => true ) );
341 $status->merge( $cBackend->quickStore(
342 array( 'src' => $fsFile->getPath(), 'dst' => $cPath )
344 } elseif ( $mStat === false ) { // file is not in master
345 if ( $this->autoResync
=== 'conservative' ) {
346 $status->fatal( 'backend-fail-synced', $path );
347 continue; // don't delete data
349 $status->merge( $cBackend->quickDelete( array( 'src' => $cPath ) ) );
358 * Get a list of file storage paths to read or write for a list of operations
360 * @param array $ops Same format as doOperations()
361 * @return Array List of storage paths to files (does not include directories)
363 protected function fileStoragePathsForOps( array $ops ) {
365 foreach ( $ops as $op ) {
366 if ( isset( $op['src'] ) ) {
367 // For things like copy/move/delete with "ignoreMissingSource" and there
368 // is no source file, nothing should happen and there should be no errors.
369 if ( empty( $op['ignoreMissingSource'] )
370 ||
$this->fileExists( array( 'src' => $op['src'] ) ) )
372 $paths[] = $op['src'];
375 if ( isset( $op['srcs'] ) ) {
376 $paths = array_merge( $paths, $op['srcs'] );
378 if ( isset( $op['dst'] ) ) {
379 $paths[] = $op['dst'];
382 return array_values( array_unique( array_filter( $paths, 'FileBackend::isStoragePath' ) ) );
386 * Substitute the backend name in storage path parameters
387 * for a set of operations with that of a given internal backend.
389 * @param array $ops List of file operation arrays
390 * @param $backend FileBackendStore
393 protected function substOpBatchPaths( array $ops, FileBackendStore
$backend ) {
394 $newOps = array(); // operations
395 foreach ( $ops as $op ) {
396 $newOp = $op; // operation
397 foreach ( array( 'src', 'srcs', 'dst', 'dir' ) as $par ) {
398 if ( isset( $newOp[$par] ) ) { // string or array
399 $newOp[$par] = $this->substPaths( $newOp[$par], $backend );
408 * Same as substOpBatchPaths() but for a single operation
410 * @param array $ops File operation array
411 * @param $backend FileBackendStore
414 protected function substOpPaths( array $ops, FileBackendStore
$backend ) {
415 $newOps = $this->substOpBatchPaths( array( $ops ), $backend );
420 * Substitute the backend of storage paths with an internal backend's name
422 * @param array|string $paths List of paths or single string path
423 * @param $backend FileBackendStore
424 * @return Array|string
426 protected function substPaths( $paths, FileBackendStore
$backend ) {
428 '!^mwstore://' . preg_quote( $this->name
) . '/!',
429 StringUtils
::escapeRegexReplacement( "mwstore://{$backend->getName()}/" ),
430 $paths // string or array
435 * Substitute the backend of internal storage paths with the proxy backend's name
437 * @param array|string $paths List of paths or single string path
438 * @return Array|string
440 protected function unsubstPaths( $paths ) {
442 '!^mwstore://([^/]+)!',
443 StringUtils
::escapeRegexReplacement( "mwstore://{$this->name}" ),
444 $paths // string or array
449 * @see FileBackend::doQuickOperationsInternal()
452 protected function doQuickOperationsInternal( array $ops ) {
453 $status = Status
::newGood();
454 // Do the operations on the master backend; setting Status fields...
455 $realOps = $this->substOpBatchPaths( $ops, $this->backends
[$this->masterIndex
] );
456 $masterStatus = $this->backends
[$this->masterIndex
]->doQuickOperations( $realOps );
457 $status->merge( $masterStatus );
458 // Propagate the operations to the clone backends...
459 if ( !$this->noPushQuickOps
) {
460 foreach ( $this->backends
as $index => $backend ) {
461 if ( $index !== $this->masterIndex
) { // not done already
462 $realOps = $this->substOpBatchPaths( $ops, $backend );
463 $status->merge( $backend->doQuickOperations( $realOps ) );
467 // Make 'success', 'successCount', and 'failCount' fields reflect
468 // the overall operation, rather than all the batches for each backend.
469 // Do this by only using success values from the master backend's batch.
470 $status->success
= $masterStatus->success
;
471 $status->successCount
= $masterStatus->successCount
;
472 $status->failCount
= $masterStatus->failCount
;
477 * @param string $path Storage path
478 * @return bool Path container should have dir changes pushed to all backends
480 protected function replicateContainerDirChanges( $path ) {
481 list( , $shortCont, ) = self
::splitStoragePath( $path );
482 return !in_array( $shortCont, $this->noPushDirConts
);
486 * @see FileBackend::doPrepare()
489 protected function doPrepare( array $params ) {
490 $status = Status
::newGood();
491 $replicate = $this->replicateContainerDirChanges( $params['dir'] );
492 foreach ( $this->backends
as $index => $backend ) {
493 if ( $replicate ||
$index == $this->masterIndex
) {
494 $realParams = $this->substOpPaths( $params, $backend );
495 $status->merge( $backend->doPrepare( $realParams ) );
502 * @see FileBackend::doSecure()
503 * @param $params array
506 protected function doSecure( array $params ) {
507 $status = Status
::newGood();
508 $replicate = $this->replicateContainerDirChanges( $params['dir'] );
509 foreach ( $this->backends
as $index => $backend ) {
510 if ( $replicate ||
$index == $this->masterIndex
) {
511 $realParams = $this->substOpPaths( $params, $backend );
512 $status->merge( $backend->doSecure( $realParams ) );
519 * @see FileBackend::doPublish()
520 * @param $params array
523 protected function doPublish( array $params ) {
524 $status = Status
::newGood();
525 $replicate = $this->replicateContainerDirChanges( $params['dir'] );
526 foreach ( $this->backends
as $index => $backend ) {
527 if ( $replicate ||
$index == $this->masterIndex
) {
528 $realParams = $this->substOpPaths( $params, $backend );
529 $status->merge( $backend->doPublish( $realParams ) );
536 * @see FileBackend::doClean()
537 * @param $params array
540 protected function doClean( array $params ) {
541 $status = Status
::newGood();
542 $replicate = $this->replicateContainerDirChanges( $params['dir'] );
543 foreach ( $this->backends
as $index => $backend ) {
544 if ( $replicate ||
$index == $this->masterIndex
) {
545 $realParams = $this->substOpPaths( $params, $backend );
546 $status->merge( $backend->doClean( $realParams ) );
553 * @see FileBackend::concatenate()
554 * @param $params array
557 public function concatenate( array $params ) {
558 // We are writing to an FS file, so we don't need to do this per-backend
559 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
560 return $this->backends
[$this->masterIndex
]->concatenate( $realParams );
564 * @see FileBackend::fileExists()
565 * @param $params array
568 public function fileExists( array $params ) {
569 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
570 return $this->backends
[$this->masterIndex
]->fileExists( $realParams );
574 * @see FileBackend::getFileTimestamp()
575 * @param $params array
576 * @return bool|string
578 public function getFileTimestamp( array $params ) {
579 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
580 return $this->backends
[$this->masterIndex
]->getFileTimestamp( $realParams );
584 * @see FileBackend::getFileSize()
585 * @param $params array
588 public function getFileSize( array $params ) {
589 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
590 return $this->backends
[$this->masterIndex
]->getFileSize( $realParams );
594 * @see FileBackend::getFileStat()
595 * @param $params array
596 * @return Array|bool|null
598 public function getFileStat( array $params ) {
599 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
600 return $this->backends
[$this->masterIndex
]->getFileStat( $realParams );
604 * @see FileBackend::getFileContentsMulti()
605 * @param $params array
606 * @return bool|string
608 public function getFileContentsMulti( array $params ) {
609 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
610 $contentsM = $this->backends
[$this->masterIndex
]->getFileContentsMulti( $realParams );
612 $contents = array(); // (path => FSFile) mapping using the proxy backend's name
613 foreach ( $contentsM as $path => $data ) {
614 $contents[$this->unsubstPaths( $path )] = $data;
620 * @see FileBackend::getFileSha1Base36()
621 * @param $params array
622 * @return bool|string
624 public function getFileSha1Base36( array $params ) {
625 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
626 return $this->backends
[$this->masterIndex
]->getFileSha1Base36( $realParams );
630 * @see FileBackend::getFileProps()
631 * @param $params array
634 public function getFileProps( array $params ) {
635 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
636 return $this->backends
[$this->masterIndex
]->getFileProps( $realParams );
640 * @see FileBackend::streamFile()
641 * @param $params array
644 public function streamFile( array $params ) {
645 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
646 return $this->backends
[$this->masterIndex
]->streamFile( $realParams );
650 * @see FileBackend::getLocalReferenceMulti()
651 * @param $params array
652 * @return FSFile|null
654 public function getLocalReferenceMulti( array $params ) {
655 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
656 $fsFilesM = $this->backends
[$this->masterIndex
]->getLocalReferenceMulti( $realParams );
658 $fsFiles = array(); // (path => FSFile) mapping using the proxy backend's name
659 foreach ( $fsFilesM as $path => $fsFile ) {
660 $fsFiles[$this->unsubstPaths( $path )] = $fsFile;
666 * @see FileBackend::getLocalCopyMulti()
667 * @param $params array
668 * @return null|TempFSFile
670 public function getLocalCopyMulti( array $params ) {
671 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
672 $tempFilesM = $this->backends
[$this->masterIndex
]->getLocalCopyMulti( $realParams );
674 $tempFiles = array(); // (path => TempFSFile) mapping using the proxy backend's name
675 foreach ( $tempFilesM as $path => $tempFile ) {
676 $tempFiles[$this->unsubstPaths( $path )] = $tempFile;
682 * @see FileBackend::getFileHttpUrl()
683 * @return string|null
685 public function getFileHttpUrl( array $params ) {
686 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
687 return $this->backends
[$this->masterIndex
]->getFileHttpUrl( $realParams );
691 * @see FileBackend::directoryExists()
692 * @param $params array
695 public function directoryExists( array $params ) {
696 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
697 return $this->backends
[$this->masterIndex
]->directoryExists( $realParams );
701 * @see FileBackend::getSubdirectoryList()
702 * @param $params array
703 * @return Array|null|Traversable
705 public function getDirectoryList( array $params ) {
706 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
707 return $this->backends
[$this->masterIndex
]->getDirectoryList( $realParams );
711 * @see FileBackend::getFileList()
712 * @param $params array
713 * @return Array|null|\Traversable
715 public function getFileList( array $params ) {
716 $realParams = $this->substOpPaths( $params, $this->backends
[$this->masterIndex
] );
717 return $this->backends
[$this->masterIndex
]->getFileList( $realParams );
721 * @see FileBackend::clearCache()
723 public function clearCache( array $paths = null ) {
724 foreach ( $this->backends
as $backend ) {
725 $realPaths = is_array( $paths ) ?
$this->substPaths( $paths, $backend ) : null;
726 $backend->clearCache( $realPaths );
731 * @see FileBackend::getScopedLocksForOps()
733 public function getScopedLocksForOps( array $ops, Status
$status ) {
734 $fileOps = $this->backends
[$this->masterIndex
]->getOperationsInternal( $ops );
735 // Get the paths to lock from the master backend
736 $paths = $this->backends
[$this->masterIndex
]->getPathsToLockForOpsInternal( $fileOps );
737 // Get the paths under the proxy backend's name
738 $paths['sh'] = $this->unsubstPaths( $paths['sh'] );
739 $paths['ex'] = $this->unsubstPaths( $paths['ex'] );
741 $this->getScopedFileLocks( $paths['sh'], LockManager
::LOCK_UW
, $status ),
742 $this->getScopedFileLocks( $paths['ex'], LockManager
::LOCK_EX
, $status )