The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Gravatar Signup Encouragement
Does not work with allow_url_fopen=0 (10 posts)

  1. jlencion
    Posted 4 years ago #

    Using version 3.0.

    I like the idea of this plugin, but unfortunately it does not work on our setup because we have allow_url_fopen disabled. Even worse, it fails silently, so instead of knowing there was a problem, it just incorrectly told me that I don't have a gravatar set up.

    To trace this problem down, I changed this line:

    $AgetHeaders = @get_headers( $fileUrl );

    to be:

    $AgetHeaders = get_headers( $fileUrl );

    Which produced the following error messages:

    Warning: get_headers() [function.get-headers]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /path/to/blog/wp-content/plugins/gravatar-signup-encouragement/gravatar-signup-encouragment.php on line 523

    Warning: get_headers() [function.get-headers]: This function may only be used against URLs in /path/to/blog/wp-content/plugins/gravatar-signup-encouragement/gravatar-signup-encouragment.php on line 523

    It would be nice if this plugin would check if allow_url_fopen was available (if (ini_get('allow_url_fopen')) {), and if not, would fall back to another method, such as cURL.



  2. jlencion
    Posted 4 years ago #

    Ninja patch!

    --- gravatar-signup-encouragement.orig.php	2011-10-10 13:22:12.783839000 -0500
    +++ gravatar-signup-encouragement.php	2011-10-10 13:43:28.900355000 -0500
    @@ -512,6 +512,31 @@
    + * Get HTTP headers from a given URL
    + *
    + * @since 3.1
    + * @param string $url URL to get HTTP headers for
    + * @return array
    + */
    +function gravatar_signup_encouragement_get_headers( $url ) {
    +  if ( ini_get( 'allow_url_fopen' ) ) {
    +    return get_headers( $url );
    +  } else {
    +    $ch = curl_init( $url );
    +    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    +    curl_setopt( $ch, CURLOPT_HEADER, true );
    +    curl_setopt( $ch, CURLOPT_NOBODY, true );
    +    $content = curl_exec( $ch );
    +    curl_close( $ch );
    +    return array($content);
    +  }
      * Check if gravatar exists
      * @since 2.0
    @@ -520,7 +545,7 @@
     function gravatar_signup_encouragement_check_gravatar_existence( $email ) {
     	$fileUrl = "http://www.gravatar.com/avatar/" . md5( strtolower( $email ) )."?s=2&d=404";
    -	$AgetHeaders = @get_headers( $fileUrl );
    +	$AgetHeaders = gravatar_signup_encouragement_get_headers( $fileUrl );
     	if ( ! preg_match( "|200|", $AgetHeaders[0] ) ) {
     		return false;
     	} else {
  3. Milan Dinić
    Plugin Author

    Posted 4 years ago #

    Thanks for this report and a patch.

    I actually thought about adding this since I got similar reports (for non existing gravatar it doesn't report) and I created a test plugin but there wasn't any feedback so I forgot about it.

    There is one thing that I would change from your patch. Instead of cURL I would use WordPress HTTP API which is the only right way to use this kind of stuff in WordPress.

    You may wondering why I didn't use it instead of get_headers. Reason is that WordPress is much slower and here we need result very fast.

    So WordPress should be used as a fallback as in your example.

    I will add this but I need to test it some time and I think that it's not crucial to have it fixed immediately (you already have temporary solution for yourself).

  4. sttiger
    Posted 4 years ago #

    does gravatar even work? everytime i try to change my picture or just log in.. i get nothing but problems from that service and hate my picture they give me. i honestly refuse to post on most wordpress sites that i see uses the service. I personally use an upload on my sites because if I am having this much trouble.. my customers and thier customers will be just as frustrated and probably mad at the stupid cartoon monsters plastered next to a serious post.. just something to think about.

    edited after post.. see, there is a perfect example of what i mean.. now i will leave this site.. THIS is NOT what i want my customers to feel like.. to make a post and have such a stupid 3 year old looking avatar next to work..

  5. stevemagruder
    Posted 4 years ago #

    Well, back to the original thread (as those who use this plugin like and use Gravatar on their blogs and aren't seeking criticisms of it)...

    I think this is what is tripping me up too. I haven't used the WordPress HTTP API before, and so I'll use the cURL patch until there's a patch to the plugin. I know cURL to work well and fast on my hosting server.

    Thanks jlencion!

  6. stevemagruder
    Posted 4 years ago #

    Hmmm, even after applying the patch, which should have worked, it's still saying a registered user who definitely has a gravatar for their e-mail address doesn't have one yet.

    In this case, the gravatar isn't the primary e-mail address in the Gravatar account, but instead a secondary one. Might that make a difference?

  7. Milan Dinić
    Plugin Author

    Posted 4 years ago #

    This is finally added in version 3.1. Please report any issues.

  8. stevemagruder
    Posted 4 years ago #

    Still not working. My "Hmmm" remark above still applies.

  9. Milan Dinić
    Plugin Author

    Posted 4 years ago #

    I need more details, URL where it's happening and email address. If you are concerned about sharing those information publicly, you can send them to me privately.

  10. stevemagruder
    Posted 4 years ago #

    I've decided to uninstall it. I don't have the time to follow up on this right now. Sorry.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Gravatar Signup Encouragement
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic