WordPress.org

Ready to get started?Download WordPress

Forums

EP Hashimage
New content only visible after cache clear (8 posts)

  1. tezt
    Member
    Posted 1 year ago #

    New content is only visible after I do cache clear. Is this by design, or a bug? I can clear the cache every once in a while, no problem, but it would be awesome if it checks for new tags on reload?

    Site: http://www.jonkopingsfaltrittklubb.se/foton/

    I am using EP Hashimage Version 4.0.1, WordPress 3.5 with a twenty ten child theme not heavily modified.

    /Therese

    http://wordpress.org/extend/plugins/ep-hashimage/

  2. Mattias
    Member
    Plugin Author

    Posted 1 year ago #

    Hi @tezt

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

    / Mattias

  3. 38tyler
    Member
    Posted 1 year ago #

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

    / Tyler

  4. cruthas
    Member
    Posted 1 year ago #

    Any fixed on this?

  5. Ulrik
    Member
    Posted 10 months ago #

    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.

  6. ohiowins1
    Member
    Posted 10 months ago #

    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

  7. Hendeca
    Member
    Posted 9 months ago #

    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!

  8. Mattias
    Member
    Plugin Author

    Posted 9 months ago #

    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. http://codex.wordpress.org/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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic