MediaWiki REL1_40
MediaWiki\Page\PageIdentityValue Class Reference

Immutable value object representing a page identity. More...

Inherits MediaWiki\Page\PageReferenceValue, and MediaWiki\Page\ProperPageIdentity.

Inherited by MediaWiki\Page\PageStoreRecord.

Collaboration diagram for MediaWiki\Page\PageIdentityValue:

Public Member Functions

 __construct (int $pageId, int $namespace, string $dbKey, $wikiId)
 
 canExist ()
 
 exists ()
 Returns whether the page currently exists.
 
 getId ( $wikiId=self::LOCAL)
 The numerical page ID provided to the constructor.
 
- Public Member Functions inherited from MediaWiki\Page\PageReferenceValue
 __construct (int $namespace, string $dbKey, $wikiId)
 
 __toString ()
 Returns a string representation of the title, for logging.
 
 getDBkey ()
 Get the page title in DB key form.
Note
This may return a string starting with a hash, if the PageReference represents the target of a block or unblock operation. This is due to the way the block target is represented in the logging table. This is intended to change in the future.
This may return an empty string, if this PageReference is a Title that represents a relative section link. This is intended to change in the future.
Returns
string

 
 getNamespace ()
 Returns the page's namespace number.The value returned by this method should represent a valid namespace, but this cannot be guaranteed in all cases.
Returns
int

 
 getWikiId ()
 Get the ID of the wiki provided to the constructor.
 
 isSamePageAs (PageReference $other)
 
- Public Member Functions inherited from MediaWiki\DAO\WikiAwareEntity
 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId().
 
- Public Member Functions inherited from MediaWiki\Page\ProperPageIdentity
 getDBkey ()
 Get the page title in DB key form.
 
 getWikiId ()
 Get the ID of the wiki this page belongs to.
 

Static Public Member Functions

static localIdentity (int $pageId, int $namespace, string $dbKey)
 Create PageIdentity for a local page.
 
static tryNew (int $pageId, int $namespace, string $dbKey, $wikiId)
 Constructs a PageIdentityValue, or returns null if the parameters are not valid.
 
- Static Public Member Functions inherited from MediaWiki\Page\PageReferenceValue
static localReference (int $namespace, string $dbKey)
 Create PageReference for a local page.
 

Detailed Description

Immutable value object representing a page identity.

Instances of this class are expected to always represent proper pages, that is, pages that can at least potentially exist as editable pages on the wiki. This class cannot represent Special pages, interwiki links, section links, etc.

Code that deserializes instances of PageIdentityValue must ensure that the original meaning of the "local" Wiki ID is preserved: When an instance of PageIdentityValue is created with self::LOCAL as the Wiki ID on one wiki, gets serialized, stored, and later read and unserialized on another wiki, the value of the Wiki ID must be adjusted to refer to the original wiki.

Since
1.36

Definition at line 41 of file PageIdentityValue.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Page\PageIdentityValue::__construct ( int $pageId,
int $namespace,
string $dbKey,
$wikiId )
Parameters
int$pageIdThe ID of this page, or 0 if the page does not exist.
int$namespaceA valid namespace ID. Validation is the caller's responsibility!
string$dbKeyA valid DB key. Validation is the caller's responsibility!
string | false$wikiIdThe Id of the wiki this page belongs to, or self::LOCAL for the local wiki.

Definition at line 76 of file PageIdentityValue.php.

Member Function Documentation

◆ canExist()

MediaWiki\Page\PageIdentityValue::canExist ( )
Returns
bool always true

Implements MediaWiki\Page\ProperPageIdentity.

Definition at line 129 of file PageIdentityValue.php.

◆ exists()

MediaWiki\Page\PageIdentityValue::exists ( )

Returns whether the page currently exists.

Returns true if getId() returns a value greater than zero.

Returns
bool

Implements MediaWiki\Page\PageIdentity.

Definition at line 122 of file PageIdentityValue.php.

◆ getId()

MediaWiki\Page\PageIdentityValue::getId ( $wikiId = self::LOCAL)

The numerical page ID provided to the constructor.

Parameters
string | false$wikiIdThe wiki ID expected by the caller. Omit if expecting the local wiki.
Returns
int

Implements MediaWiki\Page\ProperPageIdentity.

Definition at line 112 of file PageIdentityValue.php.

◆ localIdentity()

static MediaWiki\Page\PageIdentityValue::localIdentity ( int $pageId,
int $namespace,
string $dbKey )
static

Create PageIdentity for a local page.

Parameters
int$pageId
int$namespace
string$dbKey
Returns
PageIdentityValue

Definition at line 100 of file PageIdentityValue.php.

◆ tryNew()

static MediaWiki\Page\PageIdentityValue::tryNew ( int $pageId,
int $namespace,
string $dbKey,
$wikiId )
static

Constructs a PageIdentityValue, or returns null if the parameters are not valid.

Note
This does not perform any normalization, and only basic validation. For full normalization and validation, use TitleParser::makeTitleValueSafe() together with PageLookup::getPageForLink().
Parameters
int$pageIdThe ID of this page, or 0 if the page does not exist.
int$namespaceA valid namespace ID. Validation is the caller's responsibility!
string$dbKeyA valid DB key. Validation is the caller's responsibility!
string | false$wikiIdThe Id of the wiki this page belongs to, or self::LOCAL for the local wiki.
Returns
PageIdentityValue|null

Definition at line 61 of file PageIdentityValue.php.


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