Skip to content

Commit

Permalink
Don't double wrap transports
Browse files Browse the repository at this point in the history
In tests MailPanel can run multiple times and could potentially wrap
its own wrappers. This prevents duplicate proxies from being added.

Refs cakephp#721
  • Loading branch information
markstory committed Jan 16, 2020
1 parent 20f2260 commit c08193b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Panel/MailPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,24 @@ public function initialize()

$log = $this->emailLog = new ArrayObject();

foreach ($configs as $name => &$transport) {
foreach ($configs as $name => $transport) {
if (is_object($transport)) {
$configs[$name] = new DebugKitTransport(['debugKitLog' => $log], $transport);
if (!$transport instanceof DebugKitTransport) {
$configs[$name] = new DebugKitTransport(['debugKitLog' => $log], $transport);
}
continue;
}

$className = App::className($transport['className'], 'Mailer/Transport', 'Transport');

if (!$className) {
if (!$className || $className === DebugKitTransport::class) {
continue;
}

$transport['originalClassName'] = $transport['className'];
$transport['className'] = 'DebugKit.DebugKit';
$transport['debugKitLog'] = $log;

$configs[$name] = $transport;
}
$property->setValue($configs);
}
Expand Down

0 comments on commit c08193b

Please sign in to comment.