Wikibase
MediaWiki Wikibase extension
Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity Class Reference

EditEntity that collects stats for edits. More...

+ Inheritance diagram for Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity:
+ Collaboration diagram for Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity:

Public Member Functions

 __construct (EditEntity $editEntity, StatsdDataFactoryInterface $stats, string $timingPrefix)
 
 getEntityId ()
 Returns the ID of the entity being edited. More...
 
 getLatestRevision ()
 Returns the latest revision of the entity. More...
 
 getBaseRevision ()
 Return the base revision for the edit. More...
 
 getStatus ()
 Get the status object. More...
 
 isSuccess ()
 Determines whether the last call to attemptSave was successful. More...
 
 hasError ( $errorType=self::ANY_ERROR)
 Checks whether this EditEntity encountered any of the given error types while executing attemptSave(). More...
 
 hasEditConflict ()
 Determines whether an edit conflict exists, that is, whether another user has edited the same item after the base revision was created. More...
 
 isTokenOK ( $token)
 Make sure the given WebRequest contains a valid edit token. More...
 
 attemptSave (EntityDocument $newEntity, $summary, $flags, $token, $watch=null, array $tags=[])
 Attempts to save the given Entity object. More...
 

Private Attributes

 $inner
 
 $stats
 
 $timingPrefix
 

Additional Inherited Members

- Public Attributes inherited from Wikibase\Repo\EditEntity\EditEntity
const PERMISSION_ERROR = 1
 indicates a permission error More...
 
const EDIT_CONFLICT_ERROR = 2
 indicates an unresolved edit conflict More...
 
const TOKEN_ERROR = 4
 indicates a token or session error More...
 
const SAVE_ERROR = 8
 indicates that an error occurred while saving More...
 
const PRECONDITION_FAILED = 16
 Indicates that the content failed some precondition to saving, such as a global uniqueness constraint. More...
 
const FILTERED = 32
 Indicates that the content triggered an edit filter that uses the EditFilterMergedContent hook to supervise edits. More...
 
const RATE_LIMIT = 64
 Indicates that the edit exceeded a rate limit. More...
 
const ANY_ERROR = 0xFFFFFFFF
 bit mask for asking for any error. More...
 

Detailed Description

EditEntity that collects stats for edits.

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::__construct ( EditEntity  $editEntity,
StatsdDataFactoryInterface  $stats,
string  $timingPrefix 
)
Parameters
EditEntity$editEntity
StatsdDataFactoryInterface$stats
string$timingPrefixResulting metric will be: $timingPrefix.<savetype>.<entitytype>

Member Function Documentation

◆ attemptSave()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::attemptSave ( EntityDocument  $newEntity,
  $summary,
  $flags,
  $token,
  $watch = null,
array  $tags = [] 
)

Attempts to save the given Entity object.

This method performs entity level permission checks, checks the edit toke, enforces rate limits, resolves edit conflicts, and updates user watchlists if appropriate.

Success or failure are reported via the Status object returned by this method.

Todo:
$flags here should ideally not refer to EDIT_ constants from mediawiki core.
Todo:
This shouldn't throw MWExceptions
Parameters
EntityDocument$newEntity
string$summaryThe edit summary.
int$flagsThe EDIT_XXX flags as used by WikiPage::doEditContent(). Additionally, the EntityContent::EDIT_XXX constants can be used.
string | bool$tokenEdit token to check, or false to disable the token check. Null will fail the token text, as will the empty string.
bool | null$watchWhether the user wants to watch the entity. Set to null to apply default according to getWatchDefault().
string[]$tagsChange tags to add to the edit. Callers are responsible for checking that the user is permitted to add these tags.
Returns
Status
Exceptions
MWException
ReadOnlyError
See also
WikiPage::doEditContent
EntityStore::saveEntity

Implements Wikibase\Repo\EditEntity\EditEntity.

◆ getBaseRevision()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::getBaseRevision ( )

Return the base revision for the edit.

If no base revision ID was supplied to the constructor, this returns the latest revision. If the entity does not exist yet, this returns null.

Returns
EntityRevision|null
Exceptions
MWException

Implements Wikibase\Repo\EditEntity\EditEntity.

◆ getEntityId()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::getEntityId ( )

Returns the ID of the entity being edited.

May be null if a new entity is to be created.

Returns
null|EntityId

Implements Wikibase\Repo\EditEntity\EditEntity.

◆ getLatestRevision()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::getLatestRevision ( )

Returns the latest revision of the entity.

Returns
EntityRevision|null

Implements Wikibase\Repo\EditEntity\EditEntity.

◆ getStatus()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::getStatus ( )

Get the status object.

Only defined after attemptSave() was called.

After a successful save, the Status object's value field will contain an array, just like the status returned by WikiPage::doEditContent(). Well known fields in the status value are:

  • new: bool whether the edit created a new page
  • revision: Revision the new revision object
  • errorFlags: bit field indicating errors, see the XXX_ERROR constants.
Returns
Status

Implements Wikibase\Repo\EditEntity\EditEntity.

◆ hasEditConflict()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::hasEditConflict ( )

Determines whether an edit conflict exists, that is, whether another user has edited the same item after the base revision was created.

In other words, this method checks whether the base revision (as provided to the constructor) is still current. If no base revision was provided to the constructor, this will always return false.

If the base revision is different from the current revision, this will return true even if the edit conflict is resolvable. Indeed, it is used to determine whether conflict resolution should be attempted.

Returns
bool

Implements Wikibase\Repo\EditEntity\EditEntity.

◆ hasError()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::hasError (   $errorType = self::ANY_ERROR)

Checks whether this EditEntity encountered any of the given error types while executing attemptSave().

Parameters
int$errorTypebit field using the EditEntity::XXX_ERROR constants. Defaults to EditEntity::ANY_ERROR.
Returns
bool true if this EditEntity encountered any of the error types in $errorType, false otherwise.

Implements Wikibase\Repo\EditEntity\EditEntity.

◆ isSuccess()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::isSuccess ( )

Determines whether the last call to attemptSave was successful.

Returns
bool false if attemptSave() failed, true otherwise

Implements Wikibase\Repo\EditEntity\EditEntity.

◆ isTokenOK()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::isTokenOK (   $token)

Make sure the given WebRequest contains a valid edit token.

Parameters
string$tokenThe token to check.
Returns
bool true if the token is valid

Implements Wikibase\Repo\EditEntity\EditEntity.

Member Data Documentation

◆ $inner

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::$inner
private

◆ $stats

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::$stats
private

◆ $timingPrefix

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity::$timingPrefix
private

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