1
0
Fork 0

Fix require command crashing at the end if no lock file is present, fixes #11814

pull/11895/head
Jordi Boggiano 2024-02-06 13:46:46 +01:00
parent bff129f4f5
commit ef6c224ec2
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 9 additions and 7 deletions

View File

@ -558,13 +558,15 @@ EOT
throw new \RuntimeException('Unable to read '.$this->json->getPath().' contents to update the lock file hash.'); throw new \RuntimeException('Unable to read '.$this->json->getPath().' contents to update the lock file hash.');
} }
$lockFile = Factory::getLockFile($this->json->getPath()); $lockFile = Factory::getLockFile($this->json->getPath());
$lockMtime = filemtime($lockFile); if (file_exists($lockFile)) {
$lock = new JsonFile($lockFile); $lockMtime = filemtime($lockFile);
$lockData = $lock->read(); $lock = new JsonFile($lockFile);
$lockData['content-hash'] = Locker::getContentHash($contents); $lockData = $lock->read();
$lock->write($lockData); $lockData['content-hash'] = Locker::getContentHash($contents);
if (is_int($lockMtime)) { $lock->write($lockData);
@touch($lockFile, $lockMtime); if (is_int($lockMtime)) {
@touch($lockFile, $lockMtime);
}
} }
} }
} }