MediaWiki  1.23.2
FileJournal.php
Go to the documentation of this file.
1 <?php
38 abstract class FileJournal {
40  protected $backend;
41 
43  protected $ttlDays;
44 
51  protected function __construct( array $config ) {
52  $this->ttlDays = isset( $config['ttlDays'] ) ? $config['ttlDays'] : false;
53  }
54 
63  final public static function factory( array $config, $backend ) {
64  $class = $config['class'];
65  $jrn = new $class( $config );
66  if ( !$jrn instanceof self ) {
67  throw new MWException( "Class given is not an instance of FileJournal." );
68  }
69  $jrn->backend = $backend;
70 
71  return $jrn;
72  }
73 
79  final public function getTimestampedUUID() {
80  $s = '';
81  for ( $i = 0; $i < 5; $i++ ) {
82  $s .= mt_rand( 0, 2147483647 );
83  }
84  $s = wfBaseConvert( sha1( $s ), 16, 36, 31 );
85 
86  return substr( wfBaseConvert( wfTimestamp( TS_MW ), 10, 36, 9 ) . $s, 0, 31 );
87  }
88 
100  final public function logChangeBatch( array $entries, $batchId ) {
101  if ( !count( $entries ) ) {
102  return Status::newGood();
103  }
104 
105  return $this->doLogChangeBatch( $entries, $batchId );
106  }
107 
115  abstract protected function doLogChangeBatch( array $entries, $batchId );
116 
122  final public function getCurrentPosition() {
123  return $this->doGetCurrentPosition();
124  }
125 
130  abstract protected function doGetCurrentPosition();
131 
138  final public function getPositionAtTime( $time ) {
139  return $this->doGetPositionAtTime( $time );
140  }
141 
147  abstract protected function doGetPositionAtTime( $time );
148 
166  final public function getChangeEntries( $start = null, $limit = 0, &$next = null ) {
167  $entries = $this->doGetChangeEntries( $start, $limit ? $limit + 1 : 0 );
168  if ( $limit && count( $entries ) > $limit ) {
169  $last = array_pop( $entries ); // remove the extra entry
170  $next = $last['id']; // update for next call
171  } else {
172  $next = null; // end of list
173  }
174 
175  return $entries;
176  }
177 
184  abstract protected function doGetChangeEntries( $start, $limit );
185 
191  final public function purgeOldLogs() {
192  return $this->doPurgeOldLogs();
193  }
194 
199  abstract protected function doPurgeOldLogs();
200 }
201 
206 class NullFileJournal extends FileJournal {
213  protected function doLogChangeBatch( array $entries, $batchId ) {
214  return Status::newGood();
215  }
216 
221  protected function doGetCurrentPosition() {
222  return false;
223  }
224 
230  protected function doGetPositionAtTime( $time ) {
231  return false;
232  }
233 
240  protected function doGetChangeEntries( $start, $limit ) {
241  return array();
242  }
243 
248  protected function doPurgeOldLogs() {
249  return Status::newGood();
250  }
251 }
NullFileJournal\doGetChangeEntries
doGetChangeEntries( $start, $limit)
Definition: FileJournal.php:238
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1358
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
FileJournal\doGetPositionAtTime
doGetPositionAtTime( $time)
NullFileJournal\doGetPositionAtTime
doGetPositionAtTime( $time)
Definition: FileJournal.php:228
FileJournal\doGetChangeEntries
doGetChangeEntries( $start, $limit)
$last
$last
Definition: profileinfo.php:365
NullFileJournal\doGetCurrentPosition
doGetCurrentPosition()
Definition: FileJournal.php:219
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:2483
NullFileJournal
Simple version of FileJournal that does nothing.
Definition: FileJournal.php:204
FileJournal\$backend
string $backend
Definition: FileJournal.php:39
Status\newGood
static newGood( $value=null)
Factory function for good results.
Definition: Status.php:77
$limit
if( $sleep) $limit
Definition: importImages.php:99
$s
$s
Definition: mergeMessageFileList.php:156
FileJournal\getPositionAtTime
getPositionAtTime( $time)
Get the position ID of the latest journal entry at some point in time.
Definition: FileJournal.php:136
FileJournal\getCurrentPosition
getCurrentPosition()
Get the position ID of the latest journal entry.
Definition: FileJournal.php:120
FileJournal\doGetCurrentPosition
doGetCurrentPosition()
NullFileJournal\doLogChangeBatch
doLogChangeBatch(array $entries, $batchId)
Definition: FileJournal.php:211
MWException
MediaWiki exception.
Definition: MWException.php:26
FileJournal\doPurgeOldLogs
doPurgeOldLogs()
FileJournal
Class for handling file operation journaling.
Definition: FileJournal.php:38
FileJournal\logChangeBatch
logChangeBatch(array $entries, $batchId)
Log changes made by a batch file operation.
Definition: FileJournal.php:98
FileJournal\__construct
__construct(array $config)
Construct a new instance from configuration.
Definition: FileJournal.php:49
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
FileJournal\getChangeEntries
getChangeEntries( $start=null, $limit=0, &$next=null)
Get an array of file change log entries.
Definition: FileJournal.php:164
TS_MW
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
Definition: GlobalFunctions.php:2431
FileJournal\doLogChangeBatch
doLogChangeBatch(array $entries, $batchId)
FileJournal\purgeOldLogs
purgeOldLogs()
Purge any old log entries.
Definition: FileJournal.php:189
wfBaseConvert
wfBaseConvert( $input, $sourceBase, $destBase, $pad=1, $lowercase=true, $engine='auto')
Convert an arbitrarily-long digit string from one numeric base to another, optionally zero-padding to...
Definition: GlobalFunctions.php:3368
NullFileJournal\doPurgeOldLogs
doPurgeOldLogs()
Definition: FileJournal.php:246
FileJournal\getTimestampedUUID
getTimestampedUUID()
Get a statistically unique ID string.
Definition: FileJournal.php:77
FileJournal\$ttlDays
int $ttlDays
Definition: FileJournal.php:41
FileJournal\factory
static factory(array $config, $backend)
Create an appropriate FileJournal object from config.
Definition: FileJournal.php:61