Skip to content

Google\Task\Composer::cleanup doesn't remove all of ignored services #6502

@ilyaplot

Description

@ilyaplot

Environment details

  • OS: Mac OS, Linux (alpine, ubuntu and centos)
  • PHP version: 7.2 - 8.3
  • Package name and version: "google/apiclient": "2.18.2", "google/apiclient-services": "0.396.0"

Steps to reproduce

  1. Create composer.json like this
{
    "require": {
        "google/apiclient": "2.18.2",
        "google/apiclient-services": "0.396.0"
    },
    "extra": {
        "google/apiclient-services": [
            "Gmail"
        ],
    },
    "config": {
        "process-timeout": 600
    },
    "scripts": {
        "pre-autoload-dump": "Google\\Task\\Composer::cleanup"
    }
}
  1. Run composer install 2 times or more
  2. See that every run the Google\Task\Composer::cleanup removed a few of services instead all ignored.
# First run
$ composer update php
....
> Google\Task\Composer::cleanup
Removing 304 google services

# Second run
$ composer update php
....
> Google\Task\Composer::cleanup
Removing 292 google services

# Third run
$ composer update php
....
> Google\Task\Composer::cleanup
Removing 273 google services

How to fix the problem

We have the code

foreach ($filesToRemove as $fileToRemove) {
    $filesystem->remove($fileToRemove);
    $filesystem->remove($fileToRemove . '.php');
}

I don't know why (any experts here?), but calling remove reduces number of iterations for $filesToRemove

I tried to prepare a list of files to remove and iterate an array. It solved the problem.

I will create pull request shortly.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions