Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\Store\Sql\WikiPageEntityStore Class Reference

EntityStore implementation based on WikiPage. More...

+ Inheritance diagram for Wikibase\Repo\Store\Sql\WikiPageEntityStore:
+ Collaboration diagram for Wikibase\Repo\Store\Sql\WikiPageEntityStore:

Public Member Functions

 __construct (EntityContentFactory $contentFactory, EntityTitleStoreLookup $entityTitleStoreLookup, IdGenerator $idGenerator, EntityIdComposer $entityIdComposer, RevisionStore $revisionStore, DatabaseEntitySource $entitySource, ActorNormalization $actorNormalization, PermissionManager $permissionManager, WatchlistManager $watchlistManager, WikiPageFactory $wikiPageFactory, RepoDomainDb $repoDomainDb)
 
 assignFreshId (EntityDocument $entity)
 
 canCreateWithCustomId (EntityId $id)
 
 registerWatcher (EntityStoreWatcher $watcher)
 Registers a watcher that will be notified whenever an entity is updated or deleted.
 
 getWikiPageForEntity (EntityId $entityId)
 Returns the WikiPage object for the item with provided entity.
 
 saveEntity (EntityDocument $entity, $summary, User $user, $flags=0, $baseRevId=false, array $tags=[])
 
 saveRedirect (EntityRedirect $redirect, $summary, User $user, $flags=0, $baseRevId=false, array $tags=[])
 
 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.
 

Private Member Functions

 assertCanStoreEntity (EntityId $id)
 
 assertEntityIdFromKnownSource (EntityId $id)
 
 entityIdFromKnownSource (EntityId $id)
 
 saveEntityContent (EntityContent $entityContent, User $user, $summary='', $flags=0, $baseRevId=false, array $tags=[])
 Saves the entity.
 
 adjustFlagsForMCR ( $flags, $parentRevision, $slotRole)
 
 getTitleForEntity (EntityId $entityId)
 

Private Attributes

 $contentFactory
 
 $entityTitleStoreLookup
 
 $idGenerator
 
 $dispatcher
 
 $entityIdComposer
 
 $revisionStore
 
 $entitySource
 
ActorNormalization $actorNormalization
 
 $permissionManager
 
 $watchlistManager
 
 $wikiPageFactory
 
 $db
 

Detailed Description

EntityStore implementation based on WikiPage.

For more information on the relationship between entities and wiki pages, see docs/entity-storage.wiki.

Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::__construct ( EntityContentFactory $contentFactory,
EntityTitleStoreLookup $entityTitleStoreLookup,
IdGenerator $idGenerator,
EntityIdComposer $entityIdComposer,
RevisionStore $revisionStore,
DatabaseEntitySource $entitySource,
ActorNormalization $actorNormalization,
PermissionManager $permissionManager,
WatchlistManager $watchlistManager,
WikiPageFactory $wikiPageFactory,
RepoDomainDb $repoDomainDb )
Parameters
EntityContentFactory$contentFactory
EntityTitleStoreLookup$entityTitleStoreLookup
IdGenerator$idGenerator
EntityIdComposer$entityIdComposer
RevisionStore$revisionStoreA RevisionStore for the local database.
DatabaseEntitySource$entitySource
ActorNormalization$actorNormalization
PermissionManager$permissionManager
WatchlistManager$watchlistManager
WikiPageFactory$wikiPageFactory
RepoDomainDb$repoDomainDb

Member Function Documentation

◆ adjustFlagsForMCR()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::adjustFlagsForMCR ( $flags,
$parentRevision,
$slotRole )
private
Parameters
int$flags
RevisionRecord | null$parentRevision
string$slotRole
Returns
int
Exceptions
StorageException

If the flags indicate a new edit, and the page already exists and we are interacting with a slot other than the main slot, adjust the slots for the MCR save. If we are interacting with the main slot, keep the NEW flag. This is consistent with previous behaviour.

◆ assertCanStoreEntity()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::assertCanStoreEntity ( EntityId $id)
private

◆ assertEntityIdFromKnownSource()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::assertEntityIdFromKnownSource ( EntityId $id)
private

◆ assignFreshId()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::assignFreshId ( EntityDocument $entity)
See also
EntityStore::assignFreshId()
Parameters
EntityDocument$entity
Exceptions
StorageException
InvalidArgumentException

Implements Wikibase\Lib\Store\EntityStore.

◆ canCreateWithCustomId()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::canCreateWithCustomId ( EntityId $id)
See also
EntityStore::canCreateWithCustomId
Parameters
EntityId$id
Exceptions
StorageException
Returns
bool

Implements Wikibase\Lib\Store\EntityStore.

◆ deleteEntity()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::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
InvalidArgumentException
StorageException

Implements Wikibase\Lib\Store\EntityStore.

◆ entityIdFromKnownSource()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::entityIdFromKnownSource ( EntityId $id)
private

◆ getTitleForEntity()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::getTitleForEntity ( EntityId $entityId)
private
See also
EntityTitleStoreLookup::getTitleForId
Parameters
EntityId$entityId
Returns
Title|null

◆ getWikiPageForEntity()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::getWikiPageForEntity ( EntityId $entityId)

Returns the WikiPage object for the item with provided entity.

Parameters
EntityId$entityId
Exceptions
InvalidArgumentException
StorageException
Returns
WikiPage

◆ isWatching()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::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
Exceptions
InvalidArgumentExceptionfor foreign EntityIds as watching foreign entities is not yet supported
Returns
bool

Implements Wikibase\Lib\Store\EntityStore.

◆ registerWatcher()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::registerWatcher ( EntityStoreWatcher $watcher)

Registers a watcher that will be notified whenever an entity is updated or deleted.

Parameters
EntityStoreWatcher$watcher

◆ saveEntity()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::saveEntity ( EntityDocument $entity,
$summary,
User $user,
$flags = 0,
$baseRevId = false,
array $tags = [] )
See also
EntityStore::saveEntity
WikiPage::doEditContent
Parameters
EntityDocument$entity
string$summary
User$user
int$flags
int | bool$baseRevId
string[]$tags
Exceptions
InvalidArgumentException
StorageException
Returns
EntityRevision

Implements Wikibase\Lib\Store\EntityStore.

◆ saveEntityContent()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::saveEntityContent ( EntityContent $entityContent,
User $user,
$summary = '',
$flags = 0,
$baseRevId = false,
array $tags = [] )
private

Saves the entity.

If the corresponding page does not exist yet, it will be created (ie a new ID will be determined and a new page in the data NS created).

Note
this method should not be overloaded, and should not be extended to save additional information to the database. Such things should be done in a way that will also be triggered when the save is performed by calling WikiPage::doEditContent.
See also
WikiPage::doEditContent
Parameters
EntityContent$entityContentthe entity to save.
User$user
string$summary
int$flagsFlags as used by WikiPage::doEditContent, use EDIT_XXX constants.
int | bool$baseRevId
string[]$tags
Exceptions
StorageException
Returns
RevisionRecord The new revision (or the latest one, in case of a null edit).
Note
Make sure we start saving from a clean slate. Calling WikiPage::clearPreparedEdit may cause the old content to be loaded from the database again. This may be necessary, because EntityContent is mutable, so the cached object might have changed.
Todo
Might be able to further optimize handling of prepared edit in WikiPage.
Todo
Todo
now we use PageUpdater do we still need the 2 clear calls below?

◆ saveRedirect()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::saveRedirect ( EntityRedirect $redirect,
$summary,
User $user,
$flags = 0,
$baseRevId = false,
array $tags = [] )
See also
EntityStore::saveRedirect
WikiPage::doEditContent
Parameters
EntityRedirect$redirect
string$summary
User$user
int$flags
int | bool$baseRevId
string[]$tags
Exceptions
InvalidArgumentException
StorageException
Returns
int The new revision ID

Implements Wikibase\Lib\Store\EntityStore.

◆ updateWatchlist()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::updateWatchlist ( User $user,
EntityId $id,
$watch )

Watches or unwatches the entity.

Parameters
User$user
EntityId$idthe entity to watch
bool$watchwhether to watch or unwatch the page.
Exceptions
InvalidArgumentException
Note
keep in sync with logic in \MediaWiki\EditPage\EditPage

Implements Wikibase\Lib\Store\EntityStore.

◆ userWasLastToEdit()

Wikibase\Repo\Store\Sql\WikiPageEntityStore::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 (ignored by this implementation)
int$lastRevIdthe revision the user supplied
Exceptions
InvalidArgumentException
Returns
bool

Implements Wikibase\Lib\Store\EntityStore.

Member Data Documentation

◆ $actorNormalization

ActorNormalization Wikibase\Repo\Store\Sql\WikiPageEntityStore::$actorNormalization
private

◆ $contentFactory

Wikibase\Repo\Store\Sql\WikiPageEntityStore::$contentFactory
private

◆ $db

Wikibase\Repo\Store\Sql\WikiPageEntityStore::$db
private

◆ $dispatcher

Wikibase\Repo\Store\Sql\WikiPageEntityStore::$dispatcher
private

◆ $entityIdComposer

Wikibase\Repo\Store\Sql\WikiPageEntityStore::$entityIdComposer
private

◆ $entitySource

Wikibase\Repo\Store\Sql\WikiPageEntityStore::$entitySource
private

◆ $entityTitleStoreLookup

Wikibase\Repo\Store\Sql\WikiPageEntityStore::$entityTitleStoreLookup
private

◆ $idGenerator

Wikibase\Repo\Store\Sql\WikiPageEntityStore::$idGenerator
private

◆ $permissionManager

Wikibase\Repo\Store\Sql\WikiPageEntityStore::$permissionManager
private

◆ $revisionStore

Wikibase\Repo\Store\Sql\WikiPageEntityStore::$revisionStore
private

◆ $watchlistManager

Wikibase\Repo\Store\Sql\WikiPageEntityStore::$watchlistManager
private

◆ $wikiPageFactory

Wikibase\Repo\Store\Sql\WikiPageEntityStore::$wikiPageFactory
private

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