Problem/Motivation

This only works because of some problem in the php file syncer

We discovered this in #3362143: Use the rsync file syncer by default

Steps to reproduce

Proposed resolution

fix it

Remaining tasks

User interface changes

API changes

Data model changes

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

tedbow created an issue. See original summary.

tedbow’s picture

Status: Active » Needs review
tedbow’s picture

Ok added a test. The test fails on 3.0.x

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

  • phenaproxima committed 7e87dcff on 3.0.x authored by tedbow
    Issue #3363937 by tedbow: Failure marker file should be excluded using a...
phenaproxima’s picture

Status: Reviewed & tested by the community » Fixed
wim leers’s picture

Status: Fixed » Needs work
Issue tags: +Needs upstream bugfix
  1. How is it possible that this was never noticed? 😱
  2. How will we prevent this from reoccurring in the future? (No generic test coverage was added here, only test coverage for this one specific case.)

\PhpTuf\ComposerStager\Domain\Value\PathList\PathListInterface::add() has as a default implementation \PhpTuf\ComposerStager\Infrastructure\Value\PathList\PathList::add() which looks like this:

    public function add(array $paths): void
    {
        $this->assertValidInput($paths);
        $this->paths = array_merge($this->paths, $paths);
    }

which does:

    /**
     * @param array<string> $paths
     *
     * @throws \PhpTuf\ComposerStager\Domain\Exception\InvalidArgumentException
     */
    private function assertValidInput(array $paths): void
    {
        foreach ($paths as $path) {
            /** @psalm-suppress DocblockTypeContradiction */
            if (!is_string($path)) {
                $given = is_object($path)
                    ? $path::class
                    : gettype($path);

                throw new InvalidArgumentException(sprintf(
                    'Paths must be strings. Given %s.',
                    $given,
                ));
            }
        }
    }

So it just validates that it receives strings. Not relative paths. IOW: this needs an upstream bugfix in Composer Stager, because the input validation is inadequate.

Reopening for that.

wim leers’s picture

Issue tags: +Needs followup

… and we need a follow-up to either convert the test that was added here to a generic test, or to remove the test that was introduced here.

tedbow’s picture

Assigned: Unassigned » tedbow

Yep sorry I meant make upstream bug report.

from chatting with @travis.carden the intend behavior for exclusions is

  1. Paths can be relative or absolute
  2. but absolute paths should only be used if they are within the source directory.

In our case on apply() the source directory is our stage directory so this should have always been relative.

Not sure why this worked before with php. The rsync copier acts as intended.

will make follow-ups

tedbow’s picture

wim leers’s picture

but absolute paths should only be used if they are within the source directory.

Makes sense. And that's indeed the upstream bug. Clarified that at https://github.com/php-tuf/composer-stager/issues/176#issuecomment-15733....

tedbow’s picture

Assigned: tedbow » Unassigned
Status: Needs work » Fixed
Issue tags: -Needs upstream bugfix, -Needs followup

Closing since we have upstream issue

wim leers’s picture

🥳

wim leers’s picture

Assigned: Unassigned » tedbow
Status: Fixed » Needs review

In which issue did Automatic Updates start requiring a Composer Stager version that includes this fix, which is what allowed us to close this?

tedbow’s picture

We can leave this open for committing the requirement change when https://github.com/php-tuf/composer-stager/issues/176 is committed.

I think though we should consider why CollectPathsToExcludeEvent needs to implement PathListInterface.

PathListInterface only has to methods getAll() and add()

for add() we already have 2 methods on <code>CollectPathsToExcludeEvent , addPathsRelativeToWebRoot() and addPathsRelativeToProjectRoot() so we never call CollectPathsToExcludeEvent::add()

tedbow’s picture

Assigned: tedbow » Unassigned
phenaproxima’s picture

Status: Needs review » Closed (duplicate)

This is a duplicate of a fixed issue, which had upstream aspects which were also corrected months ago. I think this is thoroughly done.