@@ 206-225 (lines=20) @@ | ||
203 | if ($results) |
|
204 | foreach ($results as $result) { |
|
205 | foreach ($results2 as $result2) { |
|
206 | if ($result['id'] != $result2['id'] && $result['name'] == $result2['name'] && $result['grouping'] == $result2['grouping']) { |
|
207 | // We have a duplicate that should not exist. Need to remove the offending record first |
|
208 | $delid = -1; |
|
209 | if ($result['mtime'] == $result2['mtime']) { |
|
210 | // If the mtime's match, delete the oldest ID. |
|
211 | $delid = $result['id']; |
|
212 | if ($result['id'] > $result2['id']) |
|
213 | $delid = $result2['id']; |
|
214 | } elseif ($result['mtime'] > $result2['mtime']) { |
|
215 | // Again, delete the oldest |
|
216 | $delid = $result2['id']; |
|
217 | } elseif ($result['mtime'] < $result2['mtime']) { |
|
218 | // The only thing left is if result is older |
|
219 | $delid = $result['id']; |
|
220 | } |
|
221 | if ($delid != -1) { |
|
222 | $this->db->executeQuery("DELETE FROM *PREFIX*ownnote WHERE id=?", Array($delid)); |
|
223 | $requery = true; |
|
224 | } |
|
225 | } |
|
226 | } |
|
227 | } |
|
228 | if ($requery) { |
@@ 261-280 (lines=20) @@ | ||
258 | if($result2 instanceof OwnNote) { |
|
259 | $result2 = $result2->jsonSerialize(); |
|
260 | } |
|
261 | if ($result['id'] != $result2['id'] && $result['name'] == $result2['name'] && $result['grouping'] == $result2['grouping']) { |
|
262 | // We have a duplicate that should not exist. Need to remove the offending record first |
|
263 | $delid = -1; |
|
264 | if ($result['mtime'] == $result2['mtime']) { |
|
265 | // If the mtime's match, delete the oldest ID. |
|
266 | $delid = $result['id']; |
|
267 | if ($result['id'] > $result2['id']) |
|
268 | $delid = $result2['id']; |
|
269 | } elseif ($result['mtime'] > $result2['mtime']) { |
|
270 | // Again, delete the oldest |
|
271 | $delid = $result2['id']; |
|
272 | } elseif ($result['mtime'] < $result2['mtime']) { |
|
273 | // The only thing left is if result is older |
|
274 | $delid = $result['id']; |
|
275 | } |
|
276 | if ($delid != -1) { |
|
277 | $this->delete('', $delid); |
|
278 | $requery = true; |
|
279 | } |
|
280 | } |
|
281 | } |
|
282 | } |
|
283 | if ($requery) { |