goldsky / spiefeed

Feeds aggregator for MODx Revolution based on SimplePie
http://simplepie.org/
8 stars 4 forks source link

Missing cache folder, realpath() does not support nonexistent directory #17

Open pixelchutes opened 8 years ago

pixelchutes commented 8 years ago

In the current default handling for setCacheLocation, it processes the result through realpath(). If the defined folder does not exist _(e.g. {corepath}components/spiefeed/cache), the code attempts to create it.

However, it never succeeds.

Since realpath() cannot handle nonexistent files/folders, the result is always empty. That said, the value passed to mkdir is an empty string, and the cache folder is not created. The only reason it does not error is the error suppressor @ at the front.

$cachePath = realpath($scriptProperties['setCacheLocation']);
if (!is_dir($cachePath)) {
    @mkdir($cachePath, 0755);
}

Perhaps the default handling should pass $scriptProperties['setCacheLocation'] to mkdir(), or come up with an alternative to realpath() to handle this correctly?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/36659981-missing-cache-folder-realpath-does-not-support-nonexistent-directory?utm_campaign=plugin&utm_content=tracker%2F5873226&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F5873226&utm_medium=issues&utm_source=github).
pixelchutes commented 8 years ago

Perhaps it is due to assets/components/spiefeed/cache existing, but $defaultCacheLocation check is actually prefixed by core_path?

Personally, I think it would be safer to store in core_path (and not assets_path) anyway, so perhaps the folder (and accompanying .gitignore) also needs to be created?