Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c3bb279

Browse files
committed
Fix other issues with readonly caches, refs #10906
1 parent f8324e0 commit c3bb279

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### [2.2.15] 2022-07-01
22

3-
* Fixed support for read-only caches where the filesystem is not writable (#10906)
3+
* Fixed support for `cache-read-only` where the filesystem is not writable (#10906)
44
* Fixed type error when using `allow-plugins: true` (#10909)
55
* Fixed @putenv scripts receiving arguments passed to the command (#10846)
66
* Fixed support for spaces in paths with binary proxies on Windows (#10836)

src/Composer/Cache.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function isEnabled()
104104
|| !is_writable($this->root)
105105
)
106106
) {
107-
$this->io->writeError('<warning>Cannot create cache directory ' . $this->root . ', or directory is not writable. Proceeding without cache</warning>');
107+
$this->io->writeError('<warning>Cannot create cache directory ' . $this->root . ', or directory is not writable. Proceeding without cache. See also cache-read-only config if your filesystem is read-only.</warning>');
108108
$this->enabled = false;
109109
}
110110
}
@@ -265,7 +265,7 @@ public function gcIsNecessary()
265265
*/
266266
public function remove($file)
267267
{
268-
if ($this->isEnabled()) {
268+
if ($this->isEnabled() && !$this->readOnly) {
269269
$file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
270270
if (file_exists($this->root . $file)) {
271271
return $this->filesystem->unlink($this->root . $file);
@@ -280,7 +280,7 @@ public function remove($file)
280280
*/
281281
public function clear()
282282
{
283-
if ($this->isEnabled()) {
283+
if ($this->isEnabled() && !$this->readOnly) {
284284
$this->filesystem->emptyDirectory($this->root);
285285

286286
return true;
@@ -314,7 +314,7 @@ public function getAge($file)
314314
*/
315315
public function gc($ttl, $maxSize)
316316
{
317-
if ($this->isEnabled()) {
317+
if ($this->isEnabled() && !$this->readOnly) {
318318
$expire = new \DateTime();
319319
$expire->modify('-'.$ttl.' seconds');
320320

0 commit comments

Comments
 (0)