fixed deleting flagging collections with duplicate relatedflag
This commit is contained in:
parent
d23de27c76
commit
19c923a8d3
|
@ -63,7 +63,7 @@ foreach ($fcfd_result as $fc) {
|
|||
$conf_result = $flag_query->execute();
|
||||
$count = $flag_query->countQuery()->execute()->fetchField();
|
||||
if(!$count){
|
||||
$this->output()->writeln($count . " relatedflag");
|
||||
$this->output()->writeln($fc->id . ' flagging_collection has ' . $count . " relatedflag");
|
||||
$fc_missing_relatedflag ++;
|
||||
delete_flagingcollection($fc, $database, $delete);
|
||||
}
|
||||
|
@ -73,22 +73,40 @@ $this->output()->writeln($fc_missing_relatedflag .' flagging_collection with mis
|
|||
// searching for duplicates relatedflags
|
||||
$this->output()->writeln("");
|
||||
$this->output()->writeln("Duplicate relatedflag flagging_collection cleaning");
|
||||
$fcfd_query = $database->select('flagging_collection_field_data', 'fcfd')
|
||||
->fields('fcfd', ['id', 'relatedflag'])
|
||||
$dup_query = $database->select('flagging_collection_field_data', 'fcfd')
|
||||
->fields('fcfd', ['relatedflag'])
|
||||
->groupBy('fcfd.relatedflag')
|
||||
->having('COUNT(*) > 1');
|
||||
$fcfd_query->addExpression('COUNT(*)', 'count');
|
||||
$dup_query->addExpression('COUNT(*)', 'count');
|
||||
|
||||
// $results = $query->execute()->fetchAll();
|
||||
|
||||
$fcfd_result = $fcfd_query->execute();
|
||||
$this->output()->writeln($fcfd_query->countQuery()->execute()->fetchField() . " duplicate related flags");
|
||||
$dup_result = $dup_query->execute();
|
||||
$this->output()->writeln($dup_query->countQuery()->execute()->fetchField() . " duplicate related flags");
|
||||
|
||||
foreach ($fcfd_result as $dup){
|
||||
$this->output()->writeln($dup->relatedflag . " of " . $dup->id . " is dup");
|
||||
delete_flagingcollection($dup, $database, $delete);
|
||||
foreach ($dup_result as $dup){
|
||||
// $this->output()->writeln($dup->relatedflag . " is dup");
|
||||
$fcfd_query = $database->select('flagging_collection_field_data', 'fcfd')
|
||||
->condition('fcfd.relatedflag', $dup->relatedflag)
|
||||
->fields('fcfd', ['id', 'relatedflag']);
|
||||
$fcfd_result = $fcfd_query->execute();
|
||||
$count = $fcfd_query->countQuery()->execute()->fetchField();
|
||||
|
||||
$this->output()->writeln($dup->relatedflag . ' relatedflag has ' . $count . ' flagging collection');
|
||||
|
||||
foreach ($fcfd_result as $fc) {
|
||||
delete_flagingcollection($fc, $database, $delete);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// MAIN DELETE FUNCTION
|
||||
function delete_flagingcollection($fc, $database, $delete){
|
||||
if($delete){
|
||||
|
|
Loading…
Reference in New Issue