Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore Class Reference

EntityStore that collects stats for edit save times. More...

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

Public Member Functions

 __construct (EntityStore $entityStore, StatsdDataFactoryInterface $stats, string $timingPrefix)
 
 assignFreshId (EntityDocument $entity)
 Assigns a fresh ID to the given entity.
 
 saveEntity (EntityDocument $entity, $summary, User $user, $flags=0, $baseRevId=false, array $tags=[])
 Saves the given Entity to some underlying storage mechanism.
 
 saveRedirect (EntityRedirect $redirect, $summary, User $user, $flags=0, $baseRevId=false, array $tags=[])
 Saves the given EntityRedirect to some underlying storage mechanism.
 
 deleteEntity (EntityId $entityId, $reason, User $user)
 Deletes the given entity in some underlying storage mechanism.
 
 userWasLastToEdit (User $user, EntityId $id, $lastRevId)
 Check if no edits were made by other users since the given revision.
 
 updateWatchlist (User $user, EntityId $id, $watch)
 Watches or unwatches the entity.
 
 isWatching (User $user, EntityId $id)
 Determines whether the given user is watching the given item.
 
 canCreateWithCustomId (EntityId $id)
 Whether an entity with the given custom ID can exist.
 

Private Attributes

 $entityStore
 
 $stats
 
 $timingPrefix
 

Detailed Description

EntityStore that collects stats for edit save times.

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore::__construct ( EntityStore $entityStore,
StatsdDataFactoryInterface $stats,
string $timingPrefix )
Parameters
EntityStore$entityStore
StatsdDataFactoryInterface$stats
string$timingPrefixResulting metric will be: $timingPrefix.saveEntity.<entitytype>

Member Function Documentation

◆ assignFreshId()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore::assignFreshId ( EntityDocument $entity)

Assigns a fresh ID to the given entity.

Note
The new ID is "consumed" after this method returns, and will not be assigned to another other entity. The next available ID for each kind of entity is considered part of the persistent state of the Wikibase installation.
calling this method on an Entity that already has an ID, and specifically calling this method twice on the same entity, shall result in an exception.
Parameters
EntityDocument$entity
Exceptions
StorageException

Implements Wikibase\Lib\Store\EntityStore.

◆ canCreateWithCustomId()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore::canCreateWithCustomId ( EntityId $id)

Whether an entity with the given custom ID can exist.

Implementations are not required to check if an entity with the given ID already exists. If this method returns true, this means that an entity with the given ID could be created (or already existed) at the time the method was called. There is no guarantee that this continues to be true after the method call returned. Callers must be careful to handle race conditions.

See also
EntityHandler::canCreateWithCustomId
Parameters
EntityId$id
Returns
bool

Implements Wikibase\Lib\Store\EntityStore.

◆ deleteEntity()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore::deleteEntity ( EntityId $entityId,
$reason,
User $user )

Deletes the given entity in some underlying storage mechanism.

Parameters
EntityId$entityId
string$reasonthe reason for deletion
User$user
Exceptions
StorageException
PermissionsError

Implements Wikibase\Lib\Store\EntityStore.

◆ isWatching()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore::isWatching ( User $user,
EntityId $id )

Determines whether the given user is watching the given item.

Todo
move this to a separate service
Parameters
User$user
EntityId$idthe entity to watch
Returns
bool

Implements Wikibase\Lib\Store\EntityStore.

◆ saveEntity()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore::saveEntity ( EntityDocument $entity,
$summary,
User $user,
$flags = 0,
$baseRevId = false,
array $tags = [] )

Saves the given Entity to some underlying storage mechanism.

Note
If the item does not have an ID yet (i.e. it was not yet created in the database), saveEntity() will fail with a edit-gone-missing message unless the EDIT_NEW bit is set in $flags. If EDIT_NEW is set and the Entity does not yet have an ID, a new ID is assigned using assignFreshId().
if the save is triggered by any kind of user interaction, consider using EditEntity::attemptSave(), which automatically handles edit conflicts, permission checks, etc.
Parameters
EntityDocument$entitythe entity to save.
string$summarythe edit summary for the new revision.
User$userthe user to whom to attribute the edit
int$flagsEDIT_XXX flags, as defined for WikiPage::doEditContent. Additionally, the EntityContent::EDIT_XXX constants can be used.
int | bool$baseRevIdthe revision ID $entity is based on. Saving should fail if $baseRevId is no longer the current revision.
string[]$tagsChange tags to add to the edit. Callers are responsible for permission checks (typically using ChangeTagsStore::canAddTagsAccompanyingChange).
See also
WikiPage::doEditContent
Returns
EntityRevision
Exceptions
StorageException
PermissionsError

Implements Wikibase\Lib\Store\EntityStore.

◆ saveRedirect()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore::saveRedirect ( EntityRedirect $redirect,
$summary,
User $user,
$flags = 0,
$baseRevId = false,
array $tags = [] )

Saves the given EntityRedirect to some underlying storage mechanism.

Parameters
EntityRedirect$redirectthe redirect to save.
string$summarythe edit summary for the new revision.
User$userthe user to whom to attribute the edit
int$flagsEDIT_XXX flags, as defined for WikiPage::doEditContent.
int | bool$baseRevIdthe revision ID $entity is based on. Saving should fail if $baseRevId is no longer the current revision.
string[]$tagsChange tags to add to the edit. Callers are responsible for permission checks (typically using ChangeTagsStore::canAddTagsAccompanyingChange).
See also
WikiPage::doEditContent
Returns
int The new revision ID
Exceptions
StorageException
PermissionsError

Implements Wikibase\Lib\Store\EntityStore.

◆ updateWatchlist()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore::updateWatchlist ( User $user,
EntityId $id,
$watch )

Watches or unwatches the entity.

Todo
move this to a separate service
Parameters
User$user
EntityId$idthe entity to watch
bool$watchwhether to watch or unwatch the page.
Returns
void

Implements Wikibase\Lib\Store\EntityStore.

◆ userWasLastToEdit()

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore::userWasLastToEdit ( User $user,
EntityId $id,
$lastRevId )

Check if no edits were made by other users since the given revision.

This makes the assumption that revision ids are monotonically increasing.

See also
\MediaWiki\EditPage\EditPage::userWasLastToEdit()
Parameters
User$user
EntityId$idthe entity to check
int$lastRevIdthe revision to check from
Returns
bool

Implements Wikibase\Lib\Store\EntityStore.

Member Data Documentation

◆ $entityStore

Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore::$entityStore
private

◆ $stats

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

◆ $timingPrefix

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

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