3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
21 namespace MediaWiki\Page
;
23 use Wikimedia\Assert\PreconditionException
;
26 * Interface for a page that is (or could be, or used to be) an editable wiki page.
28 * @note In contrast to PageIdentity, a ProperPageIdentity is guaranteed to
29 * represent an actual editable (or creatable) page. Eventually,
30 * PageIdentity is intended to adopt the same contract. At that point,
31 * ProperPageIdentity may become an alias for PageIdentity.
33 * @note For compatibility with the WikiPage class, ProperPageIdentity instances
34 * may be mutable, and return different values from methods such as getId() or exist()
35 * at different times. In the future, the contract of this interface is intended
36 * to be changed to disallow this.
38 * @see https://www.mediawiki.org/wiki/Manual:Modeling_pages
44 interface ProperPageIdentity
extends PageIdentity
{
47 * Get the ID of the wiki this page belongs to.
49 * @see RevisionRecord::getWikiId()
51 * @return string|false The wiki's logical name, of false to indicate the local wiki.
53 public function getWikiId();
56 * Returns the page ID.
57 * Will return 0 if the page does not currently exist.
59 * @param string|false $wikiId Must be provided when accessing the ID of a non-local
60 * PageIdentity, to prevent data corruption when using a PageIdentity belonging
61 * to one wiki in the context of another. Should be omitted if expecting the local wiki.
62 * @throws PreconditionException if this PageIdentity does not belong to the wiki
63 * identified by $wikiId.
67 public function getId( $wikiId = self
::LOCAL
): int;
70 * Get the page title in DB key form.
72 * This should always return a valid DB key.
76 public function getDBkey(): string;
80 * Implementations must ensure that no "improper" instances can be created.
84 public function canExist(): bool;