8000 Promises are not handled correctly in processReinstallOperation · Issue #118 · vaimo/composer-patches · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Promises are not handled correctly in processReinstallOperation #118
Open
@LeanderFS

Description

@LeanderFS

While testing another issue locally, I encountered an issue which happens when you clear the composer cache before running on of the patch commands (e.g. patch:redo). The processReinstallOperation, and more specifically the download part, seems to resolve the promise too early without waiting for download completion, resulting in an empty package directory while patching.
The issue is clearly reproducible by adding some debug information to the promise chain in processReinstallOperation, which shows that the patch operation happens before the installation of the package.

I managed to resolve the issue by using the Composer\Utils\SyncHelper::downloadAndInstallPackageSync but this incurs passing the Composer object around. I'm not well versed in composer plugins but will make a PR regardless.

To Reproduce
Steps to reproduce the behavior:

  1. Run composer clear-cache
  2. Run composer patch:redo --vvv

Optionally change the processReinstallOperation to add debug information

        return $installationManager
            ->uninstall($repository, $uninstallOperation)
            ->then(function () use ($installationManager, $installOperation, $repository) {
                echo "Package uninstalled \n";
                $package = $installOperation->getPackage();
                return $installationManager->getInstaller($package->getType())->download($package);
            })
            ->then(function () use ($installationManager, $installOperation, $repository) {
                echo "Package downloaded \n";
                $installationManager->install($repository, $installOperation);
            })->then(function () {
                echo "Package installed \n";
            });

Expected
Packages are downloaded and installed before attempting to patch.

Actual
Packages are downloaded but patching begins before the installation process completed.

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

      0