blaenk / wp-recaptcha

I gave ownership of this project to Google many years ago
Other
38 stars 16 forks source link

Fixed multiple bugs related to undefined variables #49

Open jpbellona opened 12 years ago

jpbellona commented 12 years ago

Using wp-recaptcha 3.1.6 with WP version 3.4 (all bugs existed also in 3.3.2)

All bugs related to undefined variables.

  1. WP-recaptcha throws errors of undefined variables on all page loads. PHP Notice: Undefined variable: rcommentid in /wp-content/plugins/wp-recaptcha/recaptcha.php on line 482 PHP Notice: Undefined variable: rchash in /wp-content/plugins/wp-recaptcha/recaptcha.php on line 484 FIX: Added in a check if (!empty($_REQUEST['rcommentid'])) $comment_id = $_REQUEST['rcommentid'];
    if (!empty($_REQUEST['rchash']))
       $comment_hash = $_REQUEST['rchash'];
  1. on a single post with comment form PHP Notice: Undefined index: rerror in /wp-content/plugins/wp-recaptcha/recaptcha.php on line 401 FIX: Added in a check if (isset($_GET['rerror'])) { $escaped_error = htmlentities($_GET['rerror'], ENT_QUOTES); }
  2. on the WP login page (using wp-recaptcha) PHP Notice: Undefined index: rerror in /var/www/html/student/bellona/public_html/chinavine2/wp-content/plugins/wp-recaptcha/recaptcha.php on line 278 FIX: Added in a check if (isset($_GET['rerror'])) { $escaped_error = htmlentities($_GET['rerror'], ENT_QUOTES); } else { $escaped_error = ''; }
  3. after logging a comment PHP Notice: Undefined variable: needed_capability in /var/www/html/student/bellona/public_html/chinavine2/wp-content/plugins/wp-recaptcha/recaptcha.php on line 439 FIX: Nested the conditional for returning the comment since it requires a defined variable

       if ($this->options['bypass_for_registered_users'] && $this->options['minimum_bypass_level']) {
           $needed_capability = $this->options['minimum_bypass_level'];
    
           if (($needed_capability && current_user_can($needed_capability)) || !$this->options['show_in_comments'])
               return $comment_data;
       }

That's it. Thanks for your work.