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