dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make file purging also purge old versions
[lhc/web/wiklou.git]
/
includes
/
filerepo
/
file
/
LocalFile.php
diff --git
a/includes/filerepo/file/LocalFile.php
b/includes/filerepo/file/LocalFile.php
index
c109fba
..
f71e1dc
100644
(file)
--- a/
includes/filerepo/file/LocalFile.php
+++ b/
includes/filerepo/file/LocalFile.php
@@
-21,7
+21,8
@@
* @ingroup FileAbstraction
*/
* @ingroup FileAbstraction
*/
-use \MediaWiki\Logger\LoggerFactory;
+use MediaWiki\Logger\LoggerFactory;
+use Wikimedia\Rdbms\Database;
use Wikimedia\Rdbms\IDatabase;
/**
use Wikimedia\Rdbms\IDatabase;
/**
@@
-592,7
+593,7
@@
class LocalFile extends File {
if ( $upgrade ) {
$this->upgrading = true;
// Defer updates unless in auto-commit CLI mode
if ( $upgrade ) {
$this->upgrading = true;
// Defer updates unless in auto-commit CLI mode
- DeferredUpdates::addCallableUpdate( function() {
+ DeferredUpdates::addCallableUpdate( function
() {
$this->upgrading = false; // avoid duplicate updates
try {
$this->upgradeRow();
$this->upgrading = false; // avoid duplicate updates
try {
$this->upgradeRow();
@@
-715,6
+716,11
@@
class LocalFile extends File {
* @return int
*/
public function getWidth( $page = 1 ) {
* @return int
*/
public function getWidth( $page = 1 ) {
+ $page = (int)$page;
+ if ( $page < 1 ) {
+ $page = 1;
+ }
+
$this->load();
if ( $this->isMultipage() ) {
$this->load();
if ( $this->isMultipage() ) {
@@
-742,6
+748,11
@@
class LocalFile extends File {
* @return int
*/
public function getHeight( $page = 1 ) {
* @return int
*/
public function getHeight( $page = 1 ) {
+ $page = (int)$page;
+ if ( $page < 1 ) {
+ $page = 1;
+ }
+
$this->load();
if ( $this->isMultipage() ) {
$this->load();
if ( $this->isMultipage() ) {
@@
-1021,9
+1032,15
@@
class LocalFile extends File {
$purgeList = [];
foreach ( $files as $file ) {
$purgeList = [];
foreach ( $files as $file ) {
- # Check that the base file name is part of the thumb name
+ if ( $this->repo->supportsSha1URLs() ) {
+ $reference = $this->getSha1();
+ } else {
+ $reference = $this->getName();
+ }
+
+ # Check that the reference (filename or sha1) is part of the thumb name
# This is a basic sanity check to avoid erasing unrelated directories
# This is a basic sanity check to avoid erasing unrelated directories
- if ( strpos( $file, $
this->getName()
) !== false
+ if ( strpos( $file, $
reference
) !== false
|| strpos( $file, "-thumbnail" ) !== false // "short" thumb name
) {
$purgeList[] = "{$dir}/{$file}";
|| strpos( $file, "-thumbnail" ) !== false // "short" thumb name
) {
$purgeList[] = "{$dir}/{$file}";
@@
-1199,7
+1216,13
@@
class LocalFile extends File {
$options = [];
$handler = MediaHandler::getHandler( $props['mime'] );
if ( $handler ) {
$options = [];
$handler = MediaHandler::getHandler( $props['mime'] );
if ( $handler ) {
- $options['headers'] = $handler->getStreamHeaders( $props['metadata'] );
+ $metadata = MediaWiki\quietCall( 'unserialize', $props['metadata'] );
+
+ if ( !is_array( $metadata ) ) {
+ $metadata = [];
+ }
+
+ $options['headers'] = $handler->getContentHeaders( $metadata );
} else {
$options['headers'] = [];
}
} else {
$options['headers'] = [];
}