Problem/Motivation

If you scaffold an empty file, (one which exists in the source directory, but has length=0), the scaffold plugin throws an error.

Steps to reproduce

Proposed resolution

ReplaceOp::copyScaffold() says this:

    $success = file_put_contents($destination->fullPath(), $this->contents());
    if (!$success) {
      throw new \RuntimeException($interpolator->interpolate("Could not copy source file <info>[src-rel-path]</info> to <info>[dest-rel-path]</info>!"));
    }

file_put_contents() can return 0 for the length of the written file, or FALSE on failure. Since we're checking for !$success, we generate an error in either case.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#7 3283498-6.test-only.patch2.32 KBalexpott

Issue fork drupal-3283498

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

Mile23 created an issue. See original summary.

mile23’s picture

Status: Active » Needs review

MR makes the error check explicit and removes a variable.

greg.1.anderson’s picture

Status: Needs review » Reviewed & tested by the community

LGTM

mile23’s picture

alexpott made their first commit to this issue’s fork.

alexpott’s picture

StatusFileSize
new2.32 KB

I've added a test. Here's the test-only patch.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 3283498-6.test-only.patch, failed testing. View results

alexpott’s picture

Status: Needs work » Reviewed & tested by the community

The fail test fails on HEAD and passes with the MR.

alexpott’s picture

Version: 9.5.x-dev » 9.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed fc14cbc685 to 10.0.x and 5a83c90a73 to 9.5.x and 03bdeb1d9d to 9.4.x. Thanks!

Backported to 9.4.x as this is a non-disruptive bug fix.

  • alexpott committed fc14cbc on 10.0.x
    Issue #3283498 by Mile23, alexpott: Scaffold ReplaceOp::copyScaffold()...

  • alexpott committed 5a83c90 on 9.5.x
    Issue #3283498 by Mile23, alexpott: Scaffold ReplaceOp::copyScaffold()...

  • alexpott committed 03bdeb1 on 9.4.x
    Issue #3283498 by Mile23, alexpott: Scaffold ReplaceOp::copyScaffold()...

Status: Fixed » Closed (fixed)

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

effulgentsia’s picture

There's a claim in #3328893: Composer Scaffold Vendor Duplication that this caused that regression. I do not know if that claim is accurate.