Merge "mw.Feedback: If the message is posted remotely, link the title correctly"
[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 * @param Title $title if known (optional)
88 *
89 * @return RevisionRecord|null
90 */
91 public function getPreviousRevision( RevisionRecord $rev, Title $title = null );
92
93 /**
94 * Get next revision for this title
95 *
96 * MCR migration note: this replaces Revision::getNext
97 *
98 * @param RevisionRecord $rev
99 * @param Title $title if known (optional)
100 *
101 * @return RevisionRecord|null
102 */
103 public function getNextRevision( RevisionRecord $rev, Title $title = null );
104
105 /**
106 * Load a revision based on a known page ID and current revision ID from the DB
107 *
108 * This method allows for the use of caching, though accessing anything that normally
109 * requires permission checks (aside from the text) will trigger a small DB lookup.
110 *
111 * MCR migration note: this replaces Revision::newKnownCurrent
112 *
113 * @param Title $title the associated page title
114 * @param int $revId current revision of this page
115 *
116 * @return RevisionRecord|bool Returns false if missing
117 */
118 public function getKnownCurrentRevision( Title $title, $revId );
119
120 }