Skip to content
Permalink
Browse files

delete(): check on node type added

  • Loading branch information...
fmancardi committed Jun 13, 2015
1 parent 0b6758c commit feee7f983ca7849e08dd5f043e64d22fb13d38fc
Showing with 23 additions and 11 deletions.
  1. +23 −11 lib/functions/requirement_mgr.class.php
@@ -600,7 +600,9 @@ function delete($id,$version_id = self::ALL_VERSIONS)
$deleteAll = true;
// I'm trying to speedup the next deletes
$sql="SELECT NH.id FROM {$this->tables['nodes_hierarchy']} NH WHERE NH.parent_id ";
$sql = "/* $debugMsg */ " .
"SELECT NH.id FROM {$this->tables['nodes_hierarchy']} NH " .
"WHERE NH.parent_id ";
if( is_array($id) )
{
$sql .= " IN (" .implode(',',$id) . ") ";
@@ -610,6 +612,8 @@ function delete($id,$version_id = self::ALL_VERSIONS)
$sql .= " = {$id} ";
}
$sql .= " AND node_type_id=" . $this->node_types_descr_id['requirement_version'];
$children_rs=$this->db->fetchRowsIntoMap($sql,'id');
$children = array_keys($children_rs);
@@ -661,18 +665,24 @@ function delete($id,$version_id = self::ALL_VERSIONS)
$implosion = implode(',',$children);
$sql = "/* $debugMsg */ SELECT id from {$this->tables['nodes_hierarchy']} " .
" WHERE parent_id IN ( {$implosion} ) ";
" WHERE parent_id IN ( {$implosion} ) " .
"AND node_type_id=" .
$this->node_types_descr_id['requirement_revision'];
$revisionSet = $this->db->fetchRowsIntoMap($sql,'id');
if( !is_null($revisionSet) )
{
$this->cfield_mgr->remove_all_design_values_from_node(array_keys($revisionSet));
$this->cfield_mgr->remove_all_design_values_from_node(array_keys($revisionSet));
$sql = "DELETE FROM {$this->tables['req_revisions']} WHERE parent_id IN ( {$implosion} ) ";
$result = $this->db->exec_query($sql);
$sql = "/* $debugMsg */ DELETE FROM {$this->tables['req_revisions']} " .
"WHERE parent_id IN ( {$implosion} ) ";
$result = $this->db->exec_query($sql);
$sql = "DELETE FROM {$this->tables['nodes_hierarchy']} WHERE parent_id IN ( {$implosion} ) ";
$result = $this->db->exec_query($sql);
$sql = "/* $debugMsg */ DELETE FROM {$this->tables['nodes_hierarchy']} " .
"WHERE parent_id IN ( {$implosion} ) " .
"AND node_type_id=" .
$this->node_types_descr_id['requirement_revision'];
$result = $this->db->exec_query($sql);
}
$this->cfield_mgr->remove_all_design_values_from_node((array)$children);
@@ -681,10 +691,10 @@ function delete($id,$version_id = self::ALL_VERSIONS)
$sql = "DELETE FROM {$this->tables['req_versions']} " . $where['children'];
$result = $this->db->exec_query($sql);
$sql = "DELETE FROM {$this->tables['nodes_hierarchy']} " . $where['children'];
$sql = "DELETE FROM {$this->tables['nodes_hierarchy']} " .
$where['children'] .
" AND node_type_id=" . $this->node_types_descr_id['requirement_version'];
$result = $this->db->exec_query($sql);
}
$kaboom = $kaboom || ($deleteAll && $result);
@@ -693,7 +703,9 @@ function delete($id,$version_id = self::ALL_VERSIONS)
$sql = "DELETE FROM {$this->object_table} " . $where['this'];
$result = $this->db->exec_query($sql);
$sql = "DELETE FROM {$this->tables['nodes_hierarchy']} " . $where['this'];
$sql = "DELETE FROM {$this->tables['nodes_hierarchy']} " . $where['this'] .
" AND node_type_id=" . $this->node_types_descr_id['requirement'];
$result = $this->db->exec_query($sql);
}

0 comments on commit feee7f9

Please sign in to comment.
You can’t perform that action at this time.