Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Mattias

    (@darkwhispering)

    Hi @tezt

    That must be a bug. I will see if I can replicate your problem and find a fix if so.

    / Mattias

    I am having this same issue. Is there anything to resolve this bug yet?

    / Tyler

    Any fixed on this?

    I really like this plugin. I’ve searching for one like this for quite some time. But I have the same issue. When new images are uploaded, it’s not showing, before Ihave cleared the cache.

    Any solution for this?

    Thanks for a great plugin.

    I have a similar issue. Also, it does not appear that any images are pulling in from pic.twitter.com. Has this been an issue since the new version has been released?

    Thanks again

    Hey guys,

    I have a fix for this issue, or at least I’ve located the problem. The problem lies in this block of code on line starting on line 184 of hashimage.php:

    /**
        * Fetch the url
        **/
        private function _fetchurl($url = null, $ttl = 86400){
            if ($url) {
                $option_name = 'hashimage_cache_'.md5($url);
    
                // Chec if cache of the urls allready exists, if not, get content of the url
                if (false === ($data = get_site_transient($option_name))) {
                    $ch = curl_init();
                    $options = array(
                        CURLOPT_URL => $url,
                        CURLOPT_RETURNTRANSFER => true,
                        CURLOPT_CONNECTTIMEOUT => 10,
                        CURLOPT_TIMEOUT => 10
                    );
                    curl_setopt_array($ch, $options);
                    $data['chunk'] = curl_exec($ch);
                    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                    curl_close($ch);
                    if($http_code === 200){
                        // Set the new cache
                        set_site_transient($option_name, $data, $ttl);
                    }
                }
    
                return $data['chunk'];
            }
        }

    Change this to:

    /**
        * Fetch the url
        **/
        private function _fetchurl($url = null, $ttl = 86400){
            if ($url) {
                $ch = curl_init();
                $options = array(
                    CURLOPT_URL => $url,
                    CURLOPT_RETURNTRANSFER => true,
                    CURLOPT_CONNECTTIMEOUT => 10,
                    CURLOPT_TIMEOUT => 10
                );
                curl_setopt_array($ch, $options);
                $data['chunk'] = curl_exec($ch);
                $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
                curl_close($ch);
                if($http_code === 200){
                    // Set the new cache
                    set_site_transient($option_name, $data, $ttl);
                }
    
                return $data['chunk'];
            }
        }

    Looks like if (false === ($data = get_site_transient($option_name))) { is evaluating to false every time unless the cache is cleared. If I’m not mistaken, this is checking for the transient “hashimage_cache_” but the logic doesn’t seem to make sense. Essentially if it is set then no new content is loaded. However it looks like there’s no reason why that transient wouldn’t be set unless the cache has just been cleared. I may not be fully understanding the code, but from what I can tell, this will only ever evaluate to true if the cache has just been cleared.

    Secondly, the 15 minute refresh is actually set to 150 minutes. The correct value should be 90,000 ms for the setInterval in async.js on line 18. Here’s the code with the corrected value:

    setInterval(function(){
    	getImages(this, link_path, dataurl);
    }, 90000); // 90,000

    Hope this helps someone! Worked for me after these changes! Thanks for this plugin, I really enjoy it!

    Plugin Author Mattias

    (@darkwhispering)

    Hi @hendeca

    I’m happy you found a solution, and also noticed the “150” minutes refresh I totally missed. I will make sure that time is fixed in the update I’m working on.

    When I moved to the Transient API a while back, I never worked with it before and followed the documentation closely and it is for the WP documentation I got the

    (false === ($data = get_site_transient($option_name))) {

    evaluation. https://codex.www.ads-software.com/Transients_API#Fetching_Transients

    Also, with the change you have, the curl will run on both old an new images, meaning a lot of extra times, since we already have a lot of the images in the cache. Your code have no check where there exists any cache or not for an image url found on twitter or instagram.

    ** Note: I’m working on a updated version of the plugin, re-written from the ground, with working twitter API. I hope to have a alpha released soon.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘New content only visible after cache clear’ is closed to new replies.