| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 3 | function es_doc_delete($request, $args) |
||
| 4 | { |
||
| 5 | global $ESConn; |
||
| 6 | try { |
||
| 7 | $result = $ESConn->delete($args); |
||
| 8 | } catch (Exception $e) { |
||
| 9 | /* |
||
| 10 | If you try to delete a document with an _id that does not exist, $ES->delete throws an Exception. |
||
| 11 | B/c of default behaviour of reformo/rslim, it bypasses all Exceptions and it returns Exception message. |
||
| 12 | In this case it returns this message as a plain text json that elasticsearch-php returns. |
||
| 13 | */ |
||
| 14 | $result = json_decode($e->getMessage(), true); |
||
| 15 | } |
||
| 16 | $found = (int) $result['found']; |
||
| 17 | sleep(1); |
||
| 18 | return ['redirect'=>BASE_HREF . '/' . $args['index'] . '/' . $args['type'] . '?res=success&req=delete&f=' . $found]; |
||
| 19 | } |
||
| 20 |