Wikibase
MediaWiki Wikibase extension
Wikibase\Lib\Changes\ChangeRow Class Reference

Class representing a single change (ie a row in the wb_changes). More...

+ Inheritance diagram for Wikibase\Lib\Changes\ChangeRow:
+ Collaboration diagram for Wikibase\Lib\Changes\ChangeRow:

Public Member Functions

 __construct (array $fields=[])
 
 setLogger (LoggerInterface $logger)
 
 getAge ()
 
 getTime ()
 
 getUserId ()
 Original (repository) user id, or 0 for logged out users. More...
 
 getObjectId ()
 
 getField ( $name)
 
 getFields ()
 Overwritten to unserialize the info field on the fly. More...
 
 getInfo ( $cache='no')
 Returns the info array. More...
 
 getSerializedInfo ( $skipKeys=[])
 
 setField ( $name, $value)
 Sets the value of a field. More...
 
 setFields (array $fields)
 Sets multiple fields. More...
 
 getId ()
 
 hasField ( $name)
 Gets if a certain field is set. More...
 
- Public Member Functions inherited from Wikibase\Lib\Changes\Change
 getType ()
 Returns the type of change. More...
 

Public Attributes

const ID = 'id'
 
const METADATA = 'metadata'
 
const INFO = 'info'
 
const TIME = 'time'
 
const USER_ID = 'user_id'
 
const OBJECT_ID = 'object_id'
 
const COMPACT_DIFF = 'compactDiff'
 
const TYPE = 'type'
 
const REVISION_ID = 'revision_id'
 

Protected Member Functions

 unserializeInfo ( $str)
 Unserializes the info field using json_decode. More...
 

Protected Attributes

 $logger
 

Private Attributes

 $fields = [ self::ID => null ]
 

Detailed Description

Class representing a single change (ie a row in the wb_changes).

Author
Jeroen De Dauw < jeroe.nosp@m.nded.nosp@m.auw@g.nosp@m.mail.nosp@m..com >
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Changes\ChangeRow::__construct ( array  $fields = [])

Member Function Documentation

◆ getAge()

Wikibase\Lib\Changes\ChangeRow::getAge ( )
See also
Change::getAge
Exceptions
Exceptionif the "time" field is not set
Returns
int Seconds

Implements Wikibase\Lib\Changes\Change.

◆ getField()

Wikibase\Lib\Changes\ChangeRow::getField (   $name)
Parameters
string$name
Exceptions
Exceptionif the requested field is not set
Returns
mixed

◆ getFields()

Wikibase\Lib\Changes\ChangeRow::getFields ( )

Overwritten to unserialize the info field on the fly.

Returns
array

◆ getId()

Wikibase\Lib\Changes\ChangeRow::getId ( )
Exceptions
Exceptionif the "id" field is not set
Returns
int|null Number to be used as an identifier when persisting the change.

Implements Wikibase\Lib\Changes\Change.

◆ getInfo()

Wikibase\Lib\Changes\ChangeRow::getInfo (   $cache = 'no')

Returns the info array.

The array is deserialized on the fly. If $cache is set to 'cache', the deserialized version is stored for later re-use.

Usually, the deserialized version is not retained to preserve memory when lots of changes need to be processed. It can however be retained to improve performance in cases where the same object is accessed several times.

Parameters
string$cacheSet to 'cache' to cache the unserialized version of the info array.
Returns
array

◆ getObjectId()

Wikibase\Lib\Changes\ChangeRow::getObjectId ( )
See also
Change::getObjectId
Exceptions
Exceptionif the "object_id" field is not set
Returns
string

Implements Wikibase\Lib\Changes\Change.

◆ getSerializedInfo()

Wikibase\Lib\Changes\ChangeRow::getSerializedInfo (   $skipKeys = [])
abstract
Parameters
string[]$skipKeysKeys of the info array to skip during serialization. Useful for omitting undesired or unserializable data from the serialization.
Returns
string JSON

Reimplemented in Wikibase\Lib\Changes\EntityChange.

◆ getTime()

Wikibase\Lib\Changes\ChangeRow::getTime ( )
See also
Change::getTime
Exceptions
Exceptionif the "time" field is not set
Returns
string TS_MW

Implements Wikibase\Lib\Changes\Change.

◆ getUserId()

Wikibase\Lib\Changes\ChangeRow::getUserId ( )

Original (repository) user id, or 0 for logged out users.

Returns
int

Implements Wikibase\Lib\Changes\Change.

◆ hasField()

Wikibase\Lib\Changes\ChangeRow::hasField (   $name)

Gets if a certain field is set.

Parameters
string$name
Returns
bool

◆ setField()

Wikibase\Lib\Changes\ChangeRow::setField (   $name,
  $value 
)

Sets the value of a field.

Strings can be provided for other types, so this method can be called from unserialization handlers.

Parameters
string$name
mixed$value

◆ setFields()

Wikibase\Lib\Changes\ChangeRow::setFields ( array  $fields)

Sets multiple fields.

Parameters
array$fieldsThe fields to set

◆ setLogger()

Wikibase\Lib\Changes\ChangeRow::setLogger ( LoggerInterface  $logger)

◆ unserializeInfo()

Wikibase\Lib\Changes\ChangeRow::unserializeInfo (   $str)
protected

Unserializes the info field using json_decode.

This may be overridden by subclasses to implement special handling for information in the info field.

Parameters
string$str
Returns
array the info array

Reimplemented in Wikibase\Lib\Changes\EntityChange.

Member Data Documentation

◆ $fields

Wikibase\Lib\Changes\ChangeRow::$fields = [ self::ID => null ]
private

◆ $logger

Wikibase\Lib\Changes\ChangeRow::$logger
protected

◆ COMPACT_DIFF

const Wikibase\Lib\Changes\ChangeRow::COMPACT_DIFF = 'compactDiff'

◆ ID

const Wikibase\Lib\Changes\ChangeRow::ID = 'id'

◆ INFO

const Wikibase\Lib\Changes\ChangeRow::INFO = 'info'

◆ METADATA

const Wikibase\Lib\Changes\ChangeRow::METADATA = 'metadata'

◆ OBJECT_ID

const Wikibase\Lib\Changes\ChangeRow::OBJECT_ID = 'object_id'

◆ REVISION_ID

const Wikibase\Lib\Changes\ChangeRow::REVISION_ID = 'revision_id'

◆ TIME

const Wikibase\Lib\Changes\ChangeRow::TIME = 'time'

◆ TYPE

const Wikibase\Lib\Changes\ChangeRow::TYPE = 'type'

◆ USER_ID

const Wikibase\Lib\Changes\ChangeRow::USER_ID = 'user_id'

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