Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | /** |
3 | * This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. |
7 | * |
8 | * This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. |
12 | * |
13 | * You should have received a copy of the GNU General Public License along |
14 | * with this program; if not, write to the Free Software Foundation, Inc., |
15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
16 | * http://www.gnu.org/copyleft/gpl.html |
17 | * |
18 | * @file |
19 | */ |
20 | |
21 | namespace MediaWiki\Storage; |
22 | |
23 | use StatusValue; |
24 | |
25 | /** |
26 | * Service for loading and storing data blobs. |
27 | * |
28 | * @note This was written to act as a drop-in replacement for the corresponding |
29 | * static methods in the old Revision class (which was later removed in 1.37). |
30 | * |
31 | * @since 1.31 |
32 | */ |
33 | interface BlobStore { |
34 | |
35 | /** |
36 | * Hint key for use with storeBlob, indicating the general role the block |
37 | * takes in the application. For instance, it should be "page-content" if |
38 | * the blob represents a Content object. |
39 | */ |
40 | public const DESIGNATION_HINT = 'designation'; |
41 | |
42 | /** |
43 | * Hint key for use with storeBlob, indicating the page the blob is associated with. |
44 | * This may be used for sharding. |
45 | */ |
46 | public const PAGE_HINT = 'page_id'; |
47 | |
48 | /** |
49 | * Hint key for use with storeBlob, indicating the slot the blob is associated with. |
50 | * May be relevant for reference counting. |
51 | */ |
52 | public const ROLE_HINT = 'role_name'; |
53 | |
54 | /** |
55 | * Hint key for use with storeBlob, indicating the revision the blob is associated with. |
56 | * This may be used for differential storage and reference counting. |
57 | */ |
58 | public const REVISION_HINT = 'rev_id'; |
59 | |
60 | /** |
61 | * Hint key for use with storeBlob, indicating the parent revision of the revision |
62 | * the blob is associated with. This may be used for differential storage. |
63 | */ |
64 | public const PARENT_HINT = 'rev_parent_id'; |
65 | |
66 | /** |
67 | * Hint key for use with storeBlob, providing the SHA1 hash of the blob as passed to the |
68 | * method. This can be used to avoid re-calculating the hash if it is needed by the BlobStore. |
69 | */ |
70 | public const SHA1_HINT = 'cont_sha1'; |
71 | |
72 | /** |
73 | * Hint key for use with storeBlob, indicating the model of the content encoded in the |
74 | * given blob. May be used to implement optimized storage for some well known models. |
75 | */ |
76 | public const MODEL_HINT = 'cont_model'; |
77 | |
78 | /** |
79 | * Hint key for use with storeBlob, indicating the serialization format used to create |
80 | * the blob, as a MIME type. May be used for optimized storage in the underlying database. |
81 | */ |
82 | public const FORMAT_HINT = 'cont_format'; |
83 | |
84 | /** |
85 | * Hint key for an image name. |
86 | */ |
87 | public const IMAGE_HINT = 'img_name'; |
88 | |
89 | /** |
90 | * Retrieve a blob, given an address. |
91 | * |
92 | * MCR migration note: this replaced Revision::loadText |
93 | * |
94 | * @param string $blobAddress The blob address as returned by storeBlob(), |
95 | * such as "tt:12345" or "ex:DB://s16/456/9876". |
96 | * @param int $queryFlags See IDBAccessObject. |
97 | * |
98 | * @throws BlobAccessException |
99 | * @return string binary blob data |
100 | */ |
101 | public function getBlob( $blobAddress, $queryFlags = 0 ); |
102 | |
103 | /** |
104 | * A batched version of BlobStore::getBlob. |
105 | * |
106 | * @param string[] $blobAddresses An array of blob addresses. |
107 | * @param int $queryFlags See IDBAccessObject. |
108 | * @throws BlobAccessException |
109 | * @return StatusValue A status with a map of blobAddress => binary blob data or null |
110 | * if fetching the blob has failed. Fetch failures errors are the |
111 | * warnings in the status object. |
112 | * @since 1.34 |
113 | */ |
114 | public function getBlobBatch( $blobAddresses, $queryFlags = 0 ); |
115 | |
116 | /** |
117 | * Stores an arbitrary blob of data and returns an address that can be used with |
118 | * getBlob() to retrieve the same blob of data, |
119 | * |
120 | * @param string $data raw binary data |
121 | * @param array $hints An array of hints. Implementations may use the hints to optimize storage. |
122 | * All hints are optional, supported hints depend on the implementation. Hint names by |
123 | * convention correspond to the names of fields in the database. Callers are encouraged to |
124 | * provide the well known hints as defined by the XXX_HINT constants. |
125 | * |
126 | * @throws BlobAccessException |
127 | * @return string an address that can be used with getBlob() to retrieve the data. |
128 | */ |
129 | public function storeBlob( $data, $hints = [] ); |
130 | |
131 | /** |
132 | * Check if the blob metadata or backing blob data store is read-only |
133 | * |
134 | * @return bool |
135 | */ |
136 | public function isReadOnly(); |
137 | } |