From 72c276f60c8354375544d5b9a7b78bee3aa47656 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Tue, 4 Aug 2020 09:33:32 +0100 Subject: [PATCH] Issue #3151096 by dww, jungle: Replace use of whitelist in \Drupal\Core\Utility\ProjectInfo --- core/lib/Drupal/Core/Utility/ProjectInfo.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/lib/Drupal/Core/Utility/ProjectInfo.php b/core/lib/Drupal/Core/Utility/ProjectInfo.php index 395a23bfade8..63e17da2abf1 100644 --- a/core/lib/Drupal/Core/Utility/ProjectInfo.php +++ b/core/lib/Drupal/Core/Utility/ProjectInfo.php @@ -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) { @@ -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, @@ -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(). * @@ -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', @@ -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)); } } -- GitLab