$response['newurl'] = $Appearance['id'] . '-' . Appearances::getSafeLabel($EditedAppearance); } $response['notes'] = Appearances::getNotesHTML($EditedAppearance, NOWRAP); } Response::done($response); break; case "delete": if ($Appearance['id'] === 0) { Response::fail('This appearance cannot be deleted'); } $Tagged = Tags::getFor($Appearance['id'], null, true, false); if (!$CGDb->where('id', $Appearance['id'])->delete('appearances')) { Response::dbError(); } try { CoreUtils::elasticClient()->delete(Appearances::toElasticArray($Appearance, true)); } catch (ElasticMissing404Exception $e) { $message = JSON::decode($e->getMessage()); // Eat error if appearance was not indexed if ($message['found'] !== false) { throw $e; } } catch (ElasticNoNodesAvailableException $e) { error_log('ElasticSearch server was down when server attempted to remove appearance ' . $Appearance['id']); } if (!empty($Tagged)) { foreach ($Tagged as $tag) { Tags::updateUses($tag['tid']); } } $fpath = APPATH . "img/cg/{$Appearance['id']}.png";