Robert Vogel has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/328678 )
Change subject: Fixed SHA-1 lookup
......................................................................
Fixed SHA-1 lookup
Change-Id: If43d726a9edcd5c650ad3e80b4a3df59d53bcd10
---
M NSFileRepo.php
M NSFileRepo_body.php
2 files changed, 30 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/NSFileRepo
refs/changes/78/328678/1
diff --git a/NSFileRepo.php b/NSFileRepo.php
index 732f305..9d8be16 100644
--- a/NSFileRepo.php
+++ b/NSFileRepo.php
@@ -80,6 +80,9 @@
*/
function NSFileRepoNSCheck( $uploadForm ) {
$title = Title::newFromText($uploadForm->mDesiredDestName);
+ if( $title === null ) {
+ return true;
+ }
if ( $title->getNamespace() < 100 ) {
$uploadForm->mDesiredDestName = preg_replace( "/:/", '-',
$uploadForm->mDesiredDestName );
} else {
diff --git a/NSFileRepo_body.php b/NSFileRepo_body.php
index 6596848..b89ca5b 100644
--- a/NSFileRepo_body.php
+++ b/NSFileRepo_body.php
@@ -5,10 +5,11 @@
*/
class NSLocalRepo extends LocalRepo {
- var $fileFactory = array( 'NSLocalFile', 'newFromTitle' );
- var $oldFileFactory = array( 'NSOldLocalFile', 'newFromTitle' );
- var $fileFromRowFactory = array( 'NSLocalFile', 'newFromRow' );
- var $oldFileFromRowFactory = array( 'NSOldLocalFile', 'newFromRow' );
+ public $fileFactory = array( 'NSLocalFile', 'newFromTitle' );
+ protected $fileFactoryKey = array( 'NSLocalFile', 'newFromKey' );
+ public $oldFileFactory = array( 'NSOldLocalFile', 'newFromTitle' );
+ public $fileFromRowFactory = array( 'NSLocalFile', 'newFromRow' );
+ public $oldFileFromRowFactory = array( 'NSOldLocalFile', 'newFromRow' );
static function getHashPathForLevel( $name, $levels ) {
global $wgContLang;
@@ -52,6 +53,23 @@
}
class NSLocalFile extends LocalFile {
+
+ static function newFromKey( $sha1, $repo, $timestamp = false ) {
+ $dbr = $repo->getSlaveDB();
+
+ $conds = array( 'img_sha1' => $sha1 );
+ if ( $timestamp ) {
+ $conds['img_timestamp'] = $dbr->timestamp( $timestamp );
+ }
+
+ $row = $dbr->selectRow( 'image', self::selectFields(), $conds,
__METHOD__ );
+ if ( $row ) {
+ return self::newFromRow( $row, $repo );
+ } else {
+ return false;
+ }
+ }
+
/**
* Get the path of the file relative to the public zone root
*/
@@ -101,7 +119,7 @@
* Get urlencoded relative path of the file
*/
function getUrlRel() {
- return $this->getHashPath() .
+ return $this->getHashPath() .
rawurlencode( $this->getFileNameStripped(
$this->getName() ) );
}
@@ -146,7 +164,7 @@
list( $thumbExt, $thumbMime ) = $this->handler->getThumbType(
$extension, $this->getMimeType(), $params );
/* This is the part that changed from LocalFile */
- $thumbName = $this->handler->makeParamString( $params ) . '-' .
+ $thumbName = $this->handler->makeParamString( $params ) . '-' .
$this->getFileNameStripped( $this->getName() );
/* End of changes */
if ( $thumbExt != $extension ) {
@@ -230,7 +248,7 @@
$bits = explode( ':', $suffix );
return $bits[ count( $bits ) -1 ];
}
-
+
/**
* Move or copy a file to a specified location. Returns a FileRepoStatus
* object with the archive name in the "value" member on success.
@@ -354,11 +372,11 @@
class NSOldLocalFile extends OldLocalFile {
function getRel() {
- return 'archive/' . $this->getHashPath() .
+ return 'archive/' . $this->getHashPath() .
$this->getFileNameStripped( $this->getArchiveName() );
}
function getUrlRel() {
- return 'archive/' . $this->getHashPath() .
+ return 'archive/' . $this->getHashPath() .
urlencode( $this->getFileNameStripped(
$this->getArchiveName() ) );
}
function publish( $srcPath, $flags = 0, array $options = array() ) {
--
To view, visit https://gerrit.wikimedia.org/r/328678
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If43d726a9edcd5c650ad3e80b4a3df59d53bcd10
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/NSFileRepo
Gerrit-Branch: REL1_23
Gerrit-Owner: Robert Vogel <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits