MediaWiki master
MediaWiki\DAO\WikiAwareEntity Interface Reference

Marker interface for entities aware of the wiki they belong to. More...

Inherited by MediaWiki\Block\Block, MediaWiki\Page\PageReference, MediaWiki\Revision\RevisionRecord, and MediaWiki\User\UserIdentity.

Public Member Functions

 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId().
 
 getWikiId ()
 Get the ID of the wiki this page belongs to.
 

Detailed Description

Marker interface for entities aware of the wiki they belong to.

Instances of classes implementing this interface belong to a specific wiki and may be used in a cross-wiki context. Services using these classes have to ensure the entities they operate on belong to the correct wiki by calling assertWiki().

Additionally, some getters of implementing classes can take an optional $wikiId parameter to assert on for extra protection against incorrect cross-wiki access. The parameter should be added if using the property in the context of a wrong wiki will cause DB corruption. Usually the rule of thumb is fields which are commonly used as foreign keys, like page_id, rev_id, user_id, actor_id etc. However, the exact line is left to the best judgement of the implementers.

Examples: RevisionRecord::getId() or PageIdentity::getId()

See also
Block
PageIdentity
RevisionRecord
UserIdentity
Since
1.36

Definition at line 35 of file WikiAwareEntity.php.

Member Function Documentation

◆ assertWiki()

MediaWiki\DAO\WikiAwareEntity::assertWiki ( $wikiId)

Throws if $wikiId is different from the return value of getWikiId().

Parameters
string | false$wikiIdThe wiki ID expected by the caller. Use self::LOCAL for the local wiki.
Exceptions
PreconditionExceptionIf $wikiId is not the ID of the wiki this entity belongs to.

Referenced by WikiPage\__construct(), MediaWiki\User\UserGroupManager\clearCache(), ParserCache\deleteOptionsKey(), MediaWiki\Block\DatabaseBlockStore\doAutoblock(), ParserCache\get(), ParserCache\getDirty(), MediaWiki\Block\DatabaseBlockStore\insertBlock(), MediaWiki\User\UserGroupManager\loadGroupMembershipsFromArray(), ParserCache\save(), MediaWiki\Block\DatabaseBlockStore\updateBlock(), and MediaWiki\Block\DatabaseBlockStore\updateTimestamp().

◆ getWikiId()


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