Break long lines in file repo files

Change-Id: I6d95c1b3e14a947a92127efa681007baaeab89ba
This commit is contained in:
Siebrand Mazeland 2013-11-23 21:54:48 +01:00 committed by Siebrand
parent bb39b5a6e4
commit f742b27dd3
5 changed files with 39 additions and 15 deletions

View file

@ -72,7 +72,8 @@ class FileRepo {
|| !array_key_exists( 'name', $info )
|| !array_key_exists( 'backend', $info )
) {
throw new MWException( __CLASS__ . " requires an array of options having both 'name' and 'backend' keys.\n" );
throw new MWException( __CLASS__ .
" requires an array of options having both 'name' and 'backend' keys.\n" );
}
// Required settings
@ -206,11 +207,14 @@ class FileRepo {
* @return String or false
*/
public function getZoneUrl( $zone, $ext = null ) {
if ( in_array( $zone, array( 'public', 'temp', 'thumb', 'transcoded' ) ) ) { // standard public zones
if ( in_array( $zone, array( 'public', 'temp', 'thumb', 'transcoded' ) ) ) {
// standard public zones
if ( $ext !== null && isset( $this->zones[$zone]['urlsByExt'][$ext] ) ) {
return $this->zones[$zone]['urlsByExt'][$ext]; // custom URL for extension/zone
// custom URL for extension/zone
return $this->zones[$zone]['urlsByExt'][$ext];
} elseif ( isset( $this->zones[$zone]['url'] ) ) {
return $this->zones[$zone]['url']; // custom URL for zone
// custom URL for zone
return $this->zones[$zone]['url'];
}
}
switch ( $zone ) {

View file

@ -316,7 +316,8 @@ class ForeignAPIRepo extends FileRepo {
* @param string $name is a dbkey form of a title
* @param $width
* @param $height
* @param string $params Other rendering parameters (page number, etc) from handler's makeParamString.
* @param string $params Other rendering parameters (page number, etc)
* from handler's makeParamString.
* @return bool|string
*/
function getThumbUrlFromCache( $name, $width, $height, $params = "" ) {
@ -365,7 +366,8 @@ class ForeignAPIRepo extends FileRepo {
}
$localPath = $this->getZonePath( 'thumb' ) . "/" . $this->getHashPath( $name ) . $name;
$localFilename = $localPath . "/" . $fileName;
$localUrl = $this->getZoneUrl( 'thumb' ) . "/" . $this->getHashPath( $name ) . rawurlencode( $name ) . "/" . rawurlencode( $fileName );
$localUrl = $this->getZoneUrl( 'thumb' ) . "/" . $this->getHashPath( $name ) .
rawurlencode( $name ) . "/" . rawurlencode( $fileName );
if ( $backend->fileExists( array( 'src' => $localFilename ) )
&& isset( $metadata['timestamp'] )

View file

@ -1473,7 +1473,9 @@ abstract class File {
* @return bool
* @throws MWException
*/
function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '', $watch = false, $timestamp = false, User $user = null ) {
function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '',
$watch = false, $timestamp = false, User $user = null
) {
$this->readOnlyError();
}

View file

@ -291,7 +291,8 @@ class LocalFile extends File {
*/
function getCacheFields( $prefix = 'img_' ) {
static $fields = array( 'size', 'width', 'height', 'bits', 'media_type',
'major_mime', 'minor_mime', 'metadata', 'timestamp', 'sha1', 'user', 'user_text', 'description' );
'major_mime', 'minor_mime', 'metadata', 'timestamp', 'sha1', 'user',
'user_text', 'description' );
static $results = array();
if ( $prefix == '' ) {
@ -1090,7 +1091,9 @@ class LocalFile extends File {
* @return FileRepoStatus object. On success, the value member contains the
* archive name, or an empty string if it was a new file.
*/
function upload( $srcPath, $comment, $pageText, $flags = 0, $props = false, $timestamp = false, $user = null ) {
function upload( $srcPath, $comment, $pageText, $flags = 0, $props = false,
$timestamp = false, $user = null
) {
global $wgContLang;
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
@ -1369,7 +1372,13 @@ class LocalFile extends File {
# There's already a log entry, so don't make a second RC entry
# Squid and file cache for the description page are purged by doEditContent.
$content = ContentHandler::makeContent( $pageText, $descTitle );
$status = $wikiPage->doEditContent( $content, $comment, EDIT_NEW | EDIT_SUPPRESS_RC, false, $user );
$status = $wikiPage->doEditContent(
$content,
$comment,
EDIT_NEW | EDIT_SUPPRESS_RC,
false,
$user
);
$dbw->begin( __METHOD__ ); // XXX; doEdit() uses a transaction
// Now that the page exists, make an RC entry.
@ -2291,7 +2300,8 @@ class LocalFileRestoreBatch {
continue;
}
$deletedRel = $this->file->repo->getDeletedHashPath( $row->fa_storage_key ) . $row->fa_storage_key;
$deletedRel = $this->file->repo->getDeletedHashPath( $row->fa_storage_key ) .
$row->fa_storage_key;
$deletedUrl = $this->file->repo->getVirtualUrl() . '/deleted/' . $deletedRel;
if ( isset( $row->fa_sha1 ) ) {
@ -2671,13 +2681,15 @@ class LocalFileMoveBatch {
return $statusDb;
}
wfDebugLog( 'imagemove', "Renamed {$this->file->getName()} in database: {$statusDb->successCount} successes, {$statusDb->failCount} failures" );
wfDebugLog( 'imagemove', "Renamed {$this->file->getName()} in database: " .
"{$statusDb->successCount} successes, {$statusDb->failCount} failures" );
// Copy the files into their new location.
// If a prior process fataled copying or cleaning up files we tolerate any
// of the existing files if they are identical to the ones being stored.
$statusMove = $repo->storeBatch( $triplets, FileRepo::OVERWRITE_SAME );
wfDebugLog( 'imagemove', "Moved files for {$this->file->getName()}: {$statusMove->successCount} successes, {$statusMove->failCount} failures" );
wfDebugLog( 'imagemove', "Moved files for {$this->file->getName()}: " .
"{$statusMove->successCount} successes, {$statusMove->failCount} failures" );
if ( !$statusMove->isGood() ) {
// Delete any files copied over (while the destination is still locked)
$this->cleanupTarget( $triplets );
@ -2764,7 +2776,10 @@ class LocalFileMoveBatch {
// $move: (oldRelativePath, newRelativePath)
$srcUrl = $this->file->repo->getVirtualUrl() . '/public/' . rawurlencode( $move[0] );
$triplets[] = array( $srcUrl, 'public', $move[1] );
wfDebugLog( 'imagemove', "Generated move triplet for {$this->file->getName()}: {$srcUrl} :: public :: {$move[1]}" );
wfDebugLog(
'imagemove',
"Generated move triplet for {$this->file->getName()}: {$srcUrl} :: public :: {$move[1]}"
);
}
return $triplets;

View file

@ -71,7 +71,8 @@ class UnregisteredLocalFile extends File {
*/
function __construct( $title = false, $repo = false, $path = false, $mime = false ) {
if ( !( $title && $repo ) && !$path ) {
throw new MWException( __METHOD__ . ': not enough parameters, must specify title and repo, or a full path' );
throw new MWException( __METHOD__ .
': not enough parameters, must specify title and repo, or a full path' );
}
if ( $title instanceof Title ) {
$this->title = File::normalizeTitle( $title, 'exception' );