@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | * @return DumpMetaInformation[] |
29 | 29 | * @throws InvalidArgumentException |
30 | 30 | */ |
31 | - public function getWithIds( array $dumpIds ) { |
|
32 | - if ( $dumpIds === [] ) { |
|
31 | + public function getWithIds(array $dumpIds) { |
|
32 | + if ($dumpIds === []) { |
|
33 | 33 | return []; |
34 | 34 | } |
35 | 35 | |
36 | - foreach ( $dumpIds as $dumpId ) { |
|
37 | - if ( !is_string( $dumpId ) ) { |
|
38 | - throw new InvalidArgumentException( '$dumpIds must contain only strings.' ); |
|
36 | + foreach ($dumpIds as $dumpId) { |
|
37 | + if (!is_string($dumpId)) { |
|
38 | + throw new InvalidArgumentException('$dumpIds must contain only strings.'); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | |
42 | - $db = wfGetDB( DB_REPLICA ); |
|
42 | + $db = wfGetDB(DB_REPLICA); |
|
43 | 43 | $result = $db->select( |
44 | 44 | [ |
45 | 45 | self::META_TABLE_NAME, |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ] |
60 | 60 | ); |
61 | 61 | |
62 | - return $this->buildDumpMetaInformationFromResult( $result ); |
|
62 | + return $this->buildDumpMetaInformationFromResult($result); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -71,20 +71,20 @@ discard block |
||
71 | 71 | * @throws InvalidArgumentException |
72 | 72 | * @return DumpMetaInformation[] |
73 | 73 | */ |
74 | - public function getWithIdentifierProperties( array $identifierPropertyIds ) { |
|
75 | - if ( $identifierPropertyIds === [] ) { |
|
74 | + public function getWithIdentifierProperties(array $identifierPropertyIds) { |
|
75 | + if ($identifierPropertyIds === []) { |
|
76 | 76 | return []; |
77 | 77 | } |
78 | 78 | |
79 | - foreach ( $identifierPropertyIds as $propertyId ) { |
|
80 | - if ( !( $propertyId instanceof PropertyId ) ) { |
|
81 | - throw new InvalidArgumentException( '$identifierProperties must contain only PropertyIds.' ); |
|
79 | + foreach ($identifierPropertyIds as $propertyId) { |
|
80 | + if (!($propertyId instanceof PropertyId)) { |
|
81 | + throw new InvalidArgumentException('$identifierProperties must contain only PropertyIds.'); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | - $db = wfGetDB( DB_REPLICA ); |
|
85 | + $db = wfGetDB(DB_REPLICA); |
|
86 | 86 | $identifierPropertyIds = array_map( |
87 | - function( PropertyId $id ) { |
|
87 | + function(PropertyId $id) { |
|
88 | 88 | return $id->getSerialization(); |
89 | 89 | }, |
90 | 90 | $identifierPropertyIds |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | ] |
98 | 98 | ); |
99 | 99 | $dumpIds = []; |
100 | - foreach ( $result as $row ) { |
|
101 | - if ( !in_array( $row->dump_id, $dumpIds ) ) { |
|
100 | + foreach ($result as $row) { |
|
101 | + if (!in_array($row->dump_id, $dumpIds)) { |
|
102 | 102 | $dumpIds[] = $row->dump_id; |
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | - return $this->getWithIds( $dumpIds ); |
|
106 | + return $this->getWithIds($dumpIds); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @return DumpMetaInformation[] |
114 | 114 | */ |
115 | 115 | public function getAll() { |
116 | - $db = wfGetDB( DB_REPLICA ); |
|
116 | + $db = wfGetDB(DB_REPLICA); |
|
117 | 117 | $result = $db->select( |
118 | 118 | [ |
119 | 119 | self::META_TABLE_NAME, |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | ] |
132 | 132 | ); |
133 | 133 | |
134 | - return $this->buildDumpMetaInformationFromResult( $result ); |
|
134 | + return $this->buildDumpMetaInformationFromResult($result); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -139,34 +139,34 @@ discard block |
||
139 | 139 | * @return null|array |
140 | 140 | * @throws UnexpectedValueException |
141 | 141 | */ |
142 | - private function buildDumpMetaInformationFromResult( IResultWrapper $result ) { |
|
142 | + private function buildDumpMetaInformationFromResult(IResultWrapper $result) { |
|
143 | 143 | $aggregatedRows = []; |
144 | - foreach ( $result as $row ) { |
|
145 | - if ( array_key_exists( $row->id, $aggregatedRows ) ) { |
|
146 | - $propertyId = new PropertyId( $row->identifier_pid ); |
|
144 | + foreach ($result as $row) { |
|
145 | + if (array_key_exists($row->id, $aggregatedRows)) { |
|
146 | + $propertyId = new PropertyId($row->identifier_pid); |
|
147 | 147 | $aggregatedRows[$row->id]->identifier_pid[] = $propertyId; |
148 | 148 | } else { |
149 | - if ( $row->identifier_pid !== null ) { |
|
150 | - $propertyId = new PropertyId( $row->identifier_pid ); |
|
151 | - $row->identifier_pid = [ $propertyId ]; |
|
149 | + if ($row->identifier_pid !== null) { |
|
150 | + $propertyId = new PropertyId($row->identifier_pid); |
|
151 | + $row->identifier_pid = [$propertyId]; |
|
152 | 152 | } |
153 | 153 | $aggregatedRows[$row->id] = $row; |
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | 157 | $dumpMetaInformation = []; |
158 | - foreach ( $aggregatedRows as $row ) { |
|
158 | + foreach ($aggregatedRows as $row) { |
|
159 | 159 | $dumpId = $row->id; |
160 | - $sourceItemId = new ItemId( $row->source_qid ); |
|
161 | - $importDate = wfTimestamp( TS_MW, $row->import_date ); |
|
160 | + $sourceItemId = new ItemId($row->source_qid); |
|
161 | + $importDate = wfTimestamp(TS_MW, $row->import_date); |
|
162 | 162 | $language = $row->language; |
163 | 163 | $sourceUrl = $row->source_url; |
164 | 164 | $size = (int)$row->size; |
165 | - $licenseItemId = new ItemId( $row->license_qid ); |
|
165 | + $licenseItemId = new ItemId($row->license_qid); |
|
166 | 166 | $identifierPropertyIds = $row->identifier_pid; |
167 | 167 | |
168 | 168 | $dumpMetaInformation[$row->dump_id] = |
169 | - new DumpMetaInformation( $dumpId, |
|
169 | + new DumpMetaInformation($dumpId, |
|
170 | 170 | $sourceItemId, |
171 | 171 | $identifierPropertyIds, |
172 | 172 | $importDate, |
@@ -185,22 +185,22 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @param DumpMetaInformation $dumpMetaInformation |
187 | 187 | */ |
188 | - public function save( DumpMetaInformation $dumpMetaInformation ) { |
|
189 | - $db = wfGetDB( DB_REPLICA ); |
|
188 | + public function save(DumpMetaInformation $dumpMetaInformation) { |
|
189 | + $db = wfGetDB(DB_REPLICA); |
|
190 | 190 | $dumpId = $dumpMetaInformation->getDumpId(); |
191 | - $accumulator = $this->getDumpInformationFields( $db, $dumpMetaInformation ); |
|
191 | + $accumulator = $this->getDumpInformationFields($db, $dumpMetaInformation); |
|
192 | 192 | |
193 | 193 | $existing = $db->selectRow( |
194 | 194 | self::META_TABLE_NAME, |
195 | - [ 'id' ], |
|
196 | - [ 'id' => $dumpId ] |
|
195 | + ['id'], |
|
196 | + ['id' => $dumpId] |
|
197 | 197 | ); |
198 | 198 | |
199 | - if ( $existing ) { |
|
199 | + if ($existing) { |
|
200 | 200 | $db->update( |
201 | 201 | self::META_TABLE_NAME, |
202 | 202 | $accumulator, |
203 | - [ 'id' => $dumpId ] |
|
203 | + ['id' => $dumpId] |
|
204 | 204 | ); |
205 | 205 | } else { |
206 | 206 | $db->insert( |
@@ -211,12 +211,12 @@ discard block |
||
211 | 211 | |
212 | 212 | $db->delete( |
213 | 213 | self::IDENTIFIER_PROPERTIES_TABLE_NAME, |
214 | - [ 'dump_id' => $dumpId ] |
|
214 | + ['dump_id' => $dumpId] |
|
215 | 215 | ); |
216 | 216 | $db->insert( |
217 | 217 | self::IDENTIFIER_PROPERTIES_TABLE_NAME, |
218 | 218 | array_map( |
219 | - function ( PropertyId $identifierPropertyId ) use ( $dumpId ) { |
|
219 | + function(PropertyId $identifierPropertyId) use ($dumpId) { |
|
220 | 220 | return [ |
221 | 221 | 'dump_id' => $dumpId, |
222 | 222 | 'identifier_pid' => $identifierPropertyId->getSerialization() |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | * @param DumpMetaInformation $dumpMetaInformation |
233 | 233 | * @return array |
234 | 234 | */ |
235 | - private function getDumpInformationFields( IDatabase $db, DumpMetaInformation $dumpMetaInformation ) { |
|
235 | + private function getDumpInformationFields(IDatabase $db, DumpMetaInformation $dumpMetaInformation) { |
|
236 | 236 | return [ |
237 | 237 | 'id' => $dumpMetaInformation->getDumpId(), |
238 | 238 | 'source_qid' => $dumpMetaInformation->getSourceItemId()->getSerialization(), |
239 | - 'import_date' => $db->timestamp( $dumpMetaInformation->getImportDate() ), |
|
239 | + 'import_date' => $db->timestamp($dumpMetaInformation->getImportDate()), |
|
240 | 240 | 'language' => $dumpMetaInformation->getLanguageCode(), |
241 | 241 | 'source_url' => $dumpMetaInformation->getSourceUrl(), |
242 | 242 | 'size' => $dumpMetaInformation->getSize(), |