diff --git a/phpBB/language/en/cli.php b/phpBB/language/en/cli.php
index d494ef8c55..ec1d63eabf 100644
--- a/phpBB/language/en/cli.php
+++ b/phpBB/language/en/cli.php
@@ -84,20 +84,25 @@ $lang = array_merge($lang, array(
'CLI_EXTENSION_PURGE_FAILURE' => 'Could not purge extension %s',
'CLI_EXTENSION_PURGE_SUCCESS' => 'Successfully purged extension %s',
'CLI_EXTENSION_NOT_FOUND' => 'No extensions were found.',
+ 'CLI_EXTENSIONS_AVAILABLE' => 'Available',
+ 'CLI_EXTENSIONS_DISABLED' => 'Disabled',
+ 'CLI_EXTENSIONS_ENABLED' => 'Enabled',
'CLI_FIXUP_RECALCULATE_EMAIL_HASH_SUCCESS' => 'Successfully recalculated all email hashes.',
'CLI_REPARSER_REPARSE_REPARSING' => 'Reparsing %1$s (range %2$d..%3$d)',
'CLI_REPARSER_REPARSE_REPARSING_START' => 'Reparsing %s...',
'CLI_REPARSER_REPARSE_SUCCESS' => 'Reparsing ended with success',
-
+
// In all the case %1$s is the logical name of the file and %2$s the real name on the filesystem
// eg: big_image.png (2_a51529ae7932008cf8454a95af84cacd) generated.
'CLI_THUMBNAIL_DELETED' => '%1$s (%2$s) deleted.',
- 'CLI_THUMBNAIL_DELETING' => 'Deleting thumbnails…',
+ 'CLI_THUMBNAIL_DELETING' => 'Deleting thumbnails',
'CLI_THUMBNAIL_SKIPPED' => '%1$s (%2$s) skipped.',
'CLI_THUMBNAIL_GENERATED' => '%1$s (%2$s) generated.',
- 'CLI_THUMBNAIL_GENERATING' => 'Generating thumbnails…',
+ 'CLI_THUMBNAIL_GENERATING' => 'Generating thumbnails',
+ 'CLI_THUMBNAIL_GENERATING_DONE' => 'All thumbnails have been regenerated.',
+ 'CLI_THUMBNAIL_DELETING_DONE' => 'All thumbnails have been deleted.',
'CLI_THUMBNAIL_NOTHING_TO_GENERATE' => 'No thumbnails to generate.',
'CLI_THUMBNAIL_NOTHING_TO_DELETE' => 'No thumbnails to delete.',
diff --git a/phpBB/phpbb/console/command/thumbnail/delete.php b/phpBB/phpbb/console/command/thumbnail/delete.php
index fb63f7c510..e8e4cf568e 100644
--- a/phpBB/phpbb/console/command/thumbnail/delete.php
+++ b/phpBB/phpbb/console/command/thumbnail/delete.php
@@ -14,6 +14,7 @@ namespace phpbb\console\command\thumbnail;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class delete extends \phpbb\console\command\command
{
@@ -68,6 +69,10 @@ class delete extends \phpbb\console\command\command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
+ $io->section($this->user->lang('CLI_THUMBNAIL_DELETING'));
+
$sql = 'SELECT COUNT(*) AS nb_missing_thumbnails
FROM ' . ATTACHMENTS_TABLE . '
WHERE thumbnail = 1';
@@ -77,7 +82,7 @@ class delete extends \phpbb\console\command\command
if ($nb_missing_thumbnails === 0)
{
- $output->writeln('' . $this->user->lang('CLI_THUMBNAIL_NOTHING_TO_DELETE') . '');
+ $io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_DELETE'));
return 0;
}
@@ -86,11 +91,36 @@ class delete extends \phpbb\console\command\command
WHERE thumbnail = 1';
$result = $this->db->sql_query($sql);
- if (!$input->getOption('verbose'))
+ $progress = $io->createProgressBar($nb_missing_thumbnails);
+ if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE)
{
- $progress = $this->getHelper('progress');
- $progress->start($output, $nb_missing_thumbnails);
+ $progress->setFormat('[%percent:3s%%] %message%');
+ $progress->setOverwrite(false);
}
+ else if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE)
+ {
+ $progress->setFormat('[%current:s%/%max:s%][%elapsed%/%estimated%][%memory%] %message%');
+ $progress->setOverwrite(false);
+ }
+ else
+ {
+ $io->newLine(2);
+ $progress->setFormat(
+ " %current:s%/%max:s% %bar% %percent:3s%%\n" .
+ " %elapsed:6s%/%estimated:-6s% %memory:6s%\n");
+ $progress->setBarWidth(60);
+ }
+
+ if (!defined('PHP_WINDOWS_VERSION_BUILD'))
+ {
+ $progress->setEmptyBarCharacter('░'); // light shade character \u2591
+ $progress->setProgressCharacter('');
+ $progress->setBarCharacter('▓'); // dark shade character \u2593
+ }
+
+ $progress->setMessage($this->user->lang('CLI_THUMBNAIL_DELETING'));
+
+ $progress->start();
$thumbnail_deleted = array();
$return = 0;
@@ -108,24 +138,15 @@ class delete extends \phpbb\console\command\command
$thumbnail_deleted = array();
}
- if ($input->getOption('verbose'))
- {
- $output->writeln($this->user->lang('CLI_THUMBNAIL_DELETED', $row['real_filename'], $row['physical_filename']));
- }
+ $progress->setMessage($this->user->lang('CLI_THUMBNAIL_DELETED', $row['real_filename'], $row['physical_filename']));
}
else
{
- if ($input->getOption('verbose'))
- {
- $return = 1;
- $output->writeln('' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '');
- }
+ $return = 1;
+ $progress->setMessage('' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '');
}
- if (!$input->getOption('verbose'))
- {
- $progress->advance();
- }
+ $progress->advance();
}
$this->db->sql_freeresult($result);
@@ -134,10 +155,10 @@ class delete extends \phpbb\console\command\command
$this->commit_changes($thumbnail_deleted);
}
- if (!$input->getOption('verbose'))
- {
- $progress->finish();
- }
+ $progress->finish();
+
+ $io->newLine(2);
+ $io->success($this->user->lang('CLI_THUMBNAIL_DELETING_DONE'));
return $return;
}
diff --git a/phpBB/phpbb/console/command/thumbnail/generate.php b/phpBB/phpbb/console/command/thumbnail/generate.php
index 0f4a40bd9f..e677db3a97 100644
--- a/phpBB/phpbb/console/command/thumbnail/generate.php
+++ b/phpBB/phpbb/console/command/thumbnail/generate.php
@@ -10,10 +10,12 @@
* the docs/CREDITS.txt file.
*
*/
+
namespace phpbb\console\command\thumbnail;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
class generate extends \phpbb\console\command\command
{
@@ -84,6 +86,10 @@ class generate extends \phpbb\console\command\command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ $io = new SymfonyStyle($input, $output);
+
+ $io->section($this->user->lang('CLI_THUMBNAIL_GENERATING'));
+
$sql = 'SELECT COUNT(*) AS nb_missing_thumbnails
FROM ' . ATTACHMENTS_TABLE . '
WHERE thumbnail = 0';
@@ -93,7 +99,7 @@ class generate extends \phpbb\console\command\command
if ($nb_missing_thumbnails === 0)
{
- $output->writeln('' . $this->user->lang('CLI_THUMBNAIL_NOTHING_TO_GENERATE') . '');
+ $io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_GENERATE'));
return 0;
}
@@ -109,11 +115,36 @@ class generate extends \phpbb\console\command\command
require($this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext);
}
- if (!$input->getOption('verbose'))
+ $progress = $io->createProgressBar($nb_missing_thumbnails);
+ if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE)
{
- $progress = $this->getHelper('progress');
- $progress->start($output, $nb_missing_thumbnails);
+ $progress->setFormat('[%percent:3s%%] %message%');
+ $progress->setOverwrite(false);
}
+ else if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE)
+ {
+ $progress->setFormat('[%current:s%/%max:s%][%elapsed%/%estimated%][%memory%] %message%');
+ $progress->setOverwrite(false);
+ }
+ else
+ {
+ $io->newLine(2);
+ $progress->setFormat(
+ " %current:s%/%max:s% %bar% %percent:3s%%\n" .
+ " %elapsed:6s%/%estimated:-6s% %memory:6s%\n");
+ $progress->setBarWidth(60);
+ }
+
+ if (!defined('PHP_WINDOWS_VERSION_BUILD'))
+ {
+ $progress->setEmptyBarCharacter('░'); // light shade character \u2591
+ $progress->setProgressCharacter('');
+ $progress->setBarCharacter('▓'); // dark shade character \u2593
+ }
+
+ $progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATING'));
+
+ $progress->start();
$thumbnail_created = array();
while ($row = $this->db->sql_fetchrow($result))
@@ -127,30 +158,21 @@ class generate extends \phpbb\console\command\command
{
$thumbnail_created[] = (int) $row['attach_id'];
- if (sizeof($thumbnail_created) === 250)
+ if (count($thumbnail_created) === 250)
{
$this->commit_changes($thumbnail_created);
$thumbnail_created = array();
}
- if ($input->getOption('verbose'))
- {
- $output->writeln($this->user->lang('CLI_THUMBNAIL_GENERATED', $row['real_filename'], $row['physical_filename']));
- }
+ $progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATED', $row['real_filename'], $row['physical_filename']));
}
else
{
- if ($input->getOption('verbose'))
- {
- $output->writeln('' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '');
- }
+ $progress->setMessage('' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '');
}
}
- if (!$input->getOption('verbose'))
- {
- $progress->advance();
- }
+ $progress->advance();
}
$this->db->sql_freeresult($result);
@@ -159,10 +181,10 @@ class generate extends \phpbb\console\command\command
$this->commit_changes($thumbnail_created);
}
- if (!$input->getOption('verbose'))
- {
- $progress->finish();
- }
+ $progress->finish();
+
+ $io->newLine(2);
+ $io->success($this->user->lang('CLI_THUMBNAIL_GENERATING_DONE'));
return 0;
}
diff --git a/phpBB/phpbb/console/command/thumbnail/recreate.php b/phpBB/phpbb/console/command/thumbnail/recreate.php
index 5d3edbd699..382da290bf 100644
--- a/phpBB/phpbb/console/command/thumbnail/recreate.php
+++ b/phpBB/phpbb/console/command/thumbnail/recreate.php
@@ -49,12 +49,11 @@ class recreate extends \phpbb\console\command\command
if ($input->getOption('verbose'))
{
- $parameters['-v'] = true;
+ $parameters['-' . str_repeat('v', $output->getVerbosity() - 1)] = true;
}
$this->getApplication()->setAutoExit(false);
- $output->writeln('' . $this->user->lang('CLI_THUMBNAIL_DELETING') . '');
$input_delete = new ArrayInput($parameters);
$return = $this->getApplication()->run($input_delete, $output);
@@ -62,8 +61,6 @@ class recreate extends \phpbb\console\command\command
{
$parameters['command'] = 'thumbnail:generate';
- $output->writeln('');
- $output->writeln('' . $this->user->lang('CLI_THUMBNAIL_GENERATING') . '');
$input_create = new ArrayInput($parameters);
$return = $this->getApplication()->run($input_create, $output);
}
diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php
index 094d8ca051..b5ed02b5e7 100644
--- a/tests/console/thumbnail_test.php
+++ b/tests/console/thumbnail_test.php
@@ -11,6 +11,7 @@
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
use Symfony\Component\Console\Application;
@@ -36,7 +37,7 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
public function setUp()
{
- global $config, $phpbb_root_path, $phpEx;
+ global $config, $phpbb_root_path, $phpEx, $phpbb_filesystem;
parent::setUp();
@@ -47,12 +48,15 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
));
$this->db = $this->db = $this->new_dbal();
- $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ $this->user = $this->getMock('\phpbb\user', array(), array(
+ new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
+ '\phpbb\datetime')
+ );
$this->phpbb_root_path = $phpbb_root_path;
$this->phpEx = $phpEx;
$this->cache = $this->getMock('\phpbb\cache\service', array(), array(new phpbb_mock_cache(), $this->config, $this->db, $this->phpbb_root_path, $this->phpEx));
- $this->cache->expects($this->any())->method('obtain_attach_extensions')->will($this->returnValue(array(
+ $this->cache->expects(self::any())->method('obtain_attach_extensions')->will(self::returnValue(array(
'png' => array('display_cat' => ATTACHMENT_CATEGORY_IMAGE),
'txt' => array('display_cat' => ATTACHMENT_CATEGORY_NONE),
)));
@@ -61,38 +65,18 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
$this->application->add(new generate($this->user, $this->db, $this->cache, $this->phpbb_root_path, $this->phpEx));
$this->application->add(new delete($this->user, $this->db, $this->phpbb_root_path));
$this->application->add(new recreate($this->user));
- }
- public function test_thumbnails()
- {
+ $phpbb_filesystem = new \phpbb\filesystem\filesystem();
+
copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/test_png_1');
copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/test_png_2');
copy(dirname(__FILE__) . '/fixtures/png.png', $this->phpbb_root_path . 'files/thumb_test_png_2');
copy(dirname(__FILE__) . '/fixtures/txt.txt', $this->phpbb_root_path . 'files/test_txt');
+ }
- $command_tester = $this->get_command_tester('thumbnail:generate');
- $exit_status = $command_tester->execute(array('command' => 'thumbnail:generate'));
-
- $this->assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1'));
- $this->assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2'));
- $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt'));
- $this->assertSame(0, $exit_status);
-
- $command_tester = $this->get_command_tester('thumbnail:delete');
- $exit_status = $command_tester->execute(array('command' => 'thumbnail:delete'));
-
- $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1'));
- $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2'));
- $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt'));
- $this->assertSame(0, $exit_status);
-
- $command_tester = $this->get_command_tester('thumbnail:recreate');
- $exit_status = $command_tester->execute(array('command' => 'thumbnail:recreate'));
-
- $this->assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1'));
- $this->assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2'));
- $this->assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt'));
- $this->assertSame(0, $exit_status);
+ protected function tearDown()
+ {
+ parent::tearDown();
unlink($this->phpbb_root_path . 'files/test_png_1');
unlink($this->phpbb_root_path . 'files/test_png_2');
@@ -101,6 +85,33 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
unlink($this->phpbb_root_path . 'files/thumb_test_png_2');
}
+ public function test_thumbnails()
+ {
+ $command_tester = $this->get_command_tester('thumbnail:generate');
+ $exit_status = $command_tester->execute(array('command' => 'thumbnail:generate'));
+
+ self::assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1'));
+ self::assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2'));
+ self::assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt'));
+ self::assertSame(0, $exit_status);
+
+ $command_tester = $this->get_command_tester('thumbnail:delete');
+ $exit_status = $command_tester->execute(array('command' => 'thumbnail:delete'));
+
+ self::assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1'));
+ self::assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2'));
+ self::assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt'));
+ self::assertSame(0, $exit_status);
+
+ $command_tester = $this->get_command_tester('thumbnail:recreate');
+ $exit_status = $command_tester->execute(array('command' => 'thumbnail:recreate'));
+
+ self::assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_1'));
+ self::assertSame(true, file_exists($this->phpbb_root_path . 'files/thumb_test_png_2'));
+ self::assertSame(false, file_exists($this->phpbb_root_path . 'files/thumb_test_txt'));
+ self::assertSame(0, $exit_status);
+ }
+
public function get_command_tester($command_name)
{
$command = $this->application->find($command_name);