Problem/Motivation

I was working on #3195568: [PP-1] Support recursive discovery for migration plugins and noticed we're using a custom Drupal\Component\FileSystem\RegexDirectoryIterator to iterate over the directory files and apply the regex filter.

It seems the same result can be achieved by using native iterators like this:
new \RegexIterator(new \FilesystemIterator($path), 'pattern');

Actually, that's not true, because the \FilesystemIterator() will iterate over SplFileInfo objects, which returns full path name in toString() method. It makes it harder to set a regular expression for the file name. For example, '/^\d/' pattern won't match 1.yml file.

I think what we can do here - change the base class of RegexDirectoryIterator to simplify the class. Instead of \FilterIterator, we can use \RegexIterator, which already accepts a pattern.

Proposed resolution

Change the base class of RegexDirectoryIterator;

API changes

Nope.

Issue fork drupal-3195700

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Matroskeen created an issue. See original summary.

matroskeen’s picture

Issue summary: View changes
Status: Active » Needs review
matroskeen’s picture

matroskeen’s picture

Issue summary: View changes
matroskeen’s picture

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ranjith_kumar_k_u’s picture

StatusFileSize
new1.54 KB

Rerolled #2

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

shubham chandra’s picture

StatusFileSize
new1.55 KB

Re-rolled Patch against #10 in Drupal 10.1.x

bnjmnm’s picture

#12 was an unnecessary reroll that will not receive credit - it's just #10. As I've mentioned to you several times @Shubham Chandra - you can check if a patch truly needs a reroll by clicking "add test/retest" on the most recent patch and applying it to the most recent Drupal version. Drupal getting a new version doesn't necessarily mean a reroll is needed.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

Seems like a valid addition and don't think it will need any kind of change record.

  • catch committed 9857cab4 on 10.1.x
    Issue #3195700 by Matroskeen, ranjith_kumar_k_u: RegexDirectoryIterator...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Nice clean-up. Committed/pushed to 10.1.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.