X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Flibs%2Ffilebackend%2Ffilejournal%2FFileJournal.php;h=c256d72b1d9d6046aaa8d9f2a5caac2dbc466563;hb=5a451fd01be397db3209c1881a335423706da5c2;hp=dc007a0ceccaa913474df2f391dac2b37fa63bfe;hpb=6cfb2e3d7a2b96d5041312fcec88248bb46573d7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/libs/filebackend/filejournal/FileJournal.php b/includes/libs/filebackend/filejournal/FileJournal.php index dc007a0cec..c256d72b1d 100644 --- a/includes/libs/filebackend/filejournal/FileJournal.php +++ b/includes/libs/filebackend/filejournal/FileJournal.php @@ -26,6 +26,7 @@ * @ingroup FileJournal */ +use Wikimedia\ObjectFactory; use Wikimedia\Timestamp\ConvertibleTimestamp; /** @@ -39,16 +40,16 @@ use Wikimedia\Timestamp\ConvertibleTimestamp; abstract class FileJournal { /** @var string */ protected $backend; - /** @var int */ + /** @var int|false */ 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") */ - protected function __construct( array $config ) { + public function __construct( array $config ) { $this->ttlDays = $config['ttlDays'] ?? false; } @@ -61,11 +62,10 @@ abstract class FileJournal { * @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 is not an instance of " . __CLASS__ ); - } + $jrn = ObjectFactory::getObjectFromSpec( + $config, + [ 'specIsArg' => true, 'assertClass' => __CLASS__ ] + ); $jrn->backend = $backend; return $jrn; @@ -153,7 +153,7 @@ abstract class FileJournal { * A starting change ID and/or limit can be specified. * * @param int|null $start Starting change ID or null - * @param int $limit Maximum number of items to return + * @param int $limit Maximum number of items to return (0 = unlimited) * @param string|null &$next Updated to the ID of the next entry. * @return array List of associative arrays, each having: * id : unique, monotonic, ID for this change