MediaWiki  master
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(). More...
 
 getWikiId ()
 Get the ID of the wiki this page belongs to. More...
 

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
PageIdentity
RevisionRecord
UserIdentity
Since
1.36

Definition at line 34 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\Permissions\RestrictionStore\areCascadeProtectionSourcesLoaded(), MediaWiki\Permissions\RestrictionStore\areRestrictionsCascading(), MediaWiki\Permissions\RestrictionStore\areRestrictionsLoaded(), Title\castFromPageReference(), MediaWiki\Permissions\RestrictionStore\deleteCreateProtection(), ParserCache\deleteOptionsKey(), MediaWiki\Revision\RevisionStore\findIdenticalRevision(), MediaWiki\Permissions\RestrictionStore\flushRestrictions(), ParserCache\get(), User\getActorId(), MediaWiki\Permissions\RestrictionStore\getAllRestrictions(), MediaWiki\Permissions\RestrictionStore\getCascadeProtectionSources(), MediaWiki\Permissions\RestrictionStore\getCreateProtection(), ParserCache\getDirty(), Page\PageIdentityValue\getId(), WikiPage\getId(), Title\getId(), Page\PageStoreRecord\getLatest(), WikiPage\getLatest(), ParserCache\getMetadata(), Page\PageStore\getPageByReference(), MediaWiki\Permissions\RestrictionStore\getRestrictionExpiry(), MediaWiki\Permissions\RestrictionStore\getRestrictions(), MediaWiki\Permissions\RestrictionStore\isCascadeProtected(), MediaWiki\Permissions\RestrictionStore\isProtected(), MediaWiki\Permissions\RestrictionStore\isSemiProtected(), MediaWiki\Permissions\RestrictionStore\listApplicableRestrictionTypes(), MediaWiki\Permissions\RestrictionStore\loadRestrictions(), MediaWiki\Permissions\RestrictionStore\loadRestrictionsFromRows(), MediaWiki\Permissions\RestrictionStore\registerOldRestrictions(), 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 UserRightsProxy, MediaWiki\User\UserIdentityValue, User, Title, MediaWiki\Revision\RevisionRecord, WikiPage, Page\ProperPageIdentity, Page\PageReferenceValue, and Page\PageReference.

Referenced by MediaWiki\User\ActorCache\add(), and MediaWiki\User\ActorStore\deprecateInvalidCrossWikiParam().


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