Skip to content

Commit

Permalink
Merge pull request #6717 from Webmecanik/add-ispublished-check-msu
Browse files Browse the repository at this point in the history
Add isPublished verification on mautic:segments:update
  • Loading branch information
Woeler committed Nov 22, 2018
2 parents a2e4c2d + 3b08a73 commit a8e1b15
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions app/bundles/LeadBundle/Command/UpdateLeadListsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,21 @@ protected function execute(InputInterface $input, OutputInterface $output)

if ($id) {
$list = $listModel->getEntity($id);

if ($list !== null) {
$output->writeln('<info>'.$translator->trans('mautic.lead.list.rebuild.rebuilding', ['%id%' => $id]).'</info>');
$processed = 0;
try {
$processed = $listModel->rebuildListLeads($list, $batch, $max, $output);
} catch (QueryException $e) {
$this->getContainer()->get('monolog.logger.mautic')->error('Query Builder Exception: '.$e->getMessage());
if ($list->isPublished()) {
$output->writeln('<info>'.$translator->trans('mautic.lead.list.rebuild.rebuilding', ['%id%' => $id]).'</info>');
$processed = 0;
try {
$processed = $listModel->rebuildListLeads($list, $batch, $max, $output);
} catch (QueryException $e) {
$this->getContainer()->get('monolog.logger.mautic')->error('Query Builder Exception: '.$e->getMessage());
}

$output->writeln(
'<comment>'.$translator->trans('mautic.lead.list.rebuild.leads_affected', ['%leads%' => $processed]).'</comment>'
);
}

$output->writeln(
'<comment>'.$translator->trans('mautic.lead.list.rebuild.leads_affected', ['%leads%' => $processed]).'</comment>'
);
} else {
$output->writeln('<error>'.$translator->trans('mautic.lead.list.rebuild.not_found', ['%id%' => $id]).'</error>');
}
Expand All @@ -82,12 +85,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
// Get first item; using reset as the key will be the ID and not 0
$l = reset($l);

$output->writeln('<info>'.$translator->trans('mautic.lead.list.rebuild.rebuilding', ['%id%' => $l->getId()]).'</info>');
if ($l->isPublished()) {
$output->writeln('<info>'.$translator->trans('mautic.lead.list.rebuild.rebuilding', ['%id%' => $l->getId()]).'</info>');

$processed = $listModel->rebuildListLeads($l, $batch, $max, $output);
$output->writeln(
'<comment>'.$translator->trans('mautic.lead.list.rebuild.leads_affected', ['%leads%' => $processed]).'</comment>'."\n"
);
$processed = $listModel->rebuildListLeads($l, $batch, $max, $output);
$output->writeln(
'<comment>'.$translator->trans('mautic.lead.list.rebuild.leads_affected', ['%leads%' => $processed]).'</comment>'."\n"
);
}

unset($l);
}
Expand Down

0 comments on commit a8e1b15

Please sign in to comment.