diff --git a/phpBB/language/en/cli.php b/phpBB/language/en/cli.php
index f0e5dd6120..7dd8403ed4 100644
--- a/phpBB/language/en/cli.php
+++ b/phpBB/language/en/cli.php
@@ -96,4 +96,10 @@ $lang = array_merge($lang, array(
'THUMBNAIL_DELETED' => '%1$s (%2$s) deleted.',
'THUMBNAIL_SKIPPED' => '%1$s (%2$s) skipped.',
'THUMBNAIL_GENERATED' => '%1$s (%2$s) generated.',
+
+ 'THUMBNAIL_DELETING' => 'Deleting the thumbnails...',
+ 'THUMBNAIL_GENERATING' => 'Generating the thumbnails...',
+
+ 'NO_THUMBNAIL_TO_GENERATE' => 'No thumbnail to generate.',
+ 'NO_THUMBNAIL_TO_DELETE' => 'No thumbnail to delete.',
));
diff --git a/phpBB/phpbb/console/command/thumbnail/delete.php b/phpBB/phpbb/console/command/thumbnail/delete.php
index b60ea5238f..b57fcc681f 100644
--- a/phpBB/phpbb/console/command/thumbnail/delete.php
+++ b/phpBB/phpbb/console/command/thumbnail/delete.php
@@ -68,11 +68,31 @@ class delete extends \phpbb\console\command\command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $sql = 'SELECT COUNT(*) AS nb_missing_thumbnails
+ FROM ' . ATTACHMENTS_TABLE . '
+ WHERE thumbnail = 1';
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $nb_missing_thumbnails = (int) $row['nb_missing_thumbnails'];
+ if ($nb_missing_thumbnails === 0)
+ {
+ $output->writeln('' . $this->user->lang('NO_THUMBNAIL_TO_DELETE') . '');
+ return 0;
+ }
+
$sql = 'SELECT attach_id, physical_filename, extension, real_filename, mimetype
FROM ' . ATTACHMENTS_TABLE . '
WHERE thumbnail = 1';
$result = $this->db->sql_query($sql);
+ if (!$input->getOption('verbose'))
+ {
+ $progress = $this->getHelper('progress');
+ $progress->start($output, $nb_missing_thumbnails);
+ }
+
$thumbnail_deleted = array();
$return = 0;
while ($row = $this->db->sql_fetchrow($result))
@@ -102,6 +122,11 @@ class delete extends \phpbb\console\command\command
$output->writeln('' . $this->user->lang('THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '');
}
}
+
+ if (!$input->getOption('verbose'))
+ {
+ $progress->advance();
+ }
}
$this->db->sql_freeresult($result);
@@ -110,6 +135,11 @@ class delete extends \phpbb\console\command\command
$this->commit_changes($thumbnail_deleted);
}
+ if (!$input->getOption('verbose'))
+ {
+ $progress->finish();
+ }
+
return $return;
}
diff --git a/phpBB/phpbb/console/command/thumbnail/generate.php b/phpBB/phpbb/console/command/thumbnail/generate.php
index 640d971b5d..068bd0ff94 100644
--- a/phpBB/phpbb/console/command/thumbnail/generate.php
+++ b/phpBB/phpbb/console/command/thumbnail/generate.php
@@ -84,6 +84,20 @@ class generate extends \phpbb\console\command\command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $sql = 'SELECT COUNT(*) AS nb_missing_thumbnails
+ FROM ' . ATTACHMENTS_TABLE . '
+ WHERE thumbnail = 0';
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $nb_missing_thumbnails = (int) $row['nb_missing_thumbnails'];
+ if ($nb_missing_thumbnails === 0)
+ {
+ $output->writeln('' . $this->user->lang('NO_THUMBNAIL_TO_GENERATE') . '');
+ return 0;
+ }
+
$extensions = $this->cache->obtain_attach_extensions(true);
$sql = 'SELECT attach_id, physical_filename, extension, real_filename, mimetype
@@ -96,6 +110,12 @@ class generate extends \phpbb\console\command\command
require($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext);
}
+ if (!$input->getOption('verbose'))
+ {
+ $progress = $this->getHelper('progress');
+ $progress->start($output, $nb_missing_thumbnails);
+ }
+
$thumbnail_created = array();
while ($row = $this->db->sql_fetchrow($result))
{
@@ -127,6 +147,11 @@ class generate extends \phpbb\console\command\command
}
}
}
+
+ if (!$input->getOption('verbose'))
+ {
+ $progress->advance();
+ }
}
$this->db->sql_freeresult($result);
@@ -135,6 +160,11 @@ class generate extends \phpbb\console\command\command
$this->commit_changes($thumbnail_created);
}
+ if (!$input->getOption('verbose'))
+ {
+ $progress->finish();
+ }
+
return 0;
}
diff --git a/phpBB/phpbb/console/command/thumbnail/recreate.php b/phpBB/phpbb/console/command/thumbnail/recreate.php
index 624e4e507f..ec093161af 100644
--- a/phpBB/phpbb/console/command/thumbnail/recreate.php
+++ b/phpBB/phpbb/console/command/thumbnail/recreate.php
@@ -54,6 +54,7 @@ class recreate extends \phpbb\console\command\command
$this->getApplication()->setAutoExit(false);
+ $output->writeln('' . $this->user->lang('THUMBNAIL_DELETING') . '');
$input_delete = new ArrayInput($parameters);
$return = $this->getApplication()->run($input_delete, $output);
@@ -61,6 +62,8 @@ class recreate extends \phpbb\console\command\command
{
$parameters['command'] = 'thumbnail:generate';
+ $output->writeln('');
+ $output->writeln('' . $this->user->lang('THUMBNAIL_GENERATING') . '');
$input_create = new ArrayInput($parameters);
$return = $this->getApplication()->run($input_create, $output);
}