Skip to content

Commit

Permalink
Issue #3151096 by dww, jungle: Replace use of whitelist in \Drupal\Co…
Browse files Browse the repository at this point in the history
…re\Utility\ProjectInfo

(cherry picked from commit 72c276f60c8354375544d5b9a7b78bee3aa47656)
  • Loading branch information
alexpott committed Aug 4, 2020
1 parent df8b6cb commit ab2b9b8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/Drupal/Core/Utility/ProjectInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class ProjectInfo {
* @param bool $status
* Boolean that controls what status (enabled or uninstalled) to process out
* of the $list and add to the $projects array.
* @param array $additional_whitelist
* @param array $additional_elements
* (optional) Array of additional elements to be collected from the .info.yml
* file. Defaults to array().
*/
public function processInfoList(array &$projects, array $list, $project_type, $status, array $additional_whitelist = []) {
public function processInfoList(array &$projects, array $list, $project_type, $status, array $additional_elements = []) {
foreach ($list as $file) {
// Just projects with a matching status should be listed.
if ($file->status != $status) {
Expand Down Expand Up @@ -111,7 +111,7 @@ public function processInfoList(array &$projects, array $list, $project_type, $s
'name' => $project_name,
// Only save attributes from the .info.yml file we care about so we do
// not bloat our RAM usage needlessly.
'info' => $this->filterProjectInfo($file->info, $additional_whitelist),
'info' => $this->filterProjectInfo($file->info, $additional_elements),
'datestamp' => $file->info['datestamp'],
'includes' => [$file->getName() => $file->info['name']],
'project_type' => $project_display_type,
Expand Down Expand Up @@ -165,7 +165,7 @@ public function getProjectName(Extension $file) {
* @param array $info
* Array of .info.yml file data as returned by
* \Drupal\Core\Extension\InfoParser.
* @param $additional_whitelist
* @param $additional_elements
* (optional) Array of additional elements to be collected from the .info.yml
* file. Defaults to array().
*
Expand All @@ -174,8 +174,8 @@ public function getProjectName(Extension $file) {
*
* @see \Drupal\Core\Utility\ProjectInfo::processInfoList()
*/
public function filterProjectInfo($info, $additional_whitelist = []) {
$whitelist = [
public function filterProjectInfo($info, $additional_elements = []) {
$elements = [
'_info_file_ctime',
'datestamp',
'major',
Expand All @@ -185,8 +185,8 @@ public function filterProjectInfo($info, $additional_whitelist = []) {
'project status url',
'version',
];
$whitelist = array_merge($whitelist, $additional_whitelist);
return array_intersect_key($info, array_combine($whitelist, $whitelist));
$elements = array_merge($elements, $additional_elements);
return array_intersect_key($info, array_combine($elements, $elements));
}

}

0 comments on commit ab2b9b8

Please sign in to comment.