<?php
/**
+ * Proxy backend that mirrors writes to several internal backends.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
* @file
* @ingroup FileBackend
* @author Aaron Schulz
* FileBackendStore class, but with these additional settings:
* 'class' : The name of the backend class
* 'isMultiMaster' : This must be set for one backend.
+ * 'template: : If given a backend name, this will use
+ * the config of that backend as a template.
+ * Values specified here take precedence.
* 'syncChecks' : Integer bitfield of internal backend sync checks to perform.
* Possible bits include self::CHECK_SIZE and self::CHECK_TIME.
* The checks are done before allowing any file operations.
// Construct backends here rather than via registration
// to keep these backends hidden from outside the proxy.
foreach ( $config['backends'] as $index => $config ) {
+ if ( isset( $config['template'] ) ) {
+ // Config is just a modified version of a registered backend's.
+ // This should only be used when that config is used only be this backend.
+ $config = $config + FileBackendGroup::singleton()->config( $config['template'] );
+ }
$name = $config['name'];
if ( isset( $namesUsed[$name] ) ) { // don't break FileOp predicates
throw new MWException( "Two or more backends defined with the name $name." );
}
// Actually attempt the operation batch...
- $subStatus = FileOp::attemptBatch( $performOps, $opts, $this->fileJournal );
+ $subStatus = FileOpBatch::attempt( $performOps, $opts, $this->fileJournal );
$success = array();
$failCount = 0;
/**
* Same as substOpBatchPaths() but for a single operation
*
- * @param $op File operation array
+ * @param $ops array File operation array
* @param $backend FileBackendStore
* @return Array
*/
);
}
+ /**
+ * @see FileBackend::doQuickOperationsInternal()
+ * @return Status
+ */
+ public function doQuickOperationsInternal( array $ops ) {
+ // Do the operations on the master backend; setting Status fields...
+ $realOps = $this->substOpBatchPaths( $ops, $this->backends[$this->masterIndex] );
+ $status = $this->backends[$this->masterIndex]->doQuickOperations( $realOps );
+ // Propagate the operations to the clone backends...
+ foreach ( $this->backends as $index => $backend ) {
+ if ( $index !== $this->masterIndex ) { // not done already
+ $realOps = $this->substOpBatchPaths( $ops, $backend );
+ $status->merge( $backend->doQuickOperations( $realOps ) );
+ }
+ }
+ return $status;
+ }
+
/**
* @see FileBackend::doPrepare()
* @return Status
/**
* @see FileBackend::doSecure()
+ * @param $params array
* @return Status
*/
protected function doSecure( array $params ) {
/**
* @see FileBackend::doClean()
+ * @param $params array
* @return Status
*/
protected function doClean( array $params ) {
/**
* @see FileBackend::concatenate()
+ * @param $params array
+ * @return Status
*/
public function concatenate( array $params ) {
// We are writing to an FS file, so we don't need to do this per-backend
/**
* @see FileBackend::fileExists()
+ * @param $params array
*/
public function fileExists( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileTimestamp()
+ * @param $params array
+ * @return bool|string
*/
public function getFileTimestamp( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileSize()
+ * @param $params array
+ * @return bool|int
*/
public function getFileSize( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileStat()
+ * @param $params array
+ * @return Array|bool|null
*/
public function getFileStat( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileContents()
+ * @param $params array
+ * @return bool|string
*/
public function getFileContents( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileSha1Base36()
+ * @param $params array
+ * @return bool|string
*/
public function getFileSha1Base36( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileProps()
+ * @param $params array
+ * @return Array
*/
public function getFileProps( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::streamFile()
+ * @param $params array
+ * @return \Status
*/
public function streamFile( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getLocalReference()
+ * @param $params array
+ * @return FSFile|null
*/
public function getLocalReference( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getLocalCopy()
+ * @param $params array
+ * @return null|TempFSFile
*/
public function getLocalCopy( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::directoryExists()
+ * @param $params array
+ * @return bool|null
*/
public function directoryExists( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getSubdirectoryList()
+ * @param $params array
+ * @return Array|null|Traversable
*/
public function getDirectoryList( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );
/**
* @see FileBackend::getFileList()
+ * @param $params array
+ * @return Array|null|\Traversable
*/
public function getFileList( array $params ) {
$realParams = $this->substOpPaths( $params, $this->backends[$this->masterIndex] );