https://www.mediawiki.org/wiki/Special:Code/MediaWiki/104801
Revision: 104801 Author: aaron Date: 2011-12-01 00:12:00 +0000 (Thu, 01 Dec 2011) Log Message: ----------- * Renamed 'source' => 'src', 'dest' => 'dst', and 'directory' => 'dir' in operation params to be less verbose * Fixed undefined $parmams var in FileOp::checkAndBackupDest() Modified Paths: -------------- branches/FileBackend/phase3/includes/filerepo/FileRepo.php branches/FileBackend/phase3/includes/filerepo/ForeignAPIRepo.php branches/FileBackend/phase3/includes/filerepo/LocalRepo.php branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php branches/FileBackend/phase3/includes/filerepo/file/ForeignAPIFile.php branches/FileBackend/phase3/includes/filerepo/file/LocalFile.php branches/FileBackend/phase3/includes/media/Generic.php Modified: branches/FileBackend/phase3/includes/filerepo/FileRepo.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/FileRepo.php 2011-12-01 00:09:57 UTC (rev 104800) +++ branches/FileBackend/phase3/includes/filerepo/FileRepo.php 2011-12-01 00:12:00 UTC (rev 104801) @@ -116,7 +116,7 @@ if ( $doZones && !in_array( $zone, $doZones ) ) { continue; } - $params = array( 'directory' => $this->getZonePath( $zone ) ); + $params = array( 'dir' => $this->getZonePath( $zone ) ); $status->merge( $this->backend->prepare( $params ) ); } return $status; @@ -131,9 +131,9 @@ protected function initDeletedDir( $dir ) { // Add a .htaccess file to the root of the deleted zone $root = $this->getZonePath( 'deleted' ); - $this->backend->secure( array( 'directory' => $root, 'noAccess' => true ) ); + $this->backend->secure( array( 'dir' => $root, 'noAccess' => true ) ); // Seed new directories with a blank index.html, to prevent crawling - $this->backend->secure( array( 'directory' => $dir, 'noListing' => true ) ); + $this->backend->secure( array( 'dir' => $dir, 'noListing' => true ) ); } /** @@ -656,7 +656,7 @@ $dstDir = dirname( $dstPath ); // Create destination directories for this triplet - if ( !$backend->prepare( array( 'directory' => $dstDir ) )->isOK() ) { + if ( !$backend->prepare( array( 'dir' => $dstDir ) )->isOK() ) { return $this->newFatal( 'directorycreateerror', $dstDir ); } @@ -680,8 +680,8 @@ } $operations[] = array( 'op' => $opName, - 'source' => $srcPath, - 'dest' => $dstPath, + 'src' => $srcPath, + 'dst' => $dstPath, 'overwriteDest' => $flags & self::OVERWRITE, 'overwriteSame' => $flags & self::OVERWRITE_SAME, 'ignoreErrors' => true @@ -730,7 +730,7 @@ if ( FileBackend::isStoragePath( $path ) ) { $operations[] = array( 'op' => 'delete', - 'source' => $path, + 'src' => $path, 'ignoreErrors' => true ); } else { @@ -780,7 +780,7 @@ return false; } $path = $this->resolveVirtualUrl( $virtualUrl ); - $op = array( 'op' => 'delete', 'source' => $path ); + $op = array( 'op' => 'delete', 'src' => $path ); $status = $this->backend->doOperation( $op ); return $status->isOK(); } @@ -854,28 +854,28 @@ $dstDir = dirname( $dstPath ); $archiveDir = dirname( $archivePath ); // Abort immediately on directory creation errors since they're likely to be repetitive - if ( !$backend->prepare( array( 'directory' => $dstDir ) )->isOK() ) { + if ( !$backend->prepare( array( 'dir' => $dstDir ) )->isOK() ) { return $this->newFatal( 'directorycreateerror', $dstDir ); } - if ( !$backend->prepare( array( 'directory' => $archiveDir ) )->isOK() ) { + if ( !$backend->prepare( array( 'dir' => $archiveDir ) )->isOK() ) { return $this->newFatal( 'directorycreateerror', $archiveDir ); } // Archive destination file if it exists - if ( $backend->fileExists( array( 'source' => $dstPath ) ) ) { + if ( $backend->fileExists( array( 'src' => $dstPath ) ) ) { // Check if the archive file exists // This is a sanity check to avoid data loss. In UNIX, the rename primitive // unlinks the destination file if it exists. DB-based synchronisation in // publishBatch's caller should prevent races. In Windows there's no // problem because the rename primitive fails if the destination exists. - if ( $backend->fileExists( array( 'source' => $archivePath ) ) ) { + if ( $backend->fileExists( array( 'src' => $archivePath ) ) ) { $operations[] = array( 'op' => 'null' ); continue; } else { $operations[] = array( 'op' => 'move', - 'source' => $dstPath, - 'dest' => $archivePath, + 'src' => $dstPath, + 'dst' => $archivePath, 'ignoreErrors' => true ); } @@ -888,23 +888,23 @@ if ( $flags & self::DELETE_SOURCE ) { $operations[] = array( 'op' => 'move', - 'source' => $srcPath, - 'dest' => $dstPath, + 'src' => $srcPath, + 'dst' => $dstPath, 'ignoreErrors' => true ); } else { $operations[] = array( 'op' => 'copy', - 'source' => $srcPath, - 'dest' => $dstPath, + 'src' => $srcPath, + 'dst' => $dstPath, 'ignoreErrors' => true ); } } else { // FS source path $operations[] = array( 'op' => 'store', - 'source' => $srcPath, - 'dest' => $dstPath, + 'src' => $srcPath, + 'dst' => $dstPath, 'ignoreErrors' => true ); if ( $flags & self::DELETE_SOURCE ) { @@ -956,7 +956,7 @@ $file = $this->resolveVirtualUrl( $file ); } if ( FileBackend::isStoragePath( $file ) ) { - $result[$key] = $this->backend->fileExists( array( 'source' => $file ) ); + $result[$key] = $this->backend->fileExists( array( 'src' => $file ) ); } else { if ( $flags & self::FILES_ONLY ) { $result[$key] = is_file( $file ); // FS only @@ -1033,21 +1033,21 @@ $archiveDir = dirname( $archivePath ); // does not touch FS // Create destination directories - if ( !$backend->prepare( array( 'directory' => $archiveDir ) )->isOK() ) { + if ( !$backend->prepare( array( 'dir' => $archiveDir ) )->isOK() ) { return $this->newFatal( 'directorycreateerror', $archiveDir ); } $this->initDeletedDir( $archiveDir ); - if ( $backend->fileExists( array( 'source' => $archivePath ) ) ) { + if ( $backend->fileExists( array( 'src' => $archivePath ) ) ) { $operations[] = array( - 'op' => 'delete', - 'source' => $srcPath + 'op' => 'delete', + 'src' => $srcPath ); } else { $operations[] = array( - 'op' => 'move', - 'source' => $srcPath, - 'dest' => $archivePath + 'op' => 'move', + 'src' => $srcPath, + 'dst' => $archivePath ); } } @@ -1096,7 +1096,7 @@ */ public function getLocalCopy( $virtualUrl ) { $path = $this->resolveToStoragePath( $virtualUrl ); - return $this->backend->getLocalCopy( array( 'source' => $path ) ); + return $this->backend->getLocalCopy( array( 'src' => $path ) ); } /** @@ -1108,7 +1108,7 @@ */ public function getFileProps( $virtualUrl ) { $path = $this->resolveToStoragePath( $virtualUrl ); - return $this->backend->getFileProps( array( 'source' => $path ) ); + return $this->backend->getFileProps( array( 'src' => $path ) ); } /** @@ -1119,7 +1119,7 @@ */ public function getFileTimestamp( $virtualUrl ) { $path = $this->resolveToStoragePath( $virtualUrl ); - return $this->backend->getFileTimestamp( array( 'source' => $path ) ); + return $this->backend->getFileTimestamp( array( 'src' => $path ) ); } /** @@ -1130,7 +1130,7 @@ */ public function getFileSha1( $virtualUrl ) { $path = $this->resolveToStoragePath( $virtualUrl ); - $tmpFile = $this->backend->getLocalCopy( array( 'source' => $path ) ); + $tmpFile = $this->backend->getLocalCopy( array( 'src' => $path ) ); if ( !$tmpFile ) { return false; } @@ -1166,7 +1166,7 @@ for ( $hexPos = 0; $hexPos < $this->hashLevels; $hexPos++ ) { $path .= '/' . substr( $hexString, 0, $hexPos + 1 ); } - $iterator = $this->backend->getFileList( array( 'directory' => $path ) ); + $iterator = $this->backend->getFileList( array( 'dir' => $path ) ); foreach ( $iterator as $name ) { // Each item returned is a public file call_user_func( $callback, "{$path}/{$name}" ); Modified: branches/FileBackend/phase3/includes/filerepo/ForeignAPIRepo.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/ForeignAPIRepo.php 2011-12-01 00:09:57 UTC (rev 104800) +++ branches/FileBackend/phase3/includes/filerepo/ForeignAPIRepo.php 2011-12-01 00:12:00 UTC (rev 104801) @@ -296,7 +296,7 @@ # @todo FIXME: Delete old thumbs that aren't being used. Maintenance script? wfSuppressWarnings(); $backend = $this->getBackend(); - $op = array( 'op' => 'create', 'dest' => $localFilename, 'content' => $thumb ); + $op = array( 'op' => 'create', 'dst' => $localFilename, 'content' => $thumb ); if( !$backend->doOperation( $op )->isOK() ) { wfRestoreWarnings(); wfDebug( __METHOD__ . " could not write to thumb path\n" ); Modified: branches/FileBackend/phase3/includes/filerepo/LocalRepo.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/LocalRepo.php 2011-12-01 00:09:57 UTC (rev 104800) +++ branches/FileBackend/phase3/includes/filerepo/LocalRepo.php 2011-12-01 00:12:00 UTC (rev 104801) @@ -71,7 +71,7 @@ $hidden = $this->hiddenFileHasKey( $key, 'lock' ); if ( !$deleted && !$hidden ) { // not in use now wfDebug( __METHOD__ . ": deleting $key\n" ); - $op = array( 'op' => 'delete', 'source' => $path ); + $op = array( 'op' => 'delete', 'src' => $path ); if ( !$backend->doOperation( $op )->isOK() ) { $status->error( 'undelete-cleanup-error', $path ); $status->failCount++; Modified: branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php 2011-12-01 00:09:57 UTC (rev 104800) +++ branches/FileBackend/phase3/includes/filerepo/backend/FSFileBackend.php 2011-12-01 00:12:00 UTC (rev 104801) @@ -37,9 +37,9 @@ function store( array $params ) { $status = Status::newGood(); - list( $c, $dest ) = $this->resolveStoragePath( $params['dest'] ); + list( $c, $dest ) = $this->resolveStoragePath( $params['dst'] ); if ( $dest === null ) { - $status->fatal( 'backend-fail-invalidpath', $params['dest'] ); + $status->fatal( 'backend-fail-invalidpath', $params['dst'] ); return $status; } if ( is_file( $dest ) ) { @@ -48,25 +48,25 @@ $ok = unlink( $dest ); wfRestoreWarnings(); if ( !$ok ) { - $status->fatal( 'backend-fail-delete', $params['dest'] ); + $status->fatal( 'backend-fail-delete', $params['dst'] ); return $status; } } else { - $status->fatal( 'backend-fail-alreadyexists', $params['dest'] ); + $status->fatal( 'backend-fail-alreadyexists', $params['dst'] ); return $status; } } else { if ( !wfMkdirParents( dirname( $dest ) ) ) { - $status->fatal( 'directorycreateerror', $param['dest'] ); + $status->fatal( 'directorycreateerror', $param['dst'] ); return $status; } } wfSuppressWarnings(); - $ok = copy( $params['source'], $dest ); + $ok = copy( $params['src'], $dest ); wfRestoreWarnings(); if ( !$ok ) { - $status->fatal( 'backend-fail-copy', $params['source'], $params['dest'] ); + $status->fatal( 'backend-fail-copy', $params['src'], $params['dst'] ); return $status; } @@ -78,12 +78,12 @@ function copy( array $params ) { $status = Status::newGood(); - list( $c, $source ) = $this->resolveStoragePath( $params['source'] ); + list( $c, $source ) = $this->resolveStoragePath( $params['src'] ); if ( $source === null ) { - $status->fatal( 'backend-fail-invalidpath', $params['source'] ); + $status->fatal( 'backend-fail-invalidpath', $params['src'] ); return $status; } - $params['source'] = $source; // resolve source to FS path + $params['src'] = $source; // resolve source to FS path return $this->store( $params ); // both source and dest are on FS } @@ -95,14 +95,14 @@ function move( array $params ) { $status = Status::newGood(); - list( $c, $source ) = $this->resolveStoragePath( $params['source'] ); + list( $c, $source ) = $this->resolveStoragePath( $params['src'] ); if ( $source === null ) { - $status->fatal( 'backend-fail-invalidpath', $params['source'] ); + $status->fatal( 'backend-fail-invalidpath', $params['src'] ); return $status; } - list( $c, $dest ) = $this->resolveStoragePath( $params['dest'] ); + list( $c, $dest ) = $this->resolveStoragePath( $params['dst'] ); if ( $dest === null ) { - $status->fatal( 'backend-fail-invalidpath', $params['dest'] ); + $status->fatal( 'backend-fail-invalidpath', $params['dst'] ); return $status; } @@ -114,17 +114,17 @@ $ok = unlink( $dest ); wfRestoreWarnings(); if ( !$ok ) { - $status->fatal( 'backend-fail-delete', $params['dest'] ); + $status->fatal( 'backend-fail-delete', $params['dst'] ); return $status; } } } else { - $status->fatal( 'backend-fail-alreadyexists', $params['dest'] ); + $status->fatal( 'backend-fail-alreadyexists', $params['dst'] ); return $status; } } else { if ( !wfMkdirParents( dirname( $dest ) ) ) { - $status->fatal( 'directorycreateerror', $param['dest'] ); + $status->fatal( 'directorycreateerror', $param['dst'] ); return $status; } } @@ -134,7 +134,7 @@ clearstatcache(); // file no longer at source wfRestoreWarnings(); if ( !$ok ) { - $status->fatal( 'backend-fail-move', $params['source'], $params['dest'] ); + $status->fatal( 'backend-fail-move', $params['src'], $params['dst'] ); return $status; } @@ -144,15 +144,15 @@ function delete( array $params ) { $status = Status::newGood(); - list( $c, $source ) = $this->resolveStoragePath( $params['source'] ); + list( $c, $source ) = $this->resolveStoragePath( $params['src'] ); if ( $source === null ) { - $status->fatal( 'backend-fail-invalidpath', $params['source'] ); + $status->fatal( 'backend-fail-invalidpath', $params['src'] ); return $status; } if ( !is_file( $source ) ) { if ( empty( $params['ignoreMissingSource'] ) ) { - $status->fatal( 'backend-fail-delete', $params['source'] ); + $status->fatal( 'backend-fail-delete', $params['src'] ); } return $status; // do nothing; either OK or bad status } @@ -161,7 +161,7 @@ $ok = unlink( $source ); wfRestoreWarnings(); if ( !$ok ) { - $status->fatal( 'backend-fail-delete', $params['source'] ); + $status->fatal( 'backend-fail-delete', $params['src'] ); return $status; } @@ -171,16 +171,16 @@ function concatenate( array $params ) { $status = Status::newGood(); - list( $c, $dest ) = $this->resolveStoragePath( $params['dest'] ); + list( $c, $dest ) = $this->resolveStoragePath( $params['dst'] ); if ( $dest === null ) { - $status->fatal( 'backend-fail-invalidpath', $params['dest'] ); + $status->fatal( 'backend-fail-invalidpath', $params['dst'] ); return $status; } // Check if the destination file exists and we can't handle that $destExists = file_exists( $dest ); if ( $destExists && empty( $params['overwriteDest'] ) ) { - $status->fatal( 'backend-fail-alreadyexists', $params['dest'] ); + $status->fatal( 'backend-fail-alreadyexists', $params['dst'] ); return $status; } @@ -235,14 +235,14 @@ $ok = unlink( $dest ); wfRestoreWarnings(); if ( !$ok ) { - $status->fatal( 'backend-fail-delete', $params['dest'] ); + $status->fatal( 'backend-fail-delete', $params['dst'] ); return $status; } } } else { // Make sure destination directory exists if ( !wfMkdirParents( dirname( $dest ) ) ) { - $status->fatal( 'directorycreateerror', $param['dest'] ); + $status->fatal( 'directorycreateerror', $param['dst'] ); return $status; } } @@ -252,7 +252,7 @@ $ok = rename( $tmpPath, $dest ); wfRestoreWarnings(); if ( !$ok ) { - $status->fatal( 'backend-fail-move', $tmpPath, $params['dest'] ); + $status->fatal( 'backend-fail-move', $tmpPath, $params['dst'] ); return $status; } @@ -264,9 +264,9 @@ function create( array $params ) { $status = Status::newGood(); - list( $c, $dest ) = $this->resolveStoragePath( $params['dest'] ); + list( $c, $dest ) = $this->resolveStoragePath( $params['dst'] ); if ( $dest === null ) { - $status->fatal( 'backend-fail-invalidpath', $params['dest'] ); + $status->fatal( 'backend-fail-invalidpath', $params['dst'] ); return $status; } @@ -276,16 +276,16 @@ $ok = unlink( $dest ); wfRestoreWarnings(); if ( !$ok ) { - $status->fatal( 'backend-fail-delete', $param['dest'] ); + $status->fatal( 'backend-fail-delete', $param['dst'] ); return $status; } } else { - $status->fatal( 'backend-fail-alreadyexists', $params['dest'] ); + $status->fatal( 'backend-fail-alreadyexists', $params['dst'] ); return $status; } } else { if ( !wfMkdirParents( dirname( $dest ) ) ) { - $status->fatal( 'directorycreateerror', $param['dest'] ); + $status->fatal( 'directorycreateerror', $param['dst'] ); return $status; } } @@ -294,7 +294,7 @@ $ok = file_put_contents( $dest, $params['content'] ); wfRestoreWarnings(); if ( !$ok ) { - $status->fatal( 'backend-fail-create', $params['dest'] ); + $status->fatal( 'backend-fail-create', $params['dst'] ); return $status; } @@ -305,19 +305,19 @@ function prepare( array $params ) { $status = Status::newGood(); - list( $c, $dir ) = $this->resolveStoragePath( $params['directory'] ); + list( $c, $dir ) = $this->resolveStoragePath( $params['dir'] ); if ( $dir === null ) { - $status->fatal( 'backend-fail-invalidpath', $params['directory'] ); + $status->fatal( 'backend-fail-invalidpath', $params['dir'] ); return $status; // invalid storage path } if ( !wfMkdirParents( $dir ) ) { - $status->fatal( 'directorycreateerror', $param['directory'] ); + $status->fatal( 'directorycreateerror', $param['dir'] ); return $status; } elseif ( !is_writable( $dir ) ) { - $status->fatal( 'directoryreadonlyerror', $param['directory'] ); + $status->fatal( 'directoryreadonlyerror', $param['dir'] ); return $status; } elseif ( !is_readable( $dir ) ) { - $status->fatal( 'directorynotreadableerror', $param['directory'] ); + $status->fatal( 'directorynotreadableerror', $param['dir'] ); return $status; } return $status; @@ -325,13 +325,13 @@ function secure( array $params ) { $status = Status::newGood(); - list( $c, $dir ) = $this->resolveStoragePath( $params['directory'] ); + list( $c, $dir ) = $this->resolveStoragePath( $params['dir'] ); if ( $dir === null ) { - $status->fatal( 'backend-fail-invalidpath', $params['directory'] ); + $status->fatal( 'backend-fail-invalidpath', $params['dir'] ); return $status; // invalid storage path } if ( !wfMkdirParents( $dir ) ) { - $status->fatal( 'directorycreateerror', $param['directory'] ); + $status->fatal( 'directorycreateerror', $param['dir'] ); return $status; } // Add a .htaccess file to the root of the deleted zone @@ -340,7 +340,7 @@ $ok = file_put_contents( "{$dir}/.htaccess", "Deny from all\n" ); wfRestoreWarnings(); if ( !$ok ) { - $status->fatal( 'backend-fail-create', $params['directory'] . '/.htaccess' ); + $status->fatal( 'backend-fail-create', $params['dir'] . '/.htaccess' ); return $status; } } @@ -350,7 +350,7 @@ $ok = file_put_contents( "{$dir}/index.html", '' ); wfRestoreWarnings(); if ( !$ok ) { - $status->fatal( 'backend-fail-create', $params['dest'] . '/index.html' ); + $status->fatal( 'backend-fail-create', $params['dst'] . '/index.html' ); return $status; } } @@ -359,9 +359,9 @@ function clean( array $params ) { $status = Status::newGood(); - list( $c, $dir ) = $this->resolveStoragePath( $params['directory'] ); + list( $c, $dir ) = $this->resolveStoragePath( $params['dir'] ); if ( $dir === null ) { - $status->fatal( 'backend-fail-invalidpath', $params['directory'] ); + $status->fatal( 'backend-fail-invalidpath', $params['dir'] ); return $status; // invalid storage path } wfSuppressWarnings(); @@ -373,7 +373,7 @@ } function fileExists( array $params ) { - list( $c, $source ) = $this->resolveStoragePath( $params['source'] ); + list( $c, $source ) = $this->resolveStoragePath( $params['src'] ); if ( $source === null ) { return false; // invalid storage path } @@ -385,7 +385,7 @@ } function getFileHash( array $params ) { - list( $c, $source ) = $this->resolveStoragePath( $params['source'] ); + list( $c, $source ) = $this->resolveStoragePath( $params['src'] ); if ( $source === null ) { return false; // invalid storage path } @@ -393,7 +393,7 @@ } function getFileTimestamp( array $params ) { - list( $c, $source ) = $this->resolveStoragePath( $params['source'] ); + list( $c, $source ) = $this->resolveStoragePath( $params['src'] ); if ( $source === null ) { return false; // invalid storage path } @@ -402,7 +402,7 @@ } function getFileProps( array $params ) { - list( $c, $source ) = $this->resolveStoragePath( $params['source'] ); + list( $c, $source ) = $this->resolveStoragePath( $params['src'] ); if ( $source === null ) { return FSFile::placeholderProps(); // invalid storage path } @@ -411,7 +411,7 @@ } function getFileList( array $params ) { - list( $c, $dir ) = $this->resolveStoragePath( $params['directory'] ); + list( $c, $dir ) = $this->resolveStoragePath( $params['dir'] ); if ( $dir === null ) { // invalid storage path return array(); // empty result } @@ -421,15 +421,15 @@ function streamFile( array $params ) { $status = Status::newGood(); - list( $c, $source ) = $this->resolveStoragePath( $params['source'] ); + list( $c, $source ) = $this->resolveStoragePath( $params['src'] ); if ( $source === null ) { - $status->fatal( 'backend-fail-invalidpath', $params['source'] ); + $status->fatal( 'backend-fail-invalidpath', $params['src'] ); return $status; } $ok = StreamFile::stream( $source, array(), false ); if ( !$ok ) { - $status->fatal( 'backend-fail-stream', $params['source'] ); + $status->fatal( 'backend-fail-stream', $params['src'] ); return $status; } @@ -437,7 +437,7 @@ } function getLocalCopy( array $params ) { - list( $c, $source ) = $this->resolveStoragePath( $params['source'] ); + list( $c, $source ) = $this->resolveStoragePath( $params['src'] ); if ( $source === null ) { return null; } Modified: branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php 2011-12-01 00:09:57 UTC (rev 104800) +++ branches/FileBackend/phase3/includes/filerepo/backend/FileBackend.php 2011-12-01 00:12:00 UTC (rev 104801) @@ -68,9 +68,9 @@ * <code> * $ops = array( * array( - * 'op' => 'store', - * 'source' => '/tmp/uploads/picture.png', - * 'dest' => 'mwstore://container/uploadedFilename.png' + * 'op' => 'store', + * 'src' => '/tmp/uploads/picture.png', + * 'dst' => 'mwstore://container/uploadedFilename.png' * ) * ); * </code> @@ -97,7 +97,7 @@ * that don't yet exists or, on FS backends, create parent directories. * Do not call this function from places outside FileBackend and FileOp. * $params include: - * directory : storage directory + * dir : storage directory * * @param Array $params * @return Status @@ -109,7 +109,7 @@ * This is not guaranteed to actually do anything. * Do not call this function from places outside FileBackend and FileOp. * $params include: - * directory : storage directory + * dir : storage directory * noAccess : try to deny file access * noListing : try to deny file listing * @@ -123,7 +123,7 @@ * On FS backends, the directory will be deleted. Others may do nothing. * Do not call this function from places outside FileBackend and FileOp. * $params include: - * directory : storage directory + * dir : storage directory * * @param Array $params * @return Status @@ -134,7 +134,7 @@ * Check if a file exits at a storage path in the backend. * Do not call this function from places outside FileBackend and FileOp. * $params include: - * source : source storage path + * src : source storage path * * @param Array $params * @return bool @@ -145,7 +145,7 @@ * Get a hash of the file at a storage path in the backend. * Typically this will be a SHA-1 hash, MD5 hash, or something similar. * $params include: - * source : source storage path + * src : source storage path * * @param Array $params * @return string|false Hash string or false on failure @@ -162,7 +162,7 @@ /** * Get the last-modified timestamp of the file at a storage path. * $params include: - * source : source storage path + * src : source storage path * * @param Array $params * @return string|false TS_MW timestamp or false on failure @@ -173,7 +173,7 @@ * Get the properties of the file at a storage path in the backend. * Returns FSFile::placeholderProps() on failure. * $params include: - * source : source storage path + * src : source storage path * * @param Array $params * @return Array @@ -186,7 +186,7 @@ * must be sent if streaming began, while none should be sent otherwise. * Implementations should flush the output buffer before sending data. * $params include: - * source : source storage path + * src : source storage path * * @param Array $params * @return Status @@ -200,7 +200,7 @@ * then all items under that container directory should be listed. * Results should be storage paths relative to the given directory. * $params include: - * directory : storage path directory. + * dir : storage path directory. * * @return Iterator|Array */ @@ -210,7 +210,7 @@ * Get a local copy on disk of the file at a storage path in the backend. * The temporary copy should have the same file extension as the source. * $params include: - * source : source storage path + * src : source storage path * * @param Array $params * @return TempFSFile|null Temporary file or null on failure @@ -253,8 +253,8 @@ * Store a file into the backend from a file on disk. * Do not call this function from places outside FileBackend and FileOp. * $params include: - * source : source path on disk - * dest : destination storage path + * src : source path on disk + * dst : destination storage path * overwriteDest : do nothing and pass if an identical file exists at destination * * @param Array $params @@ -266,8 +266,8 @@ * Copy a file from one storage path to another in the backend. * Do not call this function from places outside FileBackend and FileOp. * $params include: - * source : source storage path - * dest : destination storage path + * src : source storage path + * dst : destination storage path * overwriteDest : do nothing and pass if an identical file exists at destination * * @param Array $params @@ -280,8 +280,8 @@ * This can be left as a dummy function as long as hasMove() returns false. * Do not call this function from places outside FileBackend and FileOp. * $params include: - * source : source storage path - * dest : destination storage path + * src : source storage path + * dst : destination storage path * overwriteDest : do nothing and pass if an identical file exists at destination * * @param Array $params @@ -295,7 +295,7 @@ * Delete a file at the storage path. * Do not call this function from places outside FileBackend and FileOp. * $params include: - * source : source storage path + * src : source storage path * * @param Array $params * @return Status @@ -306,8 +306,8 @@ * Combines files from severals storage paths into a new file in the backend. * Do not call this function from places outside FileBackend and FileOp. * $params include: - * source : source storage path - * dest : destination storage path + * src : source storage path + * dst : destination storage path * overwriteDest : do nothing and pass if an identical file exists at destination * * @param Array $params @@ -320,7 +320,7 @@ * Do not call this function from places outside FileBackend and FileOp. * $params include: * contents : the raw file contents - * dest : destination storage path + * dst : destination storage path * overwriteDest : do nothing and pass if an identical file exists at destination * * @param Array $params @@ -346,8 +346,8 @@ * For example, moving objects accross containers may not be supported. * Do not call this function from places outside FileBackend and FileOp. * $params include: - * source : source storage path - * dest : destination storage path + * src : source storage path + * dst : destination storage path * * @param Array $params * @return bool Modified: branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php 2011-12-01 00:09:57 UTC (rev 104800) +++ branches/FileBackend/phase3/includes/filerepo/backend/FileBackendMultiWrite.php 2011-12-01 00:12:00 UTC (rev 104801) @@ -233,7 +233,7 @@ return $status; // died mid-stream...so this is already fubar } } - return Status::newFatal( 'backend-fail-stream', $params['source'] ); + return Status::newFatal( 'backend-fail-stream', $params['src'] ); } function getLocalCopy( array $params ) { Modified: branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php 2011-12-01 00:09:57 UTC (rev 104800) +++ branches/FileBackend/phase3/includes/filerepo/backend/FileOp.php 2011-12-01 00:12:00 UTC (rev 104801) @@ -175,12 +175,12 @@ protected function backupSource() { $status = Status::newGood(); // Check if a file already exists at the source... - $params = array( 'source' => $this->params['source'] ); + $params = array( 'src' => $this->params['src'] ); if ( $this->backend->fileExists( $params ) ) { // Create a temporary backup copy... $this->tmpSourcePath = $this->backend->getLocalCopy( $params ); if ( $this->tmpSourcePath === null ) { - $status->fatal( 'backend-fail-backup', $this->params['source'] ); + $status->fatal( 'backend-fail-backup', $this->params['src'] ); return $status; } } @@ -201,9 +201,10 @@ if ( !empty( $this->params['overwriteDest'] ) ) { // Create a temporary backup copy... + $params = array( 'src' => $this->params['dst'] ); $this->tmpDestFile = $this->backend->getLocalCopy( $params ); if ( !$this->tmpDestFile ) { - $status->fatal( 'backend-fail-backup', $this->params['dest'] ); + $status->fatal( 'backend-fail-backup', $this->params['dst'] ); return $status; } } elseif ( !empty( $this->params['overwriteSame'] ) ) { @@ -212,19 +213,19 @@ // If there is a single source, then we can do some checks already. // For things like concatenate(), we need to build a temp file first. if ( $shash !== null ) { - $dhash = $this->getFileMD5( $this->params['dest'] ); + $dhash = $this->getFileMD5( $this->params['dst'] ); if ( !strlen( $shash ) || !strlen( $dhash ) ) { $status->fatal( 'backend-fail-hashes' ); return $status; } // Give an error if the files are not identical if ( $shash !== $dhash ) { - $status->fatal( 'backend-fail-notsame', $this->params['dest'] ); + $status->fatal( 'backend-fail-notsame', $this->params['dst'] ); } return $status; // do nothing; either OK or bad status } } else { - $status->fatal( 'backend-fail-alreadyexists', $this->params['dest'] ); + $status->fatal( 'backend-fail-alreadyexists', $this->params['dst'] ); return $status; } @@ -254,7 +255,7 @@ if ( $this->backend->getHashType() === 'md5' ) { $hash = $this->backend->getFileHash( $path ); } else { - $tmp = $this->backend->getLocalCopy( array( 'source' => $path ) ); + $tmp = $this->backend->getLocalCopy( array( 'src' => $path ) ); if ( !$tmp ) { return false; // error } @@ -277,8 +278,8 @@ // Restore any file that was at the destination if ( $this->tmpSourcePath !== null ) { $params = array( - 'source' => $this->tmpSourcePath, - 'dest' => $this->params['source'] + 'src' => $this->tmpSourcePath, + 'dst' => $this->params['src'] ); $status = $this->backend->store( $params ); if ( !$status->isOK() ) { @@ -298,8 +299,8 @@ // Restore any file that was at the destination if ( $this->tmpDestFile ) { $params = array( - 'source' => $this->tmpDestFile->getPath(), - 'dest' => $this->params['dest'] + 'src' => $this->tmpDestFile->getPath(), + 'dst' => $this->params['dst'] ); $status = $this->backend->store( $params ); if ( !$status->isOK() ) { @@ -320,7 +321,7 @@ if ( isset( $predicates['exists'][$source] ) ) { return $predicates['exists'][$source]; // previous op assures this } else { - return $this->backend->fileExists( array( 'source' => $source ) ); + return $this->backend->fileExists( array( 'src' => $source ) ); } } } @@ -328,8 +329,8 @@ /** * Store a file into the backend from a file on the file system. * Parameters similar to FileBackend::store(), which include: - * source : source path on file system - * dest : destination storage path + * src : source path on file system + * dst : destination storage path * overwriteDest : do nothing and pass if an identical file exists at destination * overwriteSame : override any existing file at destination */ @@ -337,21 +338,21 @@ protected function doPrecheck( array &$predicates ) { $status = Status::newGood(); // Check if destination file exists - if ( $this->fileExists( $this->params['dest'], $predicates ) ) { + if ( $this->fileExists( $this->params['dst'], $predicates ) ) { if ( empty( $this->params['overwriteDest'] ) ) { - $status->fatal( 'backend-fail-alreadyexists', $this->params['dest'] ); + $status->fatal( 'backend-fail-alreadyexists', $this->params['dst'] ); return $status; } } else { $this->checkDest = false; } // Check if the source file exists on the file system - if ( !file_exists( $this->params['source'] ) ) { - $status->fatal( 'backend-fail-notexists', $this->params['source'] ); + if ( !file_exists( $this->params['src'] ) ) { + $status->fatal( 'backend-fail-notexists', $this->params['src'] ); return $status; } // Update file existence predicates - $predicates['exists'][$this->params['dest']] = true; + $predicates['exists'][$this->params['dst']] = true; return $status; } @@ -371,7 +372,7 @@ protected function doRevert() { // Remove the file saved to the destination - $params = array( 'source' => $this->params['dest'] ); + $params = array( 'src' => $this->params['dst'] ); $status = $this->backend->delete( $params ); if ( !$status->isOK() ) { return $status; // also can't restore any dest file @@ -382,11 +383,11 @@ } protected function getSourceMD5() { - return md5_file( $this->params['source'] ); + return md5_file( $this->params['src'] ); } function storagePathsUsed() { - return array( $this->params['dest'] ); + return array( $this->params['dst'] ); } } @@ -394,7 +395,7 @@ * Create a file in the backend with the given content. * Parameters similar to FileBackend::create(), which include: * content : a string of raw file contents - * dest : destination storage path + * dst : destination storage path * overwriteDest : do nothing and pass if an identical file exists at destination * overwriteSame : override any existing file at destination */ @@ -402,16 +403,16 @@ protected function doPrecheck( array &$predicates ) { $status = Status::newGood(); // Check if destination file exists - if ( $this->fileExists( $this->params['dest'], $predicates ) ) { + if ( $this->fileExists( $this->params['dst'], $predicates ) ) { if ( empty( $this->params['overwriteDest'] ) ) { - $status->fatal( 'backend-fail-alreadyexists', $this->params['dest'] ); + $status->fatal( 'backend-fail-alreadyexists', $this->params['dst'] ); return $status; } } else { $this->checkDest = false; } // Update file existence predicates - $predicates['exists'][$this->params['dest']] = true; + $predicates['exists'][$this->params['dst']] = true; return $status; } @@ -431,7 +432,7 @@ protected function doRevert() { // Remove the file saved to the destination - $params = array( 'source' => $this->params['dest'] ); + $params = array( 'src' => $this->params['dst'] ); $status = $this->backend->delete( $params ); if ( !$status->isOK() ) { return $status; // also can't restore any dest file @@ -446,15 +447,15 @@ } function storagePathsUsed() { - return array( $this->params['dest'] ); + return array( $this->params['dst'] ); } } /** * Copy a file from one storage path to another in the backend. * Parameters similar to FileBackend::copy(), which include: - * source : source storage path - * dest : destination storage path + * src : source storage path + * dst : destination storage path * overwriteDest : do nothing and pass if an identical file exists at destination * overwriteSame : override any existing file at destination */ @@ -464,21 +465,21 @@ protected function doPrecheck( array &$predicates ) { $status = Status::newGood(); // Check if destination file exists - if ( $this->fileExists( $this->params['dest'], $predicates ) ) { + if ( $this->fileExists( $this->params['dst'], $predicates ) ) { if ( empty( $this->params['overwriteDest'] ) ) { - $status->fatal( 'backend-fail-alreadyexists', $this->params['dest'] ); + $status->fatal( 'backend-fail-alreadyexists', $this->params['dst'] ); return $status; } } else { $this->checkDest = false; } // Check if the source file exists - if ( !$this->fileExists( $this->params['source'], $predicates ) ) { - $status->fatal( 'backend-fail-notexists', $this->params['source'] ); + if ( !$this->fileExists( $this->params['src'], $predicates ) ) { + $status->fatal( 'backend-fail-notexists', $this->params['src'] ); return $status; } // Update file existence predicates - $predicates['exists'][$this->params['dest']] = true; + $predicates['exists'][$this->params['dst']] = true; return $status; } @@ -499,7 +500,7 @@ protected function doRevert() { $status = Status::newGood(); // Remove the file saved to the destination - $params = array( 'source' => $this->params['dest'] ); + $params = array( 'src' => $this->params['dst'] ); $status->merge( $this->backend->delete( $params ) ); if ( !$status->isOK() ) { return $status; // also can't restore any dest file @@ -510,19 +511,19 @@ } protected function getSourceMD5() { - return $this->getFileMD5( $this->params['source'] ); + return $this->getFileMD5( $this->params['src'] ); } function storagePathsUsed() { - return array( $this->params['source'], $this->params['dest'] ); + return array( $this->params['src'], $this->params['dst'] ); } } /** * Move a file from one storage path to another in the backend. * Parameters similar to FileBackend::move(), which include: - * source : source storage path - * dest : destination storage path + * src : source storage path + * dst : destination storage path * overwriteDest : do nothing and pass if an identical file exists at destination * overwriteSame : override any existing file at destination */ @@ -538,22 +539,22 @@ protected function doPrecheck( array &$predicates ) { $status = Status::newGood(); // Check if destination file exists - if ( $this->fileExists( $this->params['dest'], $predicates ) ) { + if ( $this->fileExists( $this->params['dst'], $predicates ) ) { if ( empty( $this->params['overwriteDest'] ) ) { - $status->fatal( 'backend-fail-alreadyexists', $this->params['dest'] ); + $status->fatal( 'backend-fail-alreadyexists', $this->params['dst'] ); return $status; } } else { $this->checkDest = false; } // Check if the source file exists - if ( !$this->fileExists( $this->params['source'], $predicates ) ) { - $status->fatal( 'backend-fail-notexists', $this->params['source'] ); + if ( !$this->fileExists( $this->params['src'], $predicates ) ) { + $status->fatal( 'backend-fail-notexists', $this->params['src'] ); return $status; } // Update file existence predicates - $predicates['exists'][$this->params['source']] = false; - $predicates['exists'][$this->params['dest']] = true; + $predicates['exists'][$this->params['src']] = false; + $predicates['exists'][$this->params['dst']] = true; return $status; } @@ -577,7 +578,7 @@ return $status; } // Delete source - $params = array( 'source' => $this->params['source'] ); + $params = array( 'src' => $this->params['src'] ); $status->merge( $this->backend->delete( $params ) ); if ( !$status->isOK() ) { return $status; @@ -591,8 +592,8 @@ // Native moves: move the file back to the source if ( $this->usingMove ) { $params = array( - 'source' => $this->params['dest'], - 'dest' => $this->params['source'] + 'src' => $this->params['dst'], + 'dst' => $this->params['src'] ); $status->merge( $this->backend->move( $params ) ); if ( !$status->isOK() ) { @@ -601,13 +602,13 @@ // Non-native moves: remove the file saved to the destination } else { // Copy destination back to source - $params = array( 'source' => $this->params['dest'], 'dest' => $this->params['source'] ); + $params = array( 'src' => $this->params['dst'], 'dst' => $this->params['src'] ); $status = $this->backend->copy( $params ); if ( !$status->isOK() ) { return $status; // also can't restore any dest file } // Delete destination - $params = array( 'source' => $this->params['dest'] ); + $params = array( 'src' => $this->params['dst'] ); $status = $this->backend->delete( $params ); if ( !$status->isOK() ) { return $status; // also can't restore any dest file @@ -619,11 +620,11 @@ } protected function getSourceMD5() { - return $this->getFileMD5( $this->params['source'] ); + return $this->getFileMD5( $this->params['src'] ); } function storagePathsUsed() { - return array( $this->params['source'], $this->params['dest'] ); + return array( $this->params['src'], $this->params['dst'] ); } } @@ -631,7 +632,7 @@ * Combines files from severals storage paths into a new file in the backend. * Parameters similar to FileBackend::concatenate(), which include: * sources : ordered source storage paths (e.g. chunk1,chunk2,...) - * dest : destination storage path + * dst : destination storage path * overwriteDest : do nothing and pass if an identical file exists at destination */ class ConcatenateFileOp extends FileOp { @@ -640,9 +641,9 @@ protected function doPrecheck( array &$predicates ) { $status = Status::newGood(); // Check if destination file exists - if ( $this->fileExists( $this->params['dest'], $predicates ) ) { + if ( $this->fileExists( $this->params['dst'], $predicates ) ) { if ( empty( $this->params['overwriteDest'] ) ) { - $status->fatal( 'backend-fail-alreadyexists', $this->params['dest'] ); + $status->fatal( 'backend-fail-alreadyexists', $this->params['dst'] ); return $status; } } else { @@ -656,7 +657,7 @@ } } // Update file existence predicates - $predicates['exists'][$this->params['dest']] = true; + $predicates['exists'][$this->params['dst']] = true; return $status; } @@ -676,7 +677,7 @@ protected function doRevert() { // Remove the file saved to the destination - $params = array( 'source' => $this->params['dest'] ); + $params = array( 'src' => $this->params['dst'] ); $status = $this->backend->delete( $params ); if ( !$status->isOK() ) { return $status; // also can't restore any dest file @@ -691,14 +692,14 @@ } function storagePathsUsed() { - return array_merge( $this->params['sources'], $this->params['dest'] ); + return array_merge( $this->params['sources'], $this->params['dst'] ); } } /** * Delete a file at the storage path. * Parameters similar to FileBackend::delete(), which include: - * source : source storage path + * src : source storage path * ignoreMissingSource : don't return an error if the file does not exist */ class DeleteFileOp extends FileOp { @@ -707,15 +708,15 @@ protected function doPrecheck( array &$predicates ) { $status = Status::newGood(); // Check if the source file exists - if ( !$this->fileExists( $this->params['source'], $predicates ) ) { + if ( !$this->fileExists( $this->params['src'], $predicates ) ) { if ( empty( $this->params['ignoreMissingSource'] ) ) { - $status->fatal( 'backend-fail-notexists', $this->params['source'] ); + $status->fatal( 'backend-fail-notexists', $this->params['src'] ); return $status; } $this->needsDelete = false; } // Update file existence predicates - $predicates['exists'][$this->params['source']] = false; + $predicates['exists'][$this->params['src']] = false; return $status; } @@ -742,7 +743,7 @@ } function storagePathsUsed() { - return array( $this->params['source'] ); + return array( $this->params['src'] ); } } Modified: branches/FileBackend/phase3/includes/filerepo/file/ForeignAPIFile.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/file/ForeignAPIFile.php 2011-12-01 00:09:57 UTC (rev 104800) +++ branches/FileBackend/phase3/includes/filerepo/file/ForeignAPIFile.php 2011-12-01 00:12:00 UTC (rev 104801) @@ -198,7 +198,7 @@ function getThumbnails() { $dir = $this->getThumbPath( $this->getName() ); - $iter = $this->repo->getBackend()->getFileList( array( 'directory' => $dir ) ); + $iter = $this->repo->getBackend()->getFileList( array( 'dir' => $dir ) ); $files = array(); foreach ( $iter as $file ) { @@ -241,9 +241,9 @@ $dir = $this->getThumbPath( $this->getName() ); foreach ( $files as $file ) { - $op = array( 'op' => 'delete', 'source' => "{$dir}{$file}" ); + $op = array( 'op' => 'delete', 'src' => "{$dir}{$file}" ); $backend->doOperation( $op ); } - $backend->clean( array( 'directory' => $dir ) ); + $backend->clean( array( 'dir' => $dir ) ); } } Modified: branches/FileBackend/phase3/includes/filerepo/file/LocalFile.php =================================================================== --- branches/FileBackend/phase3/includes/filerepo/file/LocalFile.php 2011-12-01 00:09:57 UTC (rev 104800) +++ branches/FileBackend/phase3/includes/filerepo/file/LocalFile.php 2011-12-01 00:12:00 UTC (rev 104801) @@ -604,7 +604,7 @@ if ( $this->repo->fileExists( $thumbDir, FileRepo::FILES_ONLY ) ) { // File where directory should be - $op = array( 'op' => 'delete', 'source' => $thumbDir ); + $op = array( 'op' => 'delete', 'src' => $thumbDir ); $this->repo->getBackend()->doOperation( $op ); } } @@ -629,7 +629,7 @@ $backend = $this->repo->getBackend(); $files = array( $dir ); - $iterator = $backend->getFileList( array( 'directory' => $dir ) ); + $iterator = $backend->getFileList( array( 'dir' => $dir ) ); foreach ( $iterator as $file ) { $files[] = $file; } @@ -757,12 +757,12 @@ # Check that the base file name is part of the thumb name # This is a basic sanity check to avoid erasing unrelated directories if ( strpos( $file, $this->getName() ) !== false ) { - $op = array( 'op' => 'delete', 'source' => "{$dir}/{$file}" ); + $op = array( 'op' => 'delete', 'src' => "{$dir}/{$file}" ); $backend->doOperation( $op ); } } # Clear out directory if empty - $backend->clean( array( 'directory' => $dir ) ); + $backend->clean( array( 'dir' => $dir ) ); } /** purgeDescription inherited */ Modified: branches/FileBackend/phase3/includes/media/Generic.php =================================================================== --- branches/FileBackend/phase3/includes/media/Generic.php 2011-12-01 00:09:57 UTC (rev 104800) +++ branches/FileBackend/phase3/includes/media/Generic.php 2011-12-01 00:12:00 UTC (rev 104801) @@ -218,7 +218,7 @@ // Note: no file is created if it's to be rendered client-side. if ( !$out->isError() && filesize( $tmpDest ) ) { $op = array( 'op' => 'store', - 'source' => $tmpDest, 'dest' => $dstPath, 'overwriteDest' => true ); + 'src' => $tmpDest, 'dst' => $dstPath, 'overwriteDest' => true ); if ( !$image->getRepo()->getBackend()->doOperation( $op )->isOK() ) { return new MediaTransformError( 'thumbnail_error', $params['width'], 0, wfMsg( 'thumbnail-dest-create' ) ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs