Bigint error in referral at account registration



  • Hi,
    Just migrated to TB and am getting this error when a new user account is created. Kindly give me a hand.

    [ThirtyBeesDatabaseException]
    
    BIGINT UNSIGNED value is out of range in '(`xxc_tdb`.`s`.`id_sponsor` - 361)'
    
    
    SELECT s.*
    FROM `ps_referralprogram` s
    WHERE (s.`id_sponsor` - 361)
    
    at line 808 in file classes/db/Db.php
    803.         if ($webserviceCall && $errno) {
    804.             $dbg = debug_backtrace();
    805.             WebserviceRequest::getInstance()->setError(500, '[SQL Error] '.$this->getMsgError().'. From '.(isset($dbg[3]['class']) ? $dbg[3]['class'] : '').'->'.$dbg[3]['function'].'() Query was : '.$sql, 97);
    806.         } elseif (_PS_DEBUG_SQL_ && $errno && !defined('TB_INSTALLATION_IN_PROGRESS')) {
    807.             if ($sql) {
    808.                 throw new PrestaShopDatabaseException($this->getMsgError().'<br /><br /><pre>'.$sql.'</pre>');
    809.             }
    810. 
    811.             throw new PrestaShopDatabaseException($this->getMsgError());
    812.         }
    813.     }
    DbCore->displayError - [line 460 - classes/db/Db.php] - [1 Arguments]
    DbCore->query - [line 673 - classes/db/Db.php] - [1 Arguments]
    DbCore->executeS - [line 91 - modules/referralprogram/ReferralProgramModule.php] - [1 Arguments]
    ReferralProgramModule::getSponsorFriend - [line 725 - modules/referralprogram/referralprogram.php] - [1 Arguments]
    ReferralProgram->hookAdminCustomers - [line 771 - classes/Hook.php] - [1 Arguments]
    HookCore::coreCallHook - [line 489 - classes/Hook.php] - [3 Arguments]
    HookCore::execWithoutCache - [line 280 - classes/Hook.php] - [7 Arguments]
    HookCore::exec - [line 211 - config/smarty.config.inc.php] - [3 Arguments]
    smartyHook - [line 274 - config/smarty.config.inc.php] - [2 Arguments]
    SmartyLazyRegister->__call - [line 856 - vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code] - [2 Arguments]
    content_5a033ff55220a7_84235799 - [line 188 - vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php] - [1 Arguments]
    Smarty_Internal_TemplateBase->fetch - [line 424 - classes/SmartyCustom.php] - [7 Arguments]
    Smarty_Custom_Template->fetch - [line 378 - classes/helper/Helper.php]
    HelperCore->generate - [line 83 - classes/helper/HelperView.php]
    HelperViewCore->generateView - [line 3054 - classes/controller/AdminController.php]
    AdminControllerCore->renderView - [line 997 - controllers/admin/AdminCustomersController.php]
    AdminCustomersControllerCore->renderView - [line 2420 - classes/controller/AdminController.php]
    AdminControllerCore->initContent - [line 244 - controllers/admin/AdminCustomersController.php]
    AdminCustomersControllerCore->initContent - [line 366 - classes/controller/Controller.php]
    ControllerCore->run - [line 743 - classes/Dispatcher.php]
    DispatcherCore->dispatch - [line 58 - admin/index.php]
    


  • is your id_sponsor in ps_referralprogram an int(10) ?



  • Yes

    Field name	Type	Allow nulls?	Key	Default value	Extras
    id_referralprogram 	int(10) unsigned 	No 	Primary 	NULL 	auto_increment
    id_sponsor 	int(10) unsigned 	No 	None 	NULL 	
    email 	varchar(255) 	No 	None 	NULL 	
    lastname 	varchar(128) 	No 	None 	NULL 	
    firstname 	varchar(128) 	No 	None 	NULL 	
    id_customer 	int(10) unsigned 	Yes 	None 	NULL 	
    id_cart_rule 	int(10) unsigned 	Yes 	None 	NULL 	
    id_cart_rule_sponsor 	int(10) unsigned 	Yes 	None 	NULL 	
    date_add 	datetime 	No 	None 	NULL 	
    date_upd 	datetime 	No 	None 	NULL


  • I’m clueless then, hopefully someone else can help.



  • The first line below is the offending line 725 of referralprogram.php
    Is there anything obvious here? I am reading that the current versions of mysql have bigint/unsigned related changes.

        $friends = ReferralProgramModule::getSponsorFriend((int) $customer->id);
        if ($idReferralprogram = ReferralProgramModule::isSponsorised((int) $customer->id, true)) {
            $referralprogram = new ReferralProgramModule((int) $idReferralprogram);
            $sponsor = new Customer((int) $referralprogram->id_sponsor);
        }


  • I don’t have this module, but this code looks suspicious:

    ...`.`id_sponsor` - 361)'
    

    I’d bet this should read

    ...`.`id_sponsor` = 361)'
    

    Note the =.



  • I’ve opened a bug report for this issue to not forget it: https://github.com/thirtybees/referralprogram/issues/1

    Traumflug created this issue in thirtybees/referralprogram

    open SQL exception #1


 

Looks like your connection to thirty bees forum was lost, please wait while we try to reconnect.