Remove dependency on symfony/finder

Created on 16 November 2022, about 2 years ago
Updated 1 March 2023, over 1 year ago

Problem/Motivation

Per @phenaproxima, we only use symfony/finder for convenience and symfony/config for autowiring:

adam.hoenich: My preference would actually be to remove the dependency on symfony/finder. We currently depend on it for convenience. With a little work I think we could refactor it out
wim.leers: ah!
adam.hoenich: And maybe even symfony/config too, if we can find a way to load in Composer Stager and its autowiring
wim.leers: is that what itโ€™s for?!
adam.hoenich: It is.
wim.leers: lol
wim.leers: okay
adam.hoenich: If you look at PackageManagerServiceProvider, itโ€™s the only way I could expose all those classes to the container. It needed things that exist in symfony/config

We should verify that we need these dependencies. A whole new dependency for Drupal core/AU is not worth it if it just saves a few LoC.

Steps to reproduce

Proposed resolution

  1. Remove dependency on symfony/finder
  2. Add symfony/config as a core dependency per #11: ๐Ÿ“Œ Add symfony/config to core's dependencies for package_manager Closed: duplicate

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ“Œ Task
Status

Fixed

Version

3.0

Component

Code

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Now that ๐Ÿ› phpcs stopped working since the switch to testing on Drupal 10.0.x by default Fixed is finally done, this is the next most important issue! Will continue this tomorrow.

  • Assigned to omkar.podey
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia omkar.podey

    Drupal CI behaves weirdly , does not run tests according to drupalci.yml , hence the retests.

  • @omkarpodey opened merge request.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia omkar.podey

    Test times

    New PR
    kernel - 6:24 mins
    functional - 13 mins
    build - 14 mins

    baseline
    kernel - 7.24
    functional - 5.42
    build - 12 mins

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia omkar.podey

    We can clearly see that functional tests are running slower , so i thought the only thing that functional tests are using that we changed is package_manager/tests/src/Traits/FixtureUtilityTrait.php but even without the changes in it they still seem to run slower.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia omkar.podey

    Performance test results

    The old finder and the RecursiveDirectoryIterator are definitely looking at different files and the RecursiveDirectoryIterator is making more passes on the same files (indicated by the numbers in front of the discovered file names)

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tedbow Ithaca, NY, USA
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia omkar.podey

    From the latest test i think i can conclude 2 things

    1. There are no weird subdirectory inside subdirectory folders from a previous run or any old undeleted files
    2. The RecursiveDirectoryIterator is the only one that see's the weird structure.
  • Issue was unassigned.
  • Assigned to wim leers
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia omkar.podey

    I did try to create a symlink locally but was unable to recreate the same pattern of paths.

  • Issue was unassigned.
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    It doesn't need to be me who works on this, so if somebody wants to dig into this before I get to it, please do!

  • Assigned to yash.rode
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia yash.rode pune
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia yash.rode pune

    When I debugged this I get ~7500 from withOutFinder() and ~250 files from withFinder().

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia yash.rode pune

    Test failing with on self::assertSame($txt_files_finder, $txt_file_no_finder); line in \Drupal\Tests\automatic_updates\Unit\PerformanceTest::testPerformance(). The results are identical still the test is failing.

  • Assigned to wim leers
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia yash.rode pune

    Need help with the error

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Reproduced the infamous recursive Omkar locally:

    โ€ฆ
    +    '/Users/wim.leers/core/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/sites/simpletest/36713557/ygxJCv2dGVN5BPYVCRvz/modules/example/.git/ignore.txt' => 1
    +    '/Users/wim.leers/core/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/sites/simpletest/18800034/files/config_gKQI85yVN-z5lKiIDAsy5GJSfwwYfJeBfF3z64BkA6qwCgXD-pg4m_mECxzSHxcTvdV_RwLHCQ/sync/README.txt' => 1
    +    '/Users/wim.leers/core/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/sites/simpletest/18067332/bP1bRMh0Cq4TfBGnoQUr/core/node_modules/ignore.txt' => 1
    +    '/Users/wim.leers/core/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/omkar/sites/simpletest/18067332/bP1bRMh0Cq4TfBGnoQUr/sites/default/stage.txt' => 1
    โ€ฆ
    

    โ†’ I'll continue here.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Turns out that the reason the 3321933-performance-test is actually very simple:

    • withFinder() never calls \Symfony\Component\Finder\Finder::followLinks(), which is why it is ignoring symlinks entirely
    • withOutFinder() specifies $flags |= \FilesystemIterator::FOLLOW_SYMLINKS;, which causes it to do the opposite

    โ‡’ the recursive Omkar mystery is solved: https://git.drupalcode.org/project/automatic_updates/-/merge_requests/64...

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    That puts us at:

    +    '/Users/wim.leers/core/omkar/core/.deprecation-ignore.txt' => 1
         '/Users/wim.leers/core/omkar/core/INSTALL.sqlite.txt' => 1
         '/Users/wim.leers/core/omkar/core/INSTALL.pgsql.txt' => 1
         '/Users/wim.leers/core/omkar/core/lib/Drupal/Core/README.txt' => 1
    @@ @@
         '/Users/wim.leers/core/omkar/sites/simpletest/29115714/fXQhTRGlQ1k5Az4B6AYc/sites/example.com/files/ignore.txt' => 1
         '/Users/wim.leers/core/omkar/sites/simpletest/29115714/fXQhTRGlQ1k5Az4B6AYc/sites/simpletest/ignore.txt' => 1
         '/Users/wim.leers/core/omkar/sites/simpletest/29115714/fXQhTRGlQ1k5Az4B6AYc/private/ignore.txt' => 1
    +    '/Users/wim.leers/core/omkar/sites/simpletest/29115714/fXQhTRGlQ1k5Az4B6AYc/.git/ignore.txt' => 1
         '/Users/wim.leers/core/omkar/sites/simpletest/29115714/fXQhTRGlQ1k5Az4B6AYc/modules/example/node_modules/ignore.txt' => 1
    +    '/Users/wim.leers/core/omkar/sites/simpletest/29115714/fXQhTRGlQ1k5Az4B6AYc/modules/example/.git/ignore.txt' => 1
         '/Users/wim.leers/core/omkar/sites/simpletest/11853257/files/config_MnP16Yj8pfbM5wIkoIceZlpcxP5K1FivVn1ZzPJ9iY0ZkGih2Fc-hM2q
    

    โ†’ better, but still not perfect.

    Reason for that: we're again not yet matching Finder's behavior, which has this:

        public function __construct()
        {
            $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
        }
    

    โ€ฆ while we have nothing like that at all in our logic in PerformanceTest.

    Now tests pass:

    PHPUnit 9.5.26 by Sebastian Bergmann and contributors.
    
    Testing /Users/wim.leers/core/modules/contrib/automatic_updates/tests/src/Unit
    ....................                                              20 / 20 (100%)
    
    Time: 00:31.553, Memory: 10.00 MB
    
    OK (20 tests, 40 assertions)
    Process finished with exit code 0
    

    So it's faster 100% of the time. Adding

    var_dump(['with finder' => $with_finder, 'without finder' => $without_finder]);
    

    makes that more clear:

    Rarray(2) {
      ["with finder"]=>
      float(0.9062411785125732)
      ["without finder"]=>
      float(0.6564769744873047)
    }
    Rarray(2) {
      ["with finder"]=>
      float(0.9076869487762451)
      ["without finder"]=>
      float(0.6771509647369385)
    }
    Rarray(2) {
      ["with finder"]=>
      float(0.9273748397827148)
      ["without finder"]=>
      float(0.6514010429382324)
    }
    Rarray(2) {
      ["with finder"]=>
      float(0.9032847881317139)
      ["without finder"]=>
      float(0.6541171073913574)
    }
    <snip>
    

    I bet that the root cause for the actual MR (https://git.drupalcode.org/project/automatic_updates/-/merge_requests/59...) was similar: none of the code in package_manager is calling Finder::followLinks()!

  • @wim-leers opened merge request.
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    New MR opened โ€ฆ waiting for it to fail before pushing the commit that will remove \FilesystemIterator::FOLLOW_SYMLINKS ๐Ÿค“

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Looks like \FilesystemIterator::CURRENT_AS_SELF is causing phpstan confusion? ๐Ÿ˜ณ ๐Ÿ˜ฌ Trying moreโ€ฆ

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Well well well โ€ฆ looks like this even works just like that, by just literally porting the MR I had created months ago against 8.x-2.x to 3.0.x (and fixing the PHPStan violations which even then were not running anymore apparently) โ€ฆ ๐Ÿ˜ณ

    I bet:

    But! It's still slower! The functional tests no longer time out like in January, but they run excruciatingly slow. So pushed a commit just now to stop following symlinks, just like the validators were doing previously.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Hah! ec30ba81 even finished before d2c2aac2 even despite it starting tests roughly an hour laterโ€ฆ ๐Ÿ˜… In fact, it's currently still going:

    โ€ฆ
    00:51:49.032 Drupal\Tests\automatic_updates_extensions\Functional\PreUpda   3 passes                                      
    01:21:38.843 Drupal\Tests\automatic_updates_extensions\Functional\UpdateE   3 passes                                      
    01:21:40.820 Drupal\Tests\automatic_updates_extensions\Functional\Display   2 passes                                      
    01:21:41.494 Drupal\Tests\automatic_updates\Functional\TableLooksCorrectT   2 passes    
    โ€ฆ
    
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    โš ๏ธ While #49 matches HEAD's current behavior, after ๐Ÿ“Œ Add symlink support to Composer Stager 2.0, require that version, and simplify UX & tests accordingly Fixed lands, we will be accepting most symlinks. Which means validators should also follow them while validating. Captured at #3319507-26: [upstream] Support more symlinks, document why certain symlinks are not supported โ†’ .

    CorePackageManifestTest and FixtureUtilityTrait will not be affected.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Posted informative comments on the open MR, closed all other MRs. This is now hard-blocked on review, at last! ๐Ÿฅณ

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    This looks really good. I think it could maybe use a little consolidation and documentation but I have no objections otherwise.

  • Assigned to wim leers
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    #3305568: Create a validator that detects duplicate info.yml files in the stage on apply โ†’ introduced DuplicateInfoFileValidator. It is what introduced ignoreUnreadableDirs() without documenting why. So that leaves some lack of clarity about how we should support this.

    So I propose to instead just reuse core's ExtensionDiscovery ๐Ÿ˜Š

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    A question, a request to revert something that didn't need to change, and a couple of nits. Then this, in my opinion, is ready and I will be glad to see it land!

  • Issue was unassigned.
  • Status changed to RTBC over 1 year ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    All feedback addressed! ๐Ÿ‘ Some really good catches in there! ๐Ÿ‘ Thanks for the thorough review ๐Ÿ˜Š

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    Re-titling, because the final MR does not document why we need symfony/config. That's okay, though.

  • Status changed to Fixed over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States phenaproxima Massachusetts

    Glad to see this alpha blocker bite the dust!

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States effulgentsia

    Re-titling, because the final MR does not document why we need symfony/config.

    Here's a follow-up for that: ๐Ÿ“Œ Remove dependency on symfony/config Fixed

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    #61: I did document that as part of working on this issue: see #11, and ๐Ÿ“Œ Add symfony/config to core's dependencies for package_manager Closed: duplicate . This is all stated in the issue summary. Nowhere in Drupal core is it documented in code why a certain composer package is being depended upon, so doing that here would've been out of scope.

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

Production build 0.71.5 2024