Merge "maintenance: Script to rename titles for Unicode uppercasing changes"
[lhc/web/wiklou.git] / includes / Revision / 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\Revision;
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 * @since 1.32 Renamed from MediaWiki\Storage\RevisionLookup
37 */
38 interface RevisionLookup extends IDBAccessObject {
39
40 /**
41 * Load a page revision from a given revision ID number.
42 * Returns null if no such revision can be found.
43 *
44 * MCR migration note: this replaces Revision::newFromId
45 *
46 * $flags include:
47 *
48 * @param int $id
49 * @param int $flags bit field, see IDBAccessObject::READ_XXX
50 * @return RevisionRecord|null
51 */
52 public function getRevisionById( $id, $flags = 0 );
53
54 /**
55 * Load either the current, or a specified, revision
56 * that's attached to a given link target. If not attached
57 * to that link target, will return null.
58 *
59 * MCR migration note: this replaces Revision::newFromTitle
60 *
61 * @param LinkTarget $linkTarget
62 * @param int $revId (optional)
63 * @param int $flags bit field, see IDBAccessObject::READ_XXX
64 * @return RevisionRecord|null
65 */
66 public function getRevisionByTitle( LinkTarget $linkTarget, $revId = 0, $flags = 0 );
67
68 /**
69 * Load either the current, or a specified, revision
70 * that's attached to a given page ID.
71 * Returns null if no such revision can be found.
72 *
73 * MCR migration note: this replaces Revision::newFromPageId
74 *
75 * @param int $pageId
76 * @param int $revId (optional)
77 * @param int $flags bit field, see IDBAccessObject::READ_XXX
78 * @return RevisionRecord|null
79 */
80 public function getRevisionByPageId( $pageId, $revId = 0, $flags = 0 );
81
82 /**
83 * Get previous revision for this title
84 *
85 * MCR migration note: this replaces Revision::getPrevious
86 *
87 * @param RevisionRecord $rev
88 * @param int $flags (optional) $flags include:
89 * IDBAccessObject::READ_LATEST: Select the data from the master
90 *
91 * @return RevisionRecord|null
92 */
93 public function getPreviousRevision( RevisionRecord $rev, $flags = 0 );
94
95 /**
96 * Get next revision for this title
97 *
98 * MCR migration note: this replaces Revision::getNext
99 *
100 * @param RevisionRecord $rev
101 * @param int $flags (optional) $flags include:
102 * IDBAccessObject::READ_LATEST: Select the data from the master
103 *
104 * @return RevisionRecord|null
105 */
106 public function getNextRevision( RevisionRecord $rev, $flags = 0 );
107
108 /**
109 * Get rev_timestamp from rev_id, without loading the rest of the row.
110 *
111 * MCR migration note: this replaces Revision::getTimestampFromId
112 *
113 * @param int $id
114 * @param int $flags
115 * @return string|bool False if not found
116 * @since 1.34 (present earlier in RevisionStore)
117 */
118 public function getTimestampFromId( $id, $flags = 0 );
119
120 /**
121 * Load a revision based on a known page ID and current revision ID from the DB
122 *
123 * This method allows for the use of caching, though accessing anything that normally
124 * requires permission checks (aside from the text) will trigger a small DB lookup.
125 *
126 * MCR migration note: this replaces Revision::newKnownCurrent
127 *
128 * @param Title $title the associated page title
129 * @param int $revId current revision of this page
130 *
131 * @return RevisionRecord|bool Returns false if missing
132 */
133 public function getKnownCurrentRevision( Title $title, $revId );
134
135 }
136
137 /**
138 * Retain the old class name for backwards compatibility.
139 * @deprecated since 1.32
140 */
141 class_alias( RevisionLookup::class, 'MediaWiki\Storage\RevisionLookup' );