Skip to content

Commit 1fbd391

Browse files
authored
Fix #293: Logged errors and warnings were duplicated in some cases
1 parent 87f8862 commit 1fbd391

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Yii Framework 2 apidoc extension Change Log
44
3.0.7 under development
55
-----------------------
66

7-
- no changes in this release.
7+
- Bug #293: Logged errors and warnings were duplicated in some cases (rhertogh)
88

99

1010
3.0.6 November 18, 2022

commands/ApiController.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,17 @@ public function actionIndex(array $sourceDirs, $targetDir)
126126
$renderer->render($context, $targetDir);
127127

128128
if (!empty($context->errors)) {
129-
ArrayHelper::multisort($context->errors, 'file');
130-
file_put_contents($targetDir . '/errors.txt', print_r($context->errors, true));
131-
$this->stdout(count($context->errors) . " errors have been logged to $targetDir/errors.txt\n", Console::FG_RED, Console::BOLD);
129+
$errors = array_map('unserialize', array_unique(array_map('serialize', $context->errors)));
130+
ArrayHelper::multisort($errors, 'file');
131+
file_put_contents($targetDir . '/errors.txt', print_r($errors, true));
132+
$this->stdout(count($errors) . " errors have been logged to $targetDir/errors.txt\n", Console::FG_RED, Console::BOLD);
132133
}
133134

134135
if (!empty($context->warnings)) {
135-
ArrayHelper::multisort($context->warnings, 'file');
136-
file_put_contents($targetDir . '/warnings.txt', print_r($context->warnings, true));
137-
$this->stdout(count($context->warnings) . " warnings have been logged to $targetDir/warnings.txt\n", Console::FG_YELLOW, Console::BOLD);
136+
$warnings = array_map('unserialize', array_unique(array_map('serialize', $context->warnings)));
137+
ArrayHelper::multisort($warnings, 'file');
138+
file_put_contents($targetDir . '/warnings.txt', print_r($warnings, true));
139+
$this->stdout(count($warnings) . " warnings have been logged to $targetDir/warnings.txt\n", Console::FG_YELLOW, Console::BOLD);
138140
}
139141

140142
return 0;

0 commit comments

Comments
 (0)