fixed drush script

This commit is contained in:
Bachir Soussi Chiadmi 2022-02-23 13:39:35 +01:00
parent 796e060d7a
commit 52b8275c89
1 changed files with 9 additions and 7 deletions

View File

@ -9,8 +9,8 @@ use Drush\Drush;
$this->output()->writeln("Flagging collection cleaning");
// $this->output()->writeln("Hello world!");
// $this->output()->writeln("The extra options/arguments to this command were:");
// $this->output()->writeln(print_r($extra, true));
$this->output()->writeln("The extra options/arguments to this command were:");
$this->output()->writeln(print_r($extra, true));
if ($extra[0] === "delete") {
$delete = true;
} else {
@ -42,7 +42,7 @@ foreach ($fcfd_result as $fc) {
$this->output()->writeln($flifd_query->countQuery()->execute()->fetchField() . " items for fc " . $fc->id . ' with baseflag ' . $fc->relatedflag);
// $this->output()->writeln(print_r($flifd_result->fetchAssoc(), true) . " items");
delete_flagingcollection($fc);
delete_flagingcollection($fc, $database, $delete);
}
@ -65,14 +65,15 @@ foreach ($fcfd_result as $fc) {
if(!$count){
$this->output()->writeln($count . " relatedflag");
$fc_missing_relatedflag ++;
delete_flagingcollection($fc);
delete_flagingcollection($fc, $database, $delete);
}
}
$this->output()->writeln($fc_missing_relatedflag .' flagging_collection with missing related_flag');
function delete_flagingcollection($fc){
function delete_flagingcollection($fc, $database, $delete){
if($delete){
$this->output()->writeln("Deleting flagging collection " . $fc->id);
// $this is not working in function
// $this->output()->writeln("Deleting flagging collection " . $fc->id);
// get flag list items
$flifd_query = $database->select('flag_list_item_field_data', 'flifd')
->condition('flifd.flag_list', $fc->id)
@ -118,7 +119,8 @@ function delete_flagingcollection($fc){
->execute();
} else {
$this->output()->writeln("In order to actually delete fault flagging collection data please use delete option");
// $this is not working in function
// $this->output()->writeln("In order to actually delete fault flagging collection data please use delete option");
}
}