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
Comments
Comment #3
mile23MR makes the error check explicit and removes a variable.
Comment #4
greg.1.anderson commentedLGTM
Comment #5
mile23Comment #7
alexpottI've added a test. Here's the test-only patch.
Comment #9
alexpottThe fail test fails on HEAD and passes with the MR.
Comment #10
alexpottCommitted 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.
Comment #15
effulgentsia commentedThere's a claim in #3328893: Composer Scaffold Vendor Duplication that this caused that regression. I do not know if that claim is accurate.