8000 feature #15709 [WebProfilerBundle] deprecated import/export commands … · symfony/symfony@0383559 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0383559

Browse files
committed
feature #15709 [WebProfilerBundle] deprecated import/export commands (fabpot)
This PR was merged into the 2.8 branch. Discussion ---------- [WebProfilerBundle] deprecated import/export commands | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | part of #11742 | License | MIT | Doc PR | n/a Commits ------- 943fec9 [HtppKernel] deprecated Profiler::import/export 17e00b9 [WebProfilerBundle] deprecated import/export commands
2 parents 224b19b + 943fec9 commit 0383559

File tree

8 files changed

+66
-4
lines changed

8 files changed

+66
-4
lines changed

UPGRADE-2.8.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,11 @@ DependencyInjection
325325
</services>
326326
```
327327

328-
Web Development Toolbar
329-
-----------------------
328+
WebProfiler
329+
-----------
330+
331+
The `profiler:import` and `profiler:export` commands have been deprecated and
332+
will be removed in 3.0.
330333

331334
The web development toolbar has been completely redesigned. This update has
332335
introduced some changes in the HTML markup of the toolbar items.

src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
2.8.0
5+
-----
6+
7+
* deprecated profiler:import and profiler:export commands
8+
49
2.7.0
510
-----
611

src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
/**
2121
* Exports a profile.
2222
*
23+
* @deprecated since version 2.8, to be removed in 3.0.
24+
*
2325
* @author Fabien Potencier <fabien@symfony.com>
2426
*/
2527
class ExportCommand extends Command
@@ -49,7 +51,7 @@ prote 8000 cted function configure()
4951
{
5052
$this
5153
->setName('profiler:export')
52-
->setDescription('Exports a profile')
54+
->setDescription('[DEPRECATED] Exports a profile')
5355
->setDefinition(array(
5456
new InputArgument('token', InputArgument::REQUIRED, 'The profile token'),
5557
))
@@ -64,6 +66,10 @@ protected function configure()
6466

6567
protected function execute(InputInterface $input, OutputInterface $output)
6668
{
69+
$formatter = $this->getHelper('formatter');
70+
71+
$output->writeln($formatter->formatSection('warning', 'The profiler:export command is deprecated since version 2.8 and will be removed in 3.0', 'comment'));
72+
6773
$token = $input->getArgument('token');
6874

6975
if (!$profile = $this->profiler->loadProfile($token)) {

src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
/**
2121
* Imports a profile.
2222
*
23+
* @deprecated since version 2.8, to be removed in 3.0.
24+
*
2325
* @author Fabien Potencier <fabien@symfony.com>
2426
*/
2527
class ImportCommand extends Command
@@ -49,7 +51,7 @@ protected function configure()
4951
{
5052
$this
5153
->setName('profiler:import')
52-
->setDescription('Imports a profile')
54+
->setDescription('[DEPRECATED] Imports a profile')
5355
->setDefinition(array(
5456
new InputArgument('filename', InputArgument::OPTIONAL, 'The profile path'),
5557
))
@@ -68,6 +70,10 @@ protected function configure()
6870

6971
protected function execute(InputInterface $input, OutputInterface $output)
7072
{
73+
$formatter = $this->getHelper('formatter');
74+
75+
$output->writeln($formatter->formatSection('warning', 'The profiler:import command is deprecated since version 2.8 and will be removed in 3.0', 'comment'));
76+
7177
$data = '';
7278
if ($input->getArgument('filename')) {
7379
$data = file_get_contents($input->getArgument('filename'));

src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
namespace Symfony\Bundle\WebProfilerBundle\Tests\Command;
1313

1414
use Symfony\Bundle\WebProfilerBundle\Command\ExportCommand;
15+
use Symfony\Component\Console\Helper\HelperSet;
1516
use Symfony\Component\Console\Tester\CommandTester;
1617
use Symfony\Component\HttpKernel\Profiler\Profile;
1718

19+
/**
20+
* @group legacy
21+
*/
1822
class ExportCommandTest ext F438 ends \PHPUnit_Framework_TestCase
1923
{
2024
/**
@@ -28,7 +32,14 @@ public function testExecuteWithUnknownToken()
2832
->getMock()
2933
;
3034

35+
$helperSet = new HelperSet();
36+
$helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper');
37+
$helper->expects($this->any())->method('formatSection');
38+
$helperSet->set($helper, 'formatter');
39+
3140
$command = new ExportCommand($profiler);
41+
$command->setHelperSet($helperSet);
42+
3243
$commandTester = new CommandTester($command);
3344
$commandTester->execute(array('token' => 'TOKEN'));
3445
}
@@ -44,7 +55,14 @@ public function testExecuteWithToken()
4455
$profile = new Profile('TOKEN');
4556
$profiler->expects($this->once())->method('loadProfile')->with('TOKEN')->will($this->returnValue($profile));
4657

58+
$helperSet = new HelperSet();
59+
$helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper');
60+
$helper->expects($this->any())->method('formatSection');
61+
$helperSet->set($helper, 'formatter');
62+
4763
$command = new ExportCommand($profiler);
64+
$command->setHelperSet($helperSet);
65+
4866
$commandTester = new CommandTester($command);
4967
$commandTester->execute(array('token' => 'TOKEN'));
5068
$this->assertEquals($profiler->export($profile), $commandTester->getDisplay());

src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ImportCommandTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
namespace Symfony\Bundle\WebProfilerBundle\Tests\Command;
1313

1414
use Symfony\Bundle\WebProfilerBundle\Command\ImportCommand;
15+
use Symfony\Component\Console\Helper\HelperSet;
1516
use Symfony\Component\Console\Tester\CommandTester;
1617
use Symfony\Component\HttpKernel\Profiler\Profile;
1718

19+
/**
20+
* @group legacy
21+
*/
1822
class ImportCommandTest extends \PHPUnit_Framework_TestCase
1923
{
2024
public function testExecute()
@@ -27,7 +31,14 @@ public function testExecute()
2731

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

34+
$helperSet = new HelperSet();
35+
$helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper');
36+
$helper->expects($this->any())->method('formatSection');
37+
$helperSet->set($helper, 'formatter');
38+
3039
$command = new ImportCommand($profiler);
40+
$command->setHelperSet($helperSet);
41+
3142
$commandTester = new CommandTester($command);
3243
$commandTester->execute(array('filename' => __DIR__.'/../Fixtures/profile.data'));
3344
$this->assertRegExp('/Profile "TOKEN" has been successfully imported\./', $commandTester->getDisplay());

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
2.8.0
5+
-----
6+
7+
* deprecated `Profiler::import` and `Profiler::export`
8+
49
2.7.0
510
-----
611

src/Symfony/Component/HttpKernel/Profiler/Profiler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,13 @@ public function purge()
137137
* @param Profile $profile A Profile instance
138138
*
139139
* @return string The exported data
140+
*
141+
* @deprecated since Symfony 2.8, to be removed in 3.0.
140142
*/
141143
public function export(Profile $profile)
142144
{
145+
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
146+
143147
return base64_encode(serialize($profile));
144148
}
145149

@@ -149,9 +153,13 @@ public function export(Profile $profile)
149153
* @param string $data A data string as exported by the export() method
150154
*
151155
* @return Profile A Profile instance
156+
*
157+
* @deprecated since Symfony 2.8, to be removed in 3.0.
152158
*/
153159
public function import($data)
154160
{
161+
@trigger_error('The '.__METHOD__.' method is deprecated since version 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
162+
155163
$profile = unserialize(base64_decode($data));
156164

157165
if ($this->storage->read($profile->getToken())) {

0 commit comments

Comments
 (0)
0