Support » Plugin: Related Posts » Errors after updating to latest version "Warning: srand() expects parameter 1"

  • Resolved harrisbueller

    (@harrisbueller)


    After updating to the latest version of Zemanta I noticed that Zemanta changed its settings from not showing thumbnails to showing the large thumbnail. Not a big deal, but now on one of my posts the following error appears at the top of the post several times (viewable by visitors to my site):

    Warning: srand() expects parameter 1 to be long, string given in public_html/enterpriseit.co/wp-content/plugins/related-posts/thumbnailer.php on line 248

    https://wordpress.org/plugins/related-posts/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey Chris,

    thanks for reaching out – I’ll gladly help!
    We can’t replicate this issue on our side, but it seems that there is a conversion problem going on. Would you mind replacing the code (line 248) to:
    srand((int) $seed);
    The whole code segment should look something like this:

    function wp_rp_get_default_thumbnail_url($seed = false, $size = 'thumbnail') {
        $options = wp_rp_get_options();
        $upload_dir = wp_upload_dir();
        if ($options['default_thumbnail_path']) {
            return $options['default_thumbnail_path'];
        } else {
            if ($seed) {
                $next_seed = rand();
               srand((int) $seed);
            }
            $file = rand(0, WP_RP_THUMBNAILS_DEFAULTS_COUNT - 1) . '.jpg';
            if ($seed) {
                srand((int) $next_seed);
            }
            return plugins_url('/static/thumbs/' . $file, __FILE__);
        }
    }

    Please let me know if this solves the error – also, a link to your blog would be much appreciated.

    Take care,

    Petra

    Hi, thanks a lot for your response. Please let me know which file to edit?

    here is the link, at the moment I have it so thumbnails are not shown thus the error is not showing up on the page to visitors:
    http://enterpriseit.co/microsoft-exchange/2013/install-certificate/

    I haven’t checked every one of my pages to see if the issue is occurring on them, but at least I can test with the above page.

    Chris

    Thanks again for all your help, that code change worked for me and removed all the error messages. That said, I have found that I’m not quite out of the woods yet.
    This particular post still refuses to display related post thumbnails properly:
    http://enterpriseit.co/microsoft-exchange/2013/install-certificate/

    Other posts that have the same related posts group display the thumbnails correctly, however this particular post insists on showing the zemanta default thumbnails, and with no variety at that.

    Any ideas?

    Thanks again for your help Zemanta is a great plugin with excellent support, I don’t know how you’all do it.

    Hey Chris,

    thanks for the kind words – it makes our days at the office a lot easier, really! 🙂
    I have re-checked your site and if I am not mistaken thumbnail issue is fixed now? If there is nothing else I can help you with, can I mark this topic as resolved?

    Best,

    Petra

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Errors after updating to latest version "Warning: srand() expects parameter 1"’ is closed to new replies.