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.');
}
$lockFile = Factory::getLockFile($this->json->getPath());
$lockMtime = filemtime($lockFile);
$lock = new JsonFile($lockFile);
$lockData = $lock->read();
$lockData['content-hash'] = Locker::getContentHash($contents);
$lock->write($lockData);
if (is_int($lockMtime)) {
@touch($lockFile, $lockMtime);
if (file_exists($lockFile)) {
$lockMtime = filemtime($lockFile);
$lock = new JsonFile($lockFile);
$lockData = $lock->read();
$lockData['content-hash'] = Locker::getContentHash($contents);
$lock->write($lockData);
if (is_int($lockMtime)) {
@touch($lockFile, $lockMtime);
}
}
}
}