| 1 | <?php |
| 2 | /** |
| 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. |
| 7 | * |
| 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. |
| 12 | * |
| 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 |
| 17 | * |
| 18 | * @file |
| 19 | */ |
| 20 | |
| 21 | namespace MediaWiki\Page; |
| 22 | |
| 23 | use Wikimedia\Assert\PreconditionException; |
| 24 | |
| 25 | /** |
| 26 | * Interface for a page that is (or could be, or used to be) an editable wiki page. |
| 27 | * |
| 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. |
| 32 | * |
| 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. |
| 37 | * |
| 38 | * @see https://www.mediawiki.org/wiki/Manual:Modeling_pages |
| 39 | * |
| 40 | * @stable to type |
| 41 | * |
| 42 | * @since 1.36 |
| 43 | */ |
| 44 | interface ProperPageIdentity extends PageIdentity { |
| 45 | |
| 46 | /** |
| 47 | * Get the ID of the wiki this page belongs to. |
| 48 | * |
| 49 | * @see RevisionRecord::getWikiId() |
| 50 | * |
| 51 | * @return string|false The wiki's logical name, of false to indicate the local wiki. |
| 52 | */ |
| 53 | public function getWikiId(); |
| 54 | |
| 55 | /** |
| 56 | * Returns the page ID. |
| 57 | * Will return 0 if the page does not currently exist. |
| 58 | * |
| 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. |
| 64 | * |
| 65 | * @return int |
| 66 | */ |
| 67 | public function getId( $wikiId = self::LOCAL ): int; |
| 68 | |
| 69 | /** |
| 70 | * Get the page title in DB key form. |
| 71 | * |
| 72 | * This should always return a valid DB key. |
| 73 | * |
| 74 | * @return string |
| 75 | */ |
| 76 | public function getDBkey(): string; |
| 77 | |
| 78 | /** |
| 79 | * Always true. |
| 80 | * Implementations must ensure that no "improper" instances can be created. |
| 81 | * |
| 82 | * @return true |
| 83 | */ |
| 84 | public function canExist(): bool; |
| 85 | |
| 86 | } |