mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 14:03:27 +00:00
Update BuildSubdefs.php
This commit is contained in:
@@ -350,12 +350,15 @@ class BuildSubdefs extends Command
|
|||||||
*/
|
*/
|
||||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$time_start = new \DateTime();
|
||||||
|
|
||||||
if(!$this->sanitizeArgs($input, $output)) {
|
if(!$this->sanitizeArgs($input, $output)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->input = $input;
|
$this->input = $input;
|
||||||
$this->output = $output;
|
$this->output = $output;
|
||||||
|
$progress = null;
|
||||||
|
|
||||||
$sql = $this->getSQL();
|
$sql = $this->getSQL();
|
||||||
|
|
||||||
@@ -367,22 +370,19 @@ class BuildSubdefs extends Command
|
|||||||
|
|
||||||
$totalRecords = (int)$this->connection->executeQuery($sqlCount)->fetchColumn();
|
$totalRecords = (int)$this->connection->executeQuery($sqlCount)->fetchColumn();
|
||||||
|
|
||||||
if ($totalRecords === 0) {
|
$nRecordsDone = 0;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$progress = null;
|
$again = true;
|
||||||
if($output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) {
|
|
||||||
$progress = new ProgressBar($output, $totalRecords);
|
|
||||||
$progress->start();
|
|
||||||
$progress->display();
|
|
||||||
}
|
|
||||||
|
|
||||||
$stmt = $this->connection->executeQuery($sql);
|
$stmt = $this->connection->executeQuery($sql);
|
||||||
|
while($again && ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) ) {
|
||||||
|
|
||||||
|
if($output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE && $progress === null) {
|
||||||
|
$progress = new ProgressBar($output, $totalRecords);
|
||||||
|
$progress->start();
|
||||||
|
$progress->display();
|
||||||
|
}
|
||||||
|
|
||||||
$time_start = new \DateTime();
|
|
||||||
$nRecordsDone = 0;
|
|
||||||
while( ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) ) {
|
|
||||||
$recordChanged = false;
|
$recordChanged = false;
|
||||||
$type = $row['type'];
|
$type = $row['type'];
|
||||||
$msg = [];
|
$msg = [];
|
||||||
@@ -489,7 +489,7 @@ class BuildSubdefs extends Command
|
|||||||
|
|
||||||
if($progress) {
|
if($progress) {
|
||||||
$progress->advance();
|
$progress->advance();
|
||||||
$output->write(implode(' ', $msg));
|
//$output->write(implode(' ', $msg));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$output->writeln(implode("\n", $msg));
|
$output->writeln(implode("\n", $msg));
|
||||||
@@ -500,6 +500,7 @@ class BuildSubdefs extends Command
|
|||||||
$output->writeln('');
|
$output->writeln('');
|
||||||
}
|
}
|
||||||
$output->writeln(sprintf("Maximum number (%d >= %d) of records done, quit.", $nRecordsDone, $this->maxrecs));
|
$output->writeln(sprintf("Maximum number (%d >= %d) of records done, quit.", $nRecordsDone, $this->maxrecs));
|
||||||
|
$again = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$time_end = new \DateTime();
|
$time_end = new \DateTime();
|
||||||
@@ -509,6 +510,7 @@ class BuildSubdefs extends Command
|
|||||||
$output->writeln('');
|
$output->writeln('');
|
||||||
}
|
}
|
||||||
$output->writeln(sprintf("Maximum duration (%d >= %d) done, quit.", $dt, $this->maxduration));
|
$output->writeln(sprintf("Maximum duration (%d >= %d) done, quit.", $dt, $this->maxduration));
|
||||||
|
$again = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -516,7 +518,6 @@ class BuildSubdefs extends Command
|
|||||||
unset($stmt);
|
unset($stmt);
|
||||||
|
|
||||||
if($progress) {
|
if($progress) {
|
||||||
$progress->finish();
|
|
||||||
$output->writeln('');
|
$output->writeln('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user