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
Merge "Fix call to non-existing TempFSFileFactory::getTempFSFile()"
[lhc/web/wiklou.git]
/
includes
/
libs
/
filebackend
/
filejournal
/
FileJournal.php
diff --git
a/includes/libs/filebackend/filejournal/FileJournal.php
b/includes/libs/filebackend/filejournal/FileJournal.php
index
999594b
..
e512423
100644
(file)
--- a/
includes/libs/filebackend/filejournal/FileJournal.php
+++ b/
includes/libs/filebackend/filejournal/FileJournal.php
@@
-26,6
+26,9
@@
* @ingroup FileJournal
*/
* @ingroup FileJournal
*/
+use Wikimedia\ObjectFactory;
+use Wikimedia\Timestamp\ConvertibleTimestamp;
+
/**
* @brief Class for handling file operation journaling.
*
/**
* @brief Class for handling file operation journaling.
*
@@
-37,17
+40,16
@@
abstract class FileJournal {
/** @var string */
protected $backend;
abstract class FileJournal {
/** @var string */
protected $backend;
-
/** @var int */
protected $ttlDays;
/**
/** @var int */
protected $ttlDays;
/**
- * Construct a new instance from configuration.
+ * Construct a new instance from configuration.
Do not call this directly, use factory().
*
* @param array $config Includes:
* 'ttlDays' : days to keep log entries around (false means "forever")
*/
*
* @param array $config Includes:
* 'ttlDays' : days to keep log entries around (false means "forever")
*/
- p
rotected
function __construct( array $config ) {
+ p
ublic
function __construct( array $config ) {
$this->ttlDays = $config['ttlDays'] ?? false;
}
$this->ttlDays = $config['ttlDays'] ?? false;
}
@@
-60,11
+62,10
@@
abstract class FileJournal {
* @return FileJournal
*/
final public static function factory( array $config, $backend ) {
* @return FileJournal
*/
final public static function factory( array $config, $backend ) {
- $class = $config['class'];
- $jrn = new $class( $config );
- if ( !$jrn instanceof self ) {
- throw new InvalidArgumentException( "Class given is not an instance of FileJournal." );
- }
+ $jrn = ObjectFactory::getObjectFromSpec(
+ $config,
+ [ 'specIsArg' => true, 'assertClass' => __CLASS__ ]
+ );
$jrn->backend = $backend;
return $jrn;
$jrn->backend = $backend;
return $jrn;
@@
-82,7
+83,9
@@
abstract class FileJournal {
}
$s = Wikimedia\base_convert( sha1( $s ), 16, 36, 31 );
}
$s = Wikimedia\base_convert( sha1( $s ), 16, 36, 31 );
- return substr( Wikimedia\base_convert( wfTimestamp( TS_MW ), 10, 36, 9 ) . $s, 0, 31 );
+ $timestamp = ConvertibleTimestamp::convert( TS_MW, time() );
+
+ return substr( Wikimedia\base_convert( $timestamp, 10, 36, 9 ) . $s, 0, 31 );
}
/**
}
/**