Unverified Commit 5ca99d59 authored by alexpott's avatar alexpott

Issue #3151096 by dww, jungle: Replace use of whitelist in \Drupal\Core\Utility\ProjectInfo

(cherry picked from commit 72c276f6)
parent 1894efe8
...@@ -35,11 +35,11 @@ class ProjectInfo { ...@@ -35,11 +35,11 @@ class ProjectInfo {
* @param bool $status * @param bool $status
* Boolean that controls what status (enabled or uninstalled) to process out * Boolean that controls what status (enabled or uninstalled) to process out
* of the $list and add to the $projects array. * 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 * (optional) Array of additional elements to be collected from the .info.yml
* file. Defaults to array(). * 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) { foreach ($list as $file) {
// Just projects with a matching status should be listed. // Just projects with a matching status should be listed.
if ($file->status != $status) { if ($file->status != $status) {
...@@ -111,7 +111,7 @@ public function processInfoList(array &$projects, array $list, $project_type, $s ...@@ -111,7 +111,7 @@ public function processInfoList(array &$projects, array $list, $project_type, $s
'name' => $project_name, 'name' => $project_name,
// Only save attributes from the .info.yml file we care about so we do // Only save attributes from the .info.yml file we care about so we do
// not bloat our RAM usage needlessly. // not bloat our RAM usage needlessly.
'info' => $this->filterProjectInfo($file->info, $additional_whitelist), 'info' => $this->filterProjectInfo($file->info, $additional_elements),
'datestamp' => $file->info['datestamp'], 'datestamp' => $file->info['datestamp'],
'includes' => [$file->getName() => $file->info['name']], 'includes' => [$file->getName() => $file->info['name']],
'project_type' => $project_display_type, 'project_type' => $project_display_type,
...@@ -165,7 +165,7 @@ public function getProjectName(Extension $file) { ...@@ -165,7 +165,7 @@ public function getProjectName(Extension $file) {
* @param array $info * @param array $info
* Array of .info.yml file data as returned by * Array of .info.yml file data as returned by
* \Drupal\Core\Extension\InfoParser. * \Drupal\Core\Extension\InfoParser.
* @param $additional_whitelist * @param $additional_elements
* (optional) Array of additional elements to be collected from the .info.yml * (optional) Array of additional elements to be collected from the .info.yml
* file. Defaults to array(). * file. Defaults to array().
* *
...@@ -174,8 +174,8 @@ public function getProjectName(Extension $file) { ...@@ -174,8 +174,8 @@ public function getProjectName(Extension $file) {
* *
* @see \Drupal\Core\Utility\ProjectInfo::processInfoList() * @see \Drupal\Core\Utility\ProjectInfo::processInfoList()
*/ */
public function filterProjectInfo($info, $additional_whitelist = []) { public function filterProjectInfo($info, $additional_elements = []) {
$whitelist = [ $elements = [
'_info_file_ctime', '_info_file_ctime',
'datestamp', 'datestamp',
'major', 'major',
...@@ -185,8 +185,8 @@ public function filterProjectInfo($info, $additional_whitelist = []) { ...@@ -185,8 +185,8 @@ public function filterProjectInfo($info, $additional_whitelist = []) {
'project status url', 'project status url',
'version', 'version',
]; ];
$whitelist = array_merge($whitelist, $additional_whitelist); $elements = array_merge($elements, $additional_elements);
return array_intersect_key($info, array_combine($whitelist, $whitelist)); return array_intersect_key($info, array_combine($elements, $elements));
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment