/** * Purify session description * @param OutputInterface $output */ protected function purifySessionDescription(OutputInterface $output) { $cleaned = 0; $offset = 1; $limit = self::QUERY_LIMIT; $total = $this->sessionDescriptionManager->getTotalSessionDescriptionCount(); $progress = new ProgressBar($output, $total); $progress->setRedrawFrequency(208); $output->writeln("<info>Starting cleanup of session descriptions...</info>"); $progress->start(); do { $descriptions = $this->sessionDescriptionManager->findBy(array(), array('id' => 'ASC'), $limit, $offset); foreach ($descriptions as $description) { $original = $description->getDescription(); $clean = $this->purifier->purify($original); if ($original != $clean) { $cleaned++; $description->setDescription($clean); $this->sessionDescriptionManager->update($description, false); } $progress->advance(); } $offset += $limit; $this->em->flush(); $this->em->clear(); } while (count($descriptions) == $limit); $progress->finish(); $output->writeln(''); $output->writeln("<info>{$cleaned} Session Descriptions updated.</info>"); }