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\Block\BlockTarget, MediaWiki\Block\BlockTargetFactory, 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.
 

Public Attributes

const LOCAL = false
 Wiki ID value to use with instances that are defined relative to the local wiki.
 

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)

◆ getWikiId()

Member Data Documentation

◆ LOCAL

const MediaWiki\DAO\WikiAwareEntity::LOCAL = false

Wiki ID value to use with instances that are defined relative to the local wiki.

Note
The value false is hardcoded in many type declarations and it cannot therefore be changed. Nonetheless, code outside of type declarations should not rely on it.

Definition at line 42 of file WikiAwareEntity.php.

Referenced by MediaWiki\Block\AbstractBlock\__construct(), MediaWiki\Page\WikiPage\__construct(), MediaWiki\Block\BlockUtilsFactory\getBlockUtils(), MediaWiki\Block\DatabaseBlockStoreFactory\getDatabaseBlockStore(), MediaWiki\User\UserGroupManagerFactory\getUserGroupManager(), and MediaWiki\User\UserEditTracker\preloadUserEditCountCache().


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