Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Lib\Store\EntityStore Interface Reference

Storage interface for Entities. More...

+ Inheritance diagram for Wikibase\Lib\Store\EntityStore:

Public Member Functions

 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.
 

Detailed Description

Storage interface for Entities.

See also
EntityLookup
EntityRevisionLookup
Author
Daniel Kinzler

Member Function Documentation

◆ assignFreshId()

Wikibase\Lib\Store\EntityStore::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

Implemented in Wikibase\Lib\Store\TypeDispatchingEntityStore, Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore, and Wikibase\Repo\Store\Sql\WikiPageEntityStore.

◆ canCreateWithCustomId()

Wikibase\Lib\Store\EntityStore::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

Implemented in Wikibase\Lib\Store\TypeDispatchingEntityStore, Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore, and Wikibase\Repo\Store\Sql\WikiPageEntityStore.

◆ deleteEntity()

Wikibase\Lib\Store\EntityStore::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

Implemented in Wikibase\Lib\Store\TypeDispatchingEntityStore, Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore, and Wikibase\Repo\Store\Sql\WikiPageEntityStore.

◆ isWatching()

Wikibase\Lib\Store\EntityStore::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

Implemented in Wikibase\Lib\Store\TypeDispatchingEntityStore, Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore, and Wikibase\Repo\Store\Sql\WikiPageEntityStore.

◆ saveEntity()

Wikibase\Lib\Store\EntityStore::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 ChangeTags::canAddTagsAccompanyingChange).
See also
WikiPage::doEditContent
Returns
EntityRevision
Exceptions
StorageException
PermissionsError

Implemented in Wikibase\Lib\Store\TypeDispatchingEntityStore, Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore, and Wikibase\Repo\Store\Sql\WikiPageEntityStore.

◆ saveRedirect()

Wikibase\Lib\Store\EntityStore::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 ChangeTags::canAddTagsAccompanyingChange).
See also
WikiPage::doEditContent
Returns
int The new revision ID
Exceptions
StorageException
PermissionsError

Implemented in Wikibase\Lib\Store\TypeDispatchingEntityStore, Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore, and Wikibase\Repo\Store\Sql\WikiPageEntityStore.

◆ updateWatchlist()

Wikibase\Lib\Store\EntityStore::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

Implemented in Wikibase\Lib\Store\TypeDispatchingEntityStore, Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore, and Wikibase\Repo\Store\Sql\WikiPageEntityStore.

◆ userWasLastToEdit()

Wikibase\Lib\Store\EntityStore::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

Implemented in Wikibase\Lib\Store\TypeDispatchingEntityStore, Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEntityStore, and Wikibase\Repo\Store\Sql\WikiPageEntityStore.


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