Skip to content
Snippets Groups Projects
Unverified Commit c2ae6841 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3151092 by ravi.shankar, durgeshs, deepakaryan1988, alexpott, dww:...

Issue #3151092 by ravi.shankar, durgeshs, deepakaryan1988, alexpott, dww: Replace use of whitelist/blacklist in \Drupal\Core\Extension classes
parent 8fd13be1
Branches
Tags
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
......@@ -11,7 +11,7 @@
* subdirectory tree recursion is avoided.
*
* The list of globally ignored directory names is defined in the
* RecursiveExtensionFilterIterator::$blacklist property.
* RecursiveExtensionFilterIterator::$skippedFolders property.
*
* In addition, all 'config' directories are skipped, unless the directory path
* ends with 'modules/config', so as to still find the config module provided by
......@@ -39,7 +39,7 @@ class RecursiveExtensionFilterIterator extends \RecursiveFilterIterator {
*
* @var array
*/
protected $whitelist = [
protected $allowedExtensionTypes = [
'profiles',
'modules',
'themes',
......@@ -54,7 +54,7 @@ class RecursiveExtensionFilterIterator extends \RecursiveFilterIterator {
*
* @var array
*/
protected $blacklist = [
protected $skippedFolders = [
// Object-oriented code subdirectories.
'src',
'lib',
......@@ -87,13 +87,13 @@ class RecursiveExtensionFilterIterator extends \RecursiveFilterIterator {
*
* @param \RecursiveIterator $iterator
* The iterator to filter.
* @param array $blacklist
* (optional) Add to the blacklist of directories that should be filtered
* out during the iteration.
* @param string[] $skipped_folders
* (optional) Add to the list of directories that should be filtered out
* during the iteration.
*/
public function __construct(\RecursiveIterator $iterator, array $blacklist = []) {
public function __construct(\RecursiveIterator $iterator, array $skipped_folders = []) {
parent::__construct($iterator);
$this->blacklist = array_merge($this->blacklist, $blacklist);
$this->skippedFolders = array_merge($this->skippedFolders, $skipped_folders);
}
/**
......@@ -102,13 +102,13 @@ public function __construct(\RecursiveIterator $iterator, array $blacklist = [])
* @param bool $flag
* Pass FALSE to skip all test directories in the discovery. If TRUE,
* extensions in test directories will be discovered and only the global
* directory blacklist in RecursiveExtensionFilterIterator::$blacklist is
* applied.
* directory skip list in RecursiveExtensionFilterIterator::$skippedFolders
* is applied.
*/
public function acceptTests($flag = FALSE) {
$this->acceptTests = $flag;
if (!$this->acceptTests) {
$this->blacklist[] = 'tests';
$this->skippedFolders[] = 'tests';
}
}
......@@ -117,8 +117,8 @@ public function acceptTests($flag = FALSE) {
*/
public function getChildren() {
$filter = parent::getChildren();
// Pass on the blacklist.
$filter->blacklist = $this->blacklist;
// Pass on the skipped folders list.
$filter->skippedFolders = $this->skippedFolders;
// Pass the $acceptTests flag forward to child iterators.
$filter->acceptTests($this->acceptTests);
return $filter;
......@@ -141,7 +141,7 @@ public function accept() {
// recurse into the whole filesystem tree that possibly contains other
// files aside from Drupal.
if ($this->current()->getSubPath() == '') {
return in_array($name, $this->whitelist, TRUE);
return in_array($name, $this->allowedExtensionTypes, TRUE);
}
// 'config' directories are special-cased here, because every extension
// contains one. However, those default configuration directories cannot
......@@ -154,8 +154,8 @@ public function accept() {
if ($name == 'config') {
return substr($this->current()->getPathname(), -14) == 'modules/config';
}
// Accept the directory unless the name is blacklisted.
return !in_array($name, $this->blacklist, TRUE);
// Accept the directory unless the folder is skipped.
return !in_array($name, $this->skippedFolders, TRUE);
}
else {
// Only accept extension info files.
......
......@@ -164,8 +164,8 @@ public function scan($type, $include_tests = NULL) {
$searchdirs[static::ORIGIN_SITES_ALL] = 'sites/all';
// Search for contributed and custom extensions in top-level directories.
// The scan uses a whitelist to limit recursion to the expected extension
// type specific directory names only.
// The scan uses a list of extension types to limit recursion to the
// expected extension type specific directory names only.
$searchdirs[static::ORIGIN_ROOT] = '';
// Simpletest uses the regular built-in multi-site functionality of Drupal
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment