Commit 0c099aa3 authored by Jess's avatar Jess
Browse files

Issue #2620576 by cilefen, alexpott, chapf, xjm, longwave, dawehner: fnmatch()...

Issue #2620576 by cilefen, alexpott, chapf, xjm, longwave, dawehner: fnmatch() is not available on all environments (i.e QNAP QTS)
parent 5580fe9c
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -207,8 +207,9 @@ public function listAll($prefix = '') {
    $files = scandir($dir);

    $names = array();
    $pattern = '/^' . preg_quote($prefix, '/') . '.*' . preg_quote($extension, '/') . '$/';
    foreach ($files as $file) {
      if ($file[0] !== '.' && fnmatch($prefix . '*' . $extension, $file)) {
      if ($file[0] !== '.' && preg_match($pattern, $file)) {
        $names[] = basename($file, $extension);
      }
    }
@@ -290,6 +291,7 @@ public function getAllCollectionNames() {
   */
  protected function getAllCollectionNamesHelper($directory) {
    $collections = array();
    $pattern = '/\.' . preg_quote($this->getFileExtension(), '/') . '$/';
    foreach (new \DirectoryIterator($directory) as $fileinfo) {
      if ($fileinfo->isDir() && !$fileinfo->isDot()) {
        $collection = $fileinfo->getFilename();
@@ -309,7 +311,7 @@ protected function getAllCollectionNamesHelper($directory) {
        // collection.
        // @see \Drupal\Core\Config\FileStorage::listAll()
        foreach (scandir($directory . '/' . $collection) as $file) {
          if ($file[0] !== '.' && fnmatch('*.' . $this->getFileExtension(), $file)) {
          if ($file[0] !== '.' && preg_match($pattern, $file)) {
            $collections[] = $collection;
            break;
          }
+4 −2
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ protected function getAllFolders() {
   */
  public function getComponentNames(array $list) {
    $extension = '.' . $this->getFileExtension();
    $pattern = '/' . preg_quote($extension, '/') . '$/';
    $folders = array();
    foreach ($list as $extension_object) {
      // We don't have to use ExtensionDiscovery here because our list of
@@ -203,7 +204,7 @@ public function getComponentNames(array $list) {
        $files = scandir($directory);

        foreach ($files as $file) {
          if ($file[0] !== '.' && fnmatch('*' . $extension, $file)) {
          if ($file[0] !== '.' && preg_match($pattern, $file)) {
            $folders[basename($file, $extension)] = $directory;
          }
        }
@@ -220,6 +221,7 @@ public function getComponentNames(array $list) {
   */
  public function getCoreNames() {
    $extension = '.' . $this->getFileExtension();
    $pattern = '/' . preg_quote($extension, '/') . '$/';
    $folders = array();
    $directory = $this->getCoreFolder();
    if (is_dir($directory)) {
@@ -230,7 +232,7 @@ public function getCoreNames() {
      $files = scandir($directory);

      foreach ($files as $file) {
        if ($file[0] !== '.' && fnmatch('*' . $extension, $file)) {
        if ($file[0] !== '.' && preg_match($pattern, $file)) {
          $folders[basename($file, $extension)] = $directory;
        }
      }
+1 −1
Original line number Diff line number Diff line
@@ -335,7 +335,7 @@ public function getLangcodes() {
      // Collect languages included with CKEditor based on file listing.
      $files = scandir('core/assets/vendor/ckeditor/lang');
      foreach ($files as $file) {
        if ($file[0] !== '.' && fnmatch('*.js', $file)) {
        if ($file[0] !== '.' && preg_match('/\.js$/', $file)) {
          $langcode = basename($file, '.js');
          $langcodes[$langcode] = $langcode;
        }
+6 −0
Original line number Diff line number Diff line
@@ -70,6 +70,12 @@ public function testlistAll() {
    $config_files = $this->storage->listAll();
    $this->assertIdentical($config_files, $expected_files, 'Relative path, two config files found.');

    // @todo https://www.drupal.org/node/2666954 FileStorage::listAll() is
    //   case-sensitive. However, \Drupal\Core\Config\DatabaseStorage::listAll()
    //   is case-insensitive.
    $this->assertIdentical(['system.performance'], $this->storage->listAll('system'), 'The FileStorage::listAll() with prefix works.');
    $this->assertIdentical([], $this->storage->listAll('System'), 'The FileStorage::listAll() is case sensitive.');

    // Initialize FileStorage with absolute file path.
    $absolute_path = realpath($this->directory);
    $storage_absolute_path = new FileStorage($absolute_path);
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ public function getAllTemplates() {
      if (file_exists($full_directory)) {
        $files = scandir($full_directory);
        foreach ($files as $file) {
          if ($file[0] !== '.' && fnmatch('*.yml', $file)) {
          if ($file[0] !== '.' && preg_match('/\.yml$/', $file)) {
            $templates[basename($file, '.yml')] = Yaml::decode(file_get_contents("$full_directory/$file"));
          }
        }