1

I've been tasked with updating an older EE plug-in that caches Weather Information from Weather Underground. Since WUnderground closed their API a few weeks ago, I've since transitioned the plug-in to open weather map and I've got data coming through properly that I can see on the front end, so all's well there.

The plug-in has some caching functionality where data is cached to reduce unnecessary API calls, but right now I'm having trouble troubleshooting that. Here's a quick example of the code:

function fetch_feed( $key, $location, $language ) {

        $parsed_json = FALSE;

        // Check cache

        $cache_path = APPPATH . 'cache/' . $this->cache_name . '/';
        $cache_refresh = $this->cache_refresh * 60; // seconds

        // Check cache folder exists

        if( ! @is_dir( $cache_path ) ) {
            @mkdir( $cache_path );
            @chmod( $cache_path, 0777 );
        }

Since the cache that add-ons use has moved from system/expressionengine/cache/ to system/user/cache/ I'm getting an error:

Warning fopen(/ee/legacy/cache/weather_forecast/214bc472f656e049d8fcc62458fb70e6):
failed to open stream: No such file or directory

I take it I'll likely have to edit the cache path variable, is there a smarter variable to user here aside from '/user/cache/'? My cache folder should have the correct permissions since a number of other add-ons are writing to it without issue.

0

After echoing the entire variable and tweaking the code a bit, I've settled on this:

$cache_path = SYSPATH . 'user/cache/' . $this->cache_name . '/';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.