Problem/Motivation
There is a bug in StageBase::stageDirectoryExists(). The problem is that it calls getStageDirectory(), which gives you a path that may not exist if we're in the PreCreate phase of the stage life cycle.
Proposed resolution
The method should return the result of is_dir($this->getStageDirectory()). It should look, overall, like this:
try {
return is_dir($this->getStageDirectory());
}
catch (\LogicException) {
return FALSE;
}
A reasonable way to test this is to add a simple PreCreateEvent listener (using addTestEventListener()) which confirms that stageDirectoryExists() returns TRUE, and that the stage directory actually exists ($this->assertDirectoryExists()).
Comments
Comment #2
phenaproximaComment #3
wim leers@phenaproxima How did you find this? How did this bug manifest?
(Tagging for this, but based on the current summary, this is already actionable, so keeping .)
Comment #4
wim leersI happened to stumble upon the place where @phenaproxima discovered this.
This is a hard blocker for #3316617: Add a validator to check that PHP-TUF's Composer integration is present and configured correctly, so matching priority and tags.
Comment #5
phenaproximaSelf-assigning to fix.
Comment #7
phenaproximaThis manifested while writing a test for the PHP-TUF validator -- I need to get the allow-plugins config value for the stage directory, if it exists. So used
stageDirectoryExists()-- only to discover that it is lying to me during pre-create, telling me that the stage directory exists when it doesn't.I've now fixed this with a test, and confirmed that the test fails if I revert the fix.
Comment #8
tedbowI confirmed that test fails without the fix. Looks good.
Comment #10
phenaproximaComment #11
wim leers👍 Thanks for the context in #7! 😊 That addresses , and the issue is so short anyway, so untagging.