MediaWiki REL1_39
MediaWiki\DAO\WikiAwareEntity Interface Reference

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

Inheritance diagram for MediaWiki\DAO\WikiAwareEntity:

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(), ParserCache\deleteOptionsKey(), ParserCache\get(), ParserCache\getDirty(), and ParserCache\save().

◆ getWikiId()

MediaWiki\DAO\WikiAwareEntity::getWikiId ( )

Get the ID of the wiki this page belongs to.

Returns
string|false The wiki's logical name, or self::LOCAL to indicate the local wiki.

Implemented in MediaWiki\Block\AbstractBlock, MediaWiki\Page\PageReference, MediaWiki\Page\PageReferenceValue, MediaWiki\Page\ProperPageIdentity, WikiPage, MediaWiki\Revision\RevisionRecord, Title, User, MediaWiki\User\UserIdentityValue, and UserRightsProxy.

Referenced by MediaWiki\User\ActorCache\add().


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