Merge "mw.rcfilters.ui.SaveFiltersPopupButtonWidget: Remove pointless option"
[lhc/web/wiklou.git] / includes / Storage / RevisionLookup.php
1 <?php
2 /**
3 * Service for looking up page revisions.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 namespace MediaWiki\Storage;
24
25 use \IDBAccessObject;
26 use MediaWiki\Linker\LinkTarget;
27 use Title;
28
29 /**
30 * Service for looking up page revisions.
31 *
32 * @note This was written to act as a drop-in replacement for the corresponding
33 * static methods in Revision.
34 *
35 * @since 1.31
36 */
37 interface RevisionLookup extends IDBAccessObject {
38
39 /**
40 * Load a page revision from a given revision ID number.
41 * Returns null if no such revision can be found.
42 *
43 * MCR migration note: this replaces Revision::newFromId
44 *
45 * $flags include:
46 *
47 * @param int $id
48 * @param int $flags bit field, see IDBAccessObject::READ_XXX
49 * @return RevisionRecord|null
50 */
51 public function getRevisionById( $id, $flags = 0 );
52
53 /**
54 * Load either the current, or a specified, revision
55 * that's attached to a given link target. If not attached
56 * to that link target, will return null.
57 *
58 * MCR migration note: this replaces Revision::newFromTitle
59 *
60 * @param LinkTarget $linkTarget
61 * @param int $revId (optional)
62 * @param int $flags bit field, see IDBAccessObject::READ_XXX
63 * @return RevisionRecord|null
64 */
65 public function getRevisionByTitle( LinkTarget $linkTarget, $revId = 0, $flags = 0 );
66
67 /**
68 * Load either the current, or a specified, revision
69 * that's attached to a given page ID.
70 * Returns null if no such revision can be found.
71 *
72 * MCR migration note: this replaces Revision::newFromPageId
73 *
74 * @param int $pageId
75 * @param int $revId (optional)
76 * @param int $flags bit field, see IDBAccessObject::READ_XXX
77 * @return RevisionRecord|null
78 */
79 public function getRevisionByPageId( $pageId, $revId = 0, $flags = 0 );
80
81 /**
82 * Get previous revision for this title
83 *
84 * MCR migration note: this replaces Revision::getPrevious
85 *
86 * @param RevisionRecord $rev
87 *
88 * @return RevisionRecord|null
89 */
90 public function getPreviousRevision( RevisionRecord $rev );
91
92 /**
93 * Get next revision for this title
94 *
95 * MCR migration note: this replaces Revision::getNext
96 *
97 * @param RevisionRecord $rev
98 *
99 * @return RevisionRecord|null
100 */
101 public function getNextRevision( RevisionRecord $rev );
102
103 /**
104 * Load a revision based on a known page ID and current revision ID from the DB
105 *
106 * This method allows for the use of caching, though accessing anything that normally
107 * requires permission checks (aside from the text) will trigger a small DB lookup.
108 *
109 * MCR migration note: this replaces Revision::newKnownCurrent
110 *
111 * @param Title $title the associated page title
112 * @param int $revId current revision of this page
113 *
114 * @return RevisionRecord|bool Returns false if missing
115 */
116 public function getKnownCurrentRevision( Title $title, $revId );
117
118 }