blob: b8bf33e1da8c54bb3f802e178bcbe8f90151b5f6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<?php
namespace MediaWiki\DAO;
use MediaWiki\Page\PageIdentity;
use MediaWiki\Revision\RevisionRecord;
use MediaWiki\User\UserIdentity;
use Wikimedia\Assert\PreconditionException;
/**
* 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: {@link RevisionRecord::getId()} or {@link PageIdentity::getId()}
*
* @see Block
* @see PageIdentity
* @see RevisionRecord
* @see UserIdentity
*
* @since 1.36
*/
interface WikiAwareEntity {
/**
* @var bool Wiki ID value to use with instances that are
* defined relative to the local wiki.
*/
public const LOCAL = false;
/**
* Throws if $wikiId is different from the return value of getWikiId().
*
* @param string|false $wikiId The wiki ID expected by the caller.
* Use self::LOCAL for the local wiki.
*
* @throws PreconditionException If $wikiId is not the ID of the wiki this entity
* belongs to.
*/
public function assertWiki( $wikiId );
/**
* Get the ID of the wiki this page belongs to.
*
* @return string|false The wiki's logical name,
* or self::LOCAL to indicate the local wiki.
*/
public function getWikiId();
}
|