Skip to content

Fix vendor:publish dumping all assets for unknown tags - #396

Merged
techmahedy merged 2 commits into
doppar:4.xfrom
xentixar:fix/vendor-publish-unknown-tag
Oct 31, 2026
Merged

techmahedy merged 2 commits into
doppar:4.xfrom
xentixar:fix/vendor-publish-unknown-tag

Conversation

@xentixar

Copy link
Copy Markdown
Member

Pull Request Checklist

Q A
Branch? 4.x
Bug fix? yes
New feature? no
Deprecations? no
Issues -
License MIT

Description

vendor:publish --tag=... asked every launcher for that tag. When a launcher did not register the tag, pathsForProviderOrGroup() returned null, and pathsToPublish() fell back to merging all of that launcher's publishable paths.

So publishing e.g. ripple-config also tried to publish unrelated packages such as Insight's insight.php.

Return an empty array for unknown tag/launcher lookups so only matching groups are published. Publishing with no tag/launcher still publishes everything.

Checklist

  • Tests have been added or updated
  • Documentation has been updated if necessary
  • Code follows the project coding standards
  • All tests pass locally

When --tag did not match a launcher's publish groups, pathsToPublish fell
through to every registered path, so other packages' configs were published
alongside the requested tag.
@xentixar xentixar self-assigned this Oct 31, 2026
@xentixar xentixar added the bug Something isn't working label Oct 31, 2026

@techmahedy techmahedy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @xentixar, thanks for tracking this down. The --tag fix works, but the --launcher regression below needs fixing before merge.

Problem: vendor:publish --launcher=... now publishes nothing

php pool vendor:publish --launcher="Doppar\Queue\QueueLauncher"

On this branch that publishes nothing, but it still prints "Published assets for launcher: ...", so the failure is silent. Picking a launcher from the interactive prompt does the same.

Cause

VendorPublishCommand::publishLauncher() calls $launcher->pathsToPublish($launcherClassName).

$this->publishes is keyed by source path (see ServiceLauncher::publishes()), not by launcher class name, so isset($this->publishes[$provider]) is false for a class name. That call used to rely on falling through to "return everything this launcher registered". The new branch turns that into an empty result:

} elseif ($group || $provider) {
    return [];
}

Behavior before and after

Checked with a launcher that has one ungrouped and one grouped path:

Call Before After this PR
pathsToPublish(Launcher::class) all of the launcher's paths [] ❌
unknown tag everything (the bug) [] ✅
known tag that group that group
no args everything everything

The new tests don't catch this. They only call pathsToPublish() with an unknown tag, or with a made-up provider plus an unknown tag. None passes a launcher class name on its own.

Suggested fix (either one)

  1. Drop the new elseif ($group || $provider) branch. Make the group-only case return [] when the group is missing, and leave provider-only as it was.
  2. Keep your ServiceLauncher change. In publishLauncher(), call $launcherClass->pathsToPublish() with no arguments, since it already holds the launcher instance.

Tests to add

  • pathsToPublish(SomeLauncher::class) returns the launcher's full set, grouped and ungrouped.
  • Command-level tests for VendorPublishCommand:
    • --tag=<unknown> errors and writes nothing.
    • --tag=<known> publishes only that group.
    • --launcher=<class> publishes everything that launcher registered.

Note on --tag=ripple

php pool vendor:publish --tag=ripple
ERROR  Unable to locate tag: ripple

That error is probably correct. As far as I can see, Ripple registers its tags as ripple-config and ripple-assets, not ripple. Please try --tag=ripple-config to confirm it publishes only ripple.php, and add that as a test.

Thanks again. The tag fix is the right behavior.

@techmahedy

Copy link
Copy Markdown
Member

Hi @xentixar, thanks for the fix. Publishing one tag no longer drags in other packages' files, which is the behavior we want.

While testing the PR I found a regression, so I pushed a follow-up commit (1ad86ef) on top of yours.

What was wrong

php pool vendor:publish --launcher="Doppar\Queue\QueueLauncher" published nothing, but still printed a success message.

publishLauncher() passes the launcher class name as $provider, and $this->publishes is keyed by source path, not by class name. That call used to rely on the old fall-through returning everything the launcher registered. The new elseif ($group || $provider) { return []; } branch turns that into an empty list.

What the commit changes

  • ServiceLauncher::pathsForProviderOrGroup(): an unknown group returns [] (your fix, kept). Provider-only behaves as it did before the PR, so --launcher gets the launcher's full set again.
  • VendorPublishCommand:
    • --launcher, --tag, and both together are resolved in one place. Nothing is copied unless every requested tag and launcher exists.

    • --tag=a,b is supported.

    • An unknown tag or launcher now exits with code 1. It used to exit 0. The error suggests similar tags (for example, --tag=ripple suggests ripple-assets and ripple-config) and lists the available tags or launchers.

    • A missing source file is reported as MISSING and fails, instead of printing a fake success line.

      The other labels are OVERWRITTEN (with --force), SKIPPED and FAILED.

  • ServiceLauncher::publishTags(): new public method, used for the suggestions.

One behavior change to be aware of

Unknown tag and unknown launcher now return exit code 1. Scripts that relied on the old exit 0 would notice.

Thanks again for catching the original bug.

@techmahedy
techmahedy merged commit ae42fab into doppar:4.x Oct 31, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants