MediaWiki  master
FileJournal Class Reference

Class for handling file operation journaling. More...

Inheritance diagram for FileJournal:

Public Member Functions

 __construct (array $config)
 Construct a new instance from configuration. More...
 
 getChangeEntries ( $start=null, $limit=0, &$next=null)
 Get an array of file change log entries. More...
 
 getCurrentPosition ()
 Get the position ID of the latest journal entry. More...
 
 getPositionAtTime ( $time)
 Get the position ID of the latest journal entry at some point in time. More...
 
 getTimestampedUUID ()
 Get a statistically unique ID string. More...
 
 logChangeBatch (array $entries, $batchId)
 Log changes made by a batch file operation. More...
 
 purgeOldLogs ()
 Purge any old log entries. More...
 

Static Public Member Functions

static factory (array $config, $backend)
 Create an appropriate FileJournal object from config. More...
 

Protected Member Functions

 doGetChangeEntries ( $start, $limit)
 
 doGetCurrentPosition ()
 
 doGetPositionAtTime ( $time)
 
 doLogChangeBatch (array $entries, $batchId)
 
 doPurgeOldLogs ()
 

Protected Attributes

string $backend
 
int false $ttlDays
 

Detailed Description

Class for handling file operation journaling.

Subclasses should avoid throwing exceptions at all costs.

Since
1.20

Definition at line 40 of file FileJournal.php.

Constructor & Destructor Documentation

◆ __construct()

FileJournal::__construct ( array  $config)

Construct a new instance from configuration.

Parameters
array$configIncludes:
  • 'backend': The name of a registered file backend
  • 'ttlDays': Days to keep log entries around (false means "forever")

Definition at line 53 of file FileJournal.php.

Member Function Documentation

◆ doGetChangeEntries()

FileJournal::doGetChangeEntries (   $start,
  $limit 
)
abstractprotected
See also
FileJournal::getChangeEntries()
Parameters
int$start
int$limit
Returns
array

Referenced by getChangeEntries().

◆ doGetCurrentPosition()

FileJournal::doGetCurrentPosition ( )
abstractprotected
See also
FileJournal::getCurrentPosition()
Returns
int|bool

Referenced by getCurrentPosition().

◆ doGetPositionAtTime()

FileJournal::doGetPositionAtTime (   $time)
abstractprotected
See also
FileJournal::getPositionAtTime()
Parameters
int | string$timeTimestamp
Returns
int|bool

Referenced by getPositionAtTime().

◆ doLogChangeBatch()

FileJournal::doLogChangeBatch ( array  $entries,
  $batchId 
)
abstractprotected
See also
FileJournal::logChangeBatch()
Parameters
array$entriesList of file operations (each an array of parameters)
string$batchIdUUID string that identifies the operation batch
Returns
StatusValue

Referenced by logChangeBatch().

◆ doPurgeOldLogs()

FileJournal::doPurgeOldLogs ( )
abstractprotected

◆ factory()

static FileJournal::factory ( array  $config,
  $backend 
)
staticfinal

Create an appropriate FileJournal object from config.

Deprecated:
since 1.35, only FileBackendGroup should need to create FileJournals
Parameters
array$config
string$backendA registered file backend name
Exceptions
Exception
Returns
FileJournal

Definition at line 67 of file FileJournal.php.

References wfDeprecated().

◆ getChangeEntries()

FileJournal::getChangeEntries (   $start = null,
  $limit = 0,
$next = null 
)
final

Get an array of file change log entries.

A starting change ID and/or limit can be specified.

Parameters
int | null$startStarting change ID or null
int$limitMaximum number of items to return (0 = unlimited)
string | null&$nextUpdated to the ID of the next entry.
Returns
array[] List of associative arrays, each having: id : unique, monotonic, ID for this change batch_uuid : UUID for an operation batch backend : the backend name op : primitive operation (create,update,delete,null) path : affected storage path new_sha1 : base 36 sha1 of the new file had the operation succeeded timestamp : TS_MW timestamp of the batch change Also, $next is updated to the ID of the next entry. -return array<int,array{id:int,batch_uuid:string,backend:string,op:string,path:string,new_sha1:string,timestamp:string}>

Definition at line 173 of file FileJournal.php.

References doGetChangeEntries().

◆ getCurrentPosition()

FileJournal::getCurrentPosition ( )
final

Get the position ID of the latest journal entry.

Returns
int|bool

Definition at line 128 of file FileJournal.php.

References doGetCurrentPosition().

◆ getPositionAtTime()

FileJournal::getPositionAtTime (   $time)
final

Get the position ID of the latest journal entry at some point in time.

Parameters
int | string$timeTimestamp
Returns
int|bool

Definition at line 144 of file FileJournal.php.

References doGetPositionAtTime().

◆ getTimestampedUUID()

FileJournal::getTimestampedUUID ( )
final

Get a statistically unique ID string.

Returns
string <9 char TS_MW timestamp in base 36><22 random base 36 chars>

Definition at line 83 of file FileJournal.php.

References $s.

Referenced by FileOpBatch\attempt().

◆ logChangeBatch()

FileJournal::logChangeBatch ( array  $entries,
  $batchId 
)
final

Log changes made by a batch file operation.

Parameters
array$entriesList of file operations (each an array of parameters) which contain: op : Basic operation name (create, update, delete) path : The storage path of the file newSha1 : The final base 36 SHA-1 of the file Note that 'false' should be used as the SHA-1 for non-existing files.
string$batchIdUUID string that identifies the operation batch
Returns
StatusValue

Definition at line 106 of file FileJournal.php.

References doLogChangeBatch(), and StatusValue\newGood().

Referenced by FileOpBatch\attempt().

◆ purgeOldLogs()

FileJournal::purgeOldLogs ( )
final

Purge any old log entries.

Returns
StatusValue

Definition at line 198 of file FileJournal.php.

References doPurgeOldLogs().

Referenced by DBFileJournal\doLogChangeBatch().

Member Data Documentation

◆ $backend

string FileJournal::$backend
protected

Definition at line 42 of file FileJournal.php.

Referenced by DBFileJournal\doLogChangeBatch().

◆ $ttlDays

int false FileJournal::$ttlDays
protected

Definition at line 44 of file FileJournal.php.


The documentation for this class was generated from the following file: