8000 [WebProfilerBundle] deprecated import/export commands by fabpot · Pull Request #15709 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[WebProfilerBundle] deprecated import/export commands #15709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions UPGRADE-2.8.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,11 @@ DependencyInjection
</services>
```

Web Development Toolbar
-----------------------
WebProfiler
-----------

The `profiler:import` and `profiler:export` commands have been deprecated and
will be removed in 3.0.

The web development toolbar has been completely redesigned. This update has
introduced some changes in the HTML markup of the toolbar items.
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

2.8.0
-----

* deprecated profiler:import and profiler:export commands

2.7.0
-----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
/**
* Exports a profile.
*
* @deprecated since version 2.8, to be removed in 3.0.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ExportCommand extends Command
Expand Down Expand Up @@ -49,7 +51,7 @@ protected function configure()
{
$this
->setName('profiler:export')
->setDescription('Exports a profile')
->setDescription('[DEPRECATED] Exports a profile')
->setDefinition(array(
new InputArgument('token', InputArgument::REQUIRED, 'The profile token'),
))
Expand All @@ -64,6 +66,10 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$formatter = $this->getHelper('formatter');

$output->writeln($formatter->formatSection('warning', 'The profiler:export command is deprecated since version 2.8 and will be removed in 3.0', 'comment'));

$token = $input->getArgument('token');

if (!$profile = $this->profiler->loadProfile($token)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
/**
* Imports a profile.
*
* @deprecated since version 2.8, to be removed in 3.0.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ImportCommand extends Command
Expand Down Expand Up @@ -49,7 +51,7 @@ protected function configure()
{
$this
->setName('profiler:import')
->setDescription('Imports a profile')
->setDescription('[DEPRECATED] Imports a profile')
->setDefinition(array(
new InputArgument('filename', InputArgument::OPTIONAL, 'The profile path'),
))
Expand All @@ -68,6 +70,10 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$formatter = $this->getHelper('formatter');

$output->writeln($formatter->formatSection('warning', 'The profiler:import command is deprecated since version 2.8 and will be removed in 3.0', 'comment'));

$data = '';
if ($input->getArgument('filename')) {
$data = file_get_contents($input->getArgument('filename'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
namespace Symfony\Bundle\WebProfilerBundle\Tests\Command;

use Symfony\Bundle\WebProfilerBundle\Command\ExportCommand;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\Profiler\Profile;

/**
* @group legacy
*/
class ExportCommandTest extends \PHPUnit_Framework_TestCase
{
/**
Expand All @@ -28,7 +32,14 @@ public function testExecuteWithUnknownToken()
->getMock()
;

$helperSet = new HelperSet();
$helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper');
$helper->expects($this->any())->method('formatSection');
$helperSet->set($helper, 'formatter');

$command = new ExportCommand($profiler);
$command->setHelperSet($helperSet);

$commandTester = new CommandTester($command);
$commandTester->execute(array('token' => 'TOKEN'));
}
Expand All @@ -44,7 +55,14 @@ public function testExecuteWithToken()
$profile = new Profile('TOKEN');
$profiler->expects($this->once())->method('loadProfile')->with('TOKEN')->will($this->returnValue($profile));

$helperSet = new HelperSet();
$helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper');
$helper->expects($this->any())->method('formatSection');
$helperSet->set($helper, 'formatter');

$command = new ExportCommand($profiler);
$command->setHelperSet($helperSet);

$commandTester = new CommandTester($command);
$commandTester->execute(array('token' => 'TOKEN'));
$this->assertEquals($profiler->export($profile), $commandTester->getDisplay());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
namespace Symfony\Bundle\WebProfilerBundle\Tests\Command;

use Symfony\Bundle\WebProfilerBundle\Command\ImportCommand;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\HttpKernel\Profiler\Profile;

/**
* @group legacy
*/
class ImportCommandTest extends \PHPUnit_Framework_TestCase
{
public function testExecute()
Expand All @@ -27,7 +31,14 @@ public function testExecute()

$profiler->expects($this->once())->method('import')->will($this->returnValue(new Profile('TOKEN')));

$helperSet = new HelperSet();
$helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper');
$helper->expects($this->any())->method('formatSection');
$helperSet->set($helper, 'formatter');

$command = new ImportCommand($profiler);
$command->setHelperSet($helperSet);

$commandTester = new CommandTester($command);
$commandTester->execute(array('filename' => __DIR__.'/../Fixtures/profile.data'));
$this->assertRegExp('/Profile "TOKEN" has been successfully imported\./', $commandTester->getDisplay());
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/HttpKernel/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

2.8.0
-----

* deprecated `Profiler::import` and `Profiler::export`

2.7.0
-----

Expand Down
8 changes: 8 additions & 0 deletions src/Symfony/Component/HttpKernel/Profiler/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,13 @@ public function purge()
* @param Profile $profile A Profile instance
*
* @return string The exported data
*
* @deprecated since Symfony 2.8, to be removed in 3.0.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the trigger deprecation code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

*/
public function export(Profile $profile)
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);

return base64_encode(serialize($profile));
}

Expand All @@ -149,9 +153,13 @@ public function export(Profile $profile)
* @param string $data A data string as exported by the export() method
*
* @return Profile A Profile instance
*
* @deprecated since Symfony 2.8, to be removed in 3.0.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deprecation warnings should be triggered

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

*/
public function import($data)
{
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);

$profile = unserialize(base64_decode($data));

if ($this->storage->read($profile->getToken())) {
Expand Down
0