Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
378 views
in Themes by

In a theme there is a function for cache and I am getting warnings.

        $options = array('compress' => true);

        $parser = new Less_Parser($options);

        $update_cache = !file_exists($cache_file);

        $vars = ra_get_less_variables();

        if (!$update_cache) {

            $cacheData = unserialize(file_get_contents($cache_file));

            foreach ($cacheData['files'] as $file => $fileData) {

                if ($fileData['filemtime'] < filemtime($file)) {

                    $update_cache = true;

                    break;

                }

            }

        }

The line with the warning (PHP Warning:  filemtime(): stat failed) is:

                if ($fileData['filemtime'] < filemtime($file)) {

How can I fix this?

Thank you.

Q2A version: 1.8.8
by
Anyone that can help here?

1 Answer

+1 vote
by
selected by
 
Best answer

Check if the file actually exists:

if (!file_exists($file) or $fileData['filemtime'] < filemtime($file)) {
    $update_cache = true;
    break;
}

by
Thank you, it seems this works just fine.

Welcome to the Q&A site for Question2Answer.

If you have a question about Q2A, please ask here, in English.

To report a bug, please create a new issue on Github or ask a question here with the bug tag.

If you just want to try Q2A, please use the demo site.

Categories

...