Merge "Add tags for undo edits"
[lhc/web/wiklou.git] / includes / Storage / RevisionFactory.php
1 <?php
2 /**
3 * Service for constructing revision objects.
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 MWException;
26 use Title;
27
28 /**
29 * Service for constructing revision objects.
30 *
31 * @since 1.31
32 *
33 * @note This was written to act as a drop-in replacement for the corresponding
34 * static methods in Revision.
35 */
36 interface RevisionFactory {
37
38 /**
39 * Constructs a new RevisionRecord based on the given associative array following the MW1.29
40 * database convention for the Revision constructor.
41 *
42 * MCR migration note: this replaces Revision::newFromRow
43 *
44 * @deprecated since 1.31. Use a MutableRevisionRecord instead.
45 *
46 * @param array $fields
47 * @param int $queryFlags Flags for lazy loading behavior, see IDBAccessObject::READ_XXX.
48 * @param Title|null $title
49 *
50 * @return MutableRevisionRecord
51 * @throws MWException
52 */
53 public function newMutableRevisionFromArray( array $fields, $queryFlags = 0, Title $title = null );
54
55 /**
56 * Constructs a RevisionRecord given a database row and content slots.
57 *
58 * MCR migration note: this replaces Revision::newFromRow for rows based on the
59 * revision, slot, and content tables defined for MCR since MW1.31.
60 *
61 * @param object $row A query result row as a raw object.
62 * Use RevisionStore::getQueryInfo() to build a query that yields the required fields.
63 * @param int $queryFlags Flags for lazy loading behavior, see IDBAccessObject::READ_XXX.
64 * @param Title|null $title
65 *
66 * @return RevisionRecord
67 */
68 public function newRevisionFromRow( $row, $queryFlags = 0, Title $title = null );
69
70 /**
71 * Make a fake revision object from an archive table row. This is queried
72 * for permissions or even inserted (as in Special:Undelete)
73 *
74 * MCR migration note: this replaces Revision::newFromArchiveRow
75 *
76 * @param object $row A query result row as a raw object.
77 * Use RevisionStore::getArchiveQueryInfo() to build a query that yields the
78 * required fields.
79 * @param int $queryFlags Flags for lazy loading behavior, see IDBAccessObject::READ_XXX.
80 * @param Title $title
81 * @param array $overrides An associative array that allows fields in $row to be overwritten.
82 * Keys in this array correspond to field names in $row without the "ar_" prefix, so
83 * $overrides['user'] will override $row->ar_user, etc.
84 *
85 * @return RevisionRecord
86 */
87 public function newRevisionFromArchiveRow(
88 $row,
89 $queryFlags = 0,
90 Title $title = null,
91 array $overrides = []
92 );
93
94 }