Zen Cart Logo
Forums / All Other Contributions/Addons / Google Recaptcha v3 deprecated constructor

Google Recaptcha v3 deprecated constructor

Views: 819

Results 1 to 3 of 3
3 Jun 2022, 3:24 PM
#1
vanhorn_s avatar

vanhorn_s

Zen Follower

Join Date:
Apr 2010
Posts:
283
Plugin Contributions:
0

Google Recaptcha v3 deprecated constructor

ZC 1.5.7 PHP 7.4
I just got done installing Numinix's Google recaptcha v3, and it seems to be working fine, but my log folder is filling up fast with this error:

[03-Jun-2022 08:59:26 America/Boise] PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; NuminixRecaptchaV3Observer has a deprecated constructor in /home1/redsauto/public_html/includes/classes/observers/class.nmx_recaptcha_v3.php on line 6

Here is the entire code from class.nmx_recaptcha_v3.php:

<?php
/**
 * Observer class used to verify request token upon requests
 *
 */
class NuminixRecaptchaV3Observer extends base 
{
    function NuminixRecaptchaV3Observer() {
        global $zco_notifier, $nmxRecaptcha;
        
        $zco_notifier->attach($this, $nmxRecaptcha->get_notifiers_to_check());
    }
	
    function update(&$class, $eventID, $paramsArray) {
        global $error, $nmxRecaptcha;
        
        if(!$nmxRecaptcha->is_enable()) return $error;
        
        $valid = false;
        if(isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])){
            $valid = $nmxRecaptcha->validate_recaptcha($_POST['g-recaptcha-response'], $nmxRecaptcha->get_notifier_message_class($eventID));
        }
        
        if(!$valid) $error = true;
        
        return $error;
    }
}

I know I need to modify lines 6, and 8 to change the constructor, but I am a mechanic, not a php master, so I am not exactly sure what to change it to that will make php happy.

3 Jun 2022, 4:37 PM
#3
vanhorn_s avatar

vanhorn_s

Zen Follower

Join Date:
Apr 2010
Posts:
283
Plugin Contributions:
0

Re: Google Recaptcha v3 deprecated constructor

Thank you. That seems to have worked. Hopefully the spam from the contact form stops now.