Вопрос

I seem to get this error on my local server when the site is loaded for the first time e.g. in the morning. Once I do a refresh it's gone...

I'm using silverstripe 3.1.

Is there a way to prevent this locally or is this a bug?

Warning: mkdir(): File exists in /framework/core/manifest/ManifestCache.php on line 19

Looks like line 19 is trying to create a TEMP folder but it already exists...

function __construct($name) {
    $this->folder = TEMP_FOLDER.'/'.$name;
    if (!is_dir($this->folder)) mkdir($this->folder);
}

Should that function check if the folder exists first e.g.

if (!is_dir($this->folder) || !file_exists($this->folder)) mkdir($this->folder);
Это было полезно?

Решение

Seems that there exists a file with the same name as the directory. That's why is_dir() returns false but mkdir() fails because the file exists.

You can change this to:

if (!file_exists($this->folder)) mkdir($this->folder);

This should work so far.

However it is necessary to mention that such file existence tests are vulnerable against race conditions by design. That's why you need to additionally check the return value of mkdir():

if (!file_exists($this->folder)) {
    if(@mkdir($this->folder) === FALSE) {
        throw new Exception('failed to create ' . $this->folder);
    }
}

This may not being required if you (or the framework) has registered a global error handler which turns warning into exceptions, because mkdir() will throw a warning on errors.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top