mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 05:48:11 +08:00
Fixes #16580: Delete unused php message files in MessageController if $removeUnused option is on
This commit is contained in:
committed by
Alexander Makarov
parent
b4adada51e
commit
8150cd1ed4
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
||||
2.0.16 under development
|
||||
------------------------
|
||||
|
||||
- Bug #16580: Delete unused php message files in MessageController if `$removeUnused` option is on (Groonya)
|
||||
- Bug #16022: Fix UniqueValidator for PostgreSQL. Checks the uniqueness of keys in `jsonb` field (lav45)
|
||||
- Bug #16903: Fixed 'yii\validators\NumberValidator' method 'isNotNumber' returns false for true/false value (annechko)
|
||||
- Bug #16648: Html::strtolower() was corrupting UTF-8 strings (Kolyunya)
|
||||
|
||||
@ -665,6 +665,10 @@ EOD;
|
||||
$this->stdout("Saving messages to $coloredFileName...\n");
|
||||
$this->saveMessagesCategoryToPHP($msgs, $file, $overwrite, $removeUnused, $sort, $category, $markUnused);
|
||||
}
|
||||
|
||||
if ($removeUnused) {
|
||||
$this->deleteUnusedPhpMessageFiles($dirName, array_keys($messages));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -883,6 +887,17 @@ EOD;
|
||||
}
|
||||
}
|
||||
|
||||
private function deleteUnusedPhpMessageFiles($dirName, $existingCategories)
|
||||
{
|
||||
$messageFiles = FileHelper::findFiles($dirName);
|
||||
foreach ($messageFiles as $file) {
|
||||
$category = preg_replace('#\.php$#', '', basename($file));
|
||||
if (!in_array($category, $existingCategories, true)) {
|
||||
unlink($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $configFile
|
||||
* @throws Exception If configuration file does not exists.
|
||||
|
||||
Reference in New Issue
Block a user