mirror of https://github.com/MISP/MISP
fix: Fixed various warninglist performance issues for updating
parent
c3a75a5d78
commit
dba77b4762
|
@ -154,17 +154,7 @@ class WarninglistsController extends AppController {
|
|||
public function delete($id) {
|
||||
if ($this->request->is('post')) {
|
||||
$id = intval($id);
|
||||
$result = $this->Warninglist->WarninglistEntry->deleteAll(
|
||||
array('WarninglistEntry.warninglist_id' => $id)
|
||||
);
|
||||
if ($result) {
|
||||
$result = $this->Warninglist->WarninglistType->deleteAll(
|
||||
array('WarninglistType.warninglist_id' => $id)
|
||||
);
|
||||
}
|
||||
if ($result) {
|
||||
$result = $this->Warninglist->delete($id, false);
|
||||
}
|
||||
$result = $this->Warninglist->quickDelete($id);
|
||||
if ($result) {
|
||||
$this->Session->setFlash('Warninglist successfuly deleted.');
|
||||
$this->redirect(array('controller' => 'warninglists', 'action' => 'index'));
|
||||
|
|
|
@ -72,12 +72,27 @@ class Warninglist extends AppModel{
|
|||
return $updated;
|
||||
}
|
||||
|
||||
public function quickDelete($id) {
|
||||
$result = $this->WarninglistEntry->deleteAll(
|
||||
array('WarninglistEntry.warninglist_id' => $id)
|
||||
);
|
||||
if ($result) {
|
||||
$result = $this->WarninglistType->deleteAll(
|
||||
array('WarninglistType.warninglist_id' => $id)
|
||||
);
|
||||
}
|
||||
if ($result) {
|
||||
$result = $this->delete($id, false);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function __updateList($list, $current) {
|
||||
$list['enabled'] = 0;
|
||||
$warninglist = array();
|
||||
if (!empty($current)) {
|
||||
if ($current['Warninglist']['enabled']) $list['enabled'] = 1;
|
||||
$this->deleteAll(array('Warninglist.id' => $current['Warninglist']['id']));
|
||||
$this->quickDelete($current['Warninglist']['id']);
|
||||
}
|
||||
$fieldsToSave = array('name', 'version', 'description', 'type', 'enabled');
|
||||
foreach ($fieldsToSave as $fieldToSave) {
|
||||
|
@ -94,7 +109,7 @@ class Warninglist extends AppModel{
|
|||
}
|
||||
unset($list['list']);
|
||||
$count = count($values);
|
||||
$values = array_chunk($values, 1000);
|
||||
$values = array_chunk($values, 100);
|
||||
foreach ($values as $chunk) {
|
||||
$result = $db->insertMulti('warninglist_entries', array('value', 'warninglist_id'), $chunk);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue