From ca32f08966f1b51fcb19460f0996bb0c4048e6fe Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 3 Dec 2011 13:29:22 +0100 Subject: Update to MediaWiki 1.18.0 * also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing --- includes/filerepo/LocalRepo.php | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'includes/filerepo/LocalRepo.php') diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index 02883c53..9089f4d7 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -20,6 +20,11 @@ class LocalRepo extends FSRepo { var $fileFromRowFactory = array( 'LocalFile', 'newFromRow' ); var $oldFileFromRowFactory = array( 'OldLocalFile', 'newFromRow' ); + /** + * @throws MWException + * @param $row + * @return File + */ function newFileFromRow( $row ) { if ( isset( $row->img_name ) ) { return call_user_func( $this->fileFromRowFactory, $row, $this ); @@ -30,6 +35,11 @@ class LocalRepo extends FSRepo { } } + /** + * @param $title + * @param $archiveName + * @return OldLocalFile + */ function newFromArchiveName( $title, $archiveName ) { return OldLocalFile::newFromArchiveName( $title, $this, $archiveName ); } @@ -39,13 +49,16 @@ class LocalRepo extends FSRepo { * filearchive table. This needs to be done in the repo because it needs to * interleave database locks with file operations, which is potentially a * remote operation. + * + * @param $storageKeys array + * * @return FileRepoStatus */ function cleanupDeletedBatch( $storageKeys ) { $root = $this->getZonePath( 'deleted' ); $dbw = $this->getMasterDB(); $status = $this->newGood(); - $storageKeys = array_unique($storageKeys); + $storageKeys = array_unique( $storageKeys ); foreach ( $storageKeys as $key ) { $hashPath = $this->getDeletedHashPath( $key ); $path = "$root/$hashPath$key"; @@ -54,8 +67,8 @@ class LocalRepo extends FSRepo { array( 'fa_storage_group' => 'deleted', 'fa_storage_key' => $key ), __METHOD__, array( 'FOR UPDATE' ) ); if( !$inuse ) { - $sha1 = substr( $key, 0, strcspn( $key, '.' ) ); - $ext = substr( $key, strcspn($key,'.') + 1 ); + $sha1 = self::getHashFromKey( $key ); + $ext = substr( $key, strcspn( $key, '.' ) + 1 ); $ext = File::normalizeExtension($ext); $inuse = $dbw->selectField( 'oldimage', '1', array( 'oi_sha1' => $sha1, @@ -65,7 +78,10 @@ class LocalRepo extends FSRepo { } if ( !$inuse ) { wfDebug( __METHOD__ . ": deleting $key\n" ); - if ( !@unlink( $path ) ) { + wfSuppressWarnings(); + $unlink = unlink( $path ); + wfRestoreWarnings(); + if ( !$unlink ) { $status->error( 'undelete-cleanup-error', $path ); $status->failCount++; } @@ -77,6 +93,16 @@ class LocalRepo extends FSRepo { } return $status; } + + /** + * Gets the SHA1 hash from a storage key + * + * @param string $key + * @return string + */ + public static function getHashFromKey( $key ) { + return strtok( $key, '.' ); + } /** * Checks if there is a redirect named as $title @@ -87,7 +113,7 @@ class LocalRepo extends FSRepo { global $wgMemc; if( is_string( $title ) ) { - $title = Title::newFromTitle( $title ); + $title = Title::newFromText( $title ); } if( $title instanceof Title && $title->getNamespace() == NS_MEDIA ) { $title = Title::makeTitle( NS_FILE, $title->getText() ); @@ -135,6 +161,7 @@ class LocalRepo extends FSRepo { /** * Function link Title::getArticleID(). * We can't say Title object, what database it should use, so we duplicate that function here. + * @param $title Title */ protected function getArticleID( $title ) { if( !$title instanceof Title ) { -- cgit v1.2.3-54-g00ecf