Forums

DB saving issue after upgrading joomla to 3.x

melindamak 05 Apr, 2016
HI,

I am now using a development server to copy my live site to this development server including the database for the purpose of migrating joomla 2.x to 3.x. I want to assure it is working before copying back to live site.

I backed up the chronoforms on live site and restored back to the development site, and seems restoring ok. However, when i run a registration form, it gives me some db insert error to the coupon table. It said duplicate record of inserting blank record.

I have the following server side scripts to validate the coupon code entered, and i make sure the following scripts would be running only if coupon_code entered on the form is not EMPTY. However, it seems that the script is still running even if the form data is EMPTY. Is there anything wrong or DB Save is wrong here? I also attached my DB Save configuration.
<?php


if (!empty($form->data['coupon_code']))

{

$form->data['coupon_type'] = $form->data['coup']['coupon_type'];
$form->data['coupon_times'] = $form->data['coup']['coupon_times'];
$form->data['coupon_expiry'] = $form->data['coup']['coupon_expiry'];
$form->data['coupon_id'] = $form->data['coup']['coupon_id'];
$form->data['reseller_id'] = $form->data['coup']['coupon_rid'];
$form->data['todaydate'] = date('Y-m-d');

if (($form->data['coupon_type']) == "T"){ 
  if (($form->data['coupon_times']) <= 0 ) {
      return false;
     }
  else
  {
   $form->data['coupon_times'] = $form->data['coupon_times'] - 1 ;
  }
}

if (($form->data['coupon_type']) == "D"){
  if (($form->data['coupon_expiry']) < $form->data['todaydate']) {
      return false;
     }
}
}
?>
GreyHead 05 Apr, 2016
Hi melindamak,

Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.

Bob
melindamak 06 Apr, 2016
Hi Bob,

Below is the debugger's result:
Array
(
    [chronoform] => User_Registration
    [event] => submit
    [username] => tyt
    [MoCast_BindNo] => +85299999999
    [passwd] => test
    [passwd2] => test
    [cf_user_id] => 712
    [coupon_id] => 
    [name] => test
    [company_name] => testc
    [company_addr] => sdef
    [city] => 45t sdf
    [state] => sdf
    [postal_code] => 563465
    [country] => sdf
    [email_address] => asdf@dfg.com
    [phone_number] => +85299999999
    [QS_Plans] => QS Deluxe
    [MoCast_Service] => 
    [FT_Plans] => 
    [LT_Plans] => 
    [coupon_code] => 
    [requirements] => 
    [TC_Box] => 1
    [chrono_verification] => FUd4D
    [input_submit_6] => Submit & Register
    [coupon_times] => 
    [coupon_type] => 
    [coupon_expiry] => 
    [todaydate] => 
    [reseller_id] => 
    [reg_status] => P
    [de5b4a7cb38c6c0c719547caa4bbd55a] => 1
    [coup] => Array
        (
            [cf_uid] => 5c7b16af6f8a6973fe1e944d48f08992
            [cf_created] => 2016-04-06 04:33:22
            [cf_created_by] => 0
            [cf_ipaddress] => 183.178.53.72
            [cf_user_id] => 712
            [chronoform] => User_Registration
            [event] => submit
            [username] => tyt
            [MoCast_BindNo] => +85299999999
            [passwd] => test
            [passwd2] => test
            [coupon_id] => 22
            [name] => test
            [company_name] => testc
            [company_addr] => sdef
            [city] => 45t sdf
            [state] => sdf
            [postal_code] => 563465
            [country] => sdf
            [email_address] => asdf@dfg.com
            [phone_number] => +85299999999
            [QS_Plans] => QS Deluxe
            [MoCast_Service] => 
            [FT_Plans] => 
            [LT_Plans] => 
            [coupon_code] => 
            [requirements] => 
            [TC_Box] => 1
            [chrono_verification] => FUd4D
            [input_submit_6] => Submit & Register
            [coupon_times] => 
            [coupon_type] => 
            [coupon_expiry] => 
            [todaydate] => 
            [reseller_id] => 
            [reg_status] => P
            [de5b4a7cb38c6c0c719547caa4bbd55a] => 1
            [coup] => Array
                (
                )

            [email] => asdf@dfg.com
            [password] => test
            [password2] => test
            [_PLUGINS_] => Array
                (
                    [joomla_registration] => Array
                        (
                            [*isRoot] => 
                            [id] => 712
                            [name] => test
                            [username] => tyt
                            [email] => asdf@dfg.com
                            [password] => $2y$10$Ugj/TIFq73QrBWFGlCZBiucBDqzZUsxvxyAZpLQzpMRUiKTs7N6Ua
                            [password_clear] => test
                            [block] => 1
                            [sendEmail] => 0
                            [registerDate] => 2016-04-06 04:33:22
                            [lastvisitDate] => 
                            [activation] => f0c5d4400a4585a75088818fb1f6336e
                            [groups] => Array
                                (
                                    [0] => 2
                                )

                            [lastResetTime] => 
                            [resetCount] => 
                            [requireReset] => 
                            [*_params] => Joomla\Registry\Registry Object
                                (
                                    [data:protected] => stdClass Object
                                        (
                                        )

                                    [separator] => .
                                )

                            [*_authGroups] => Array
                                (
                                    [0] => 1
                                )

                            [*_authLevels] => Array
                                (
                                    [0] => 1
                                    [1] => 1
                                )

                            [*_authActions] => 
                            [*_errorMsg] => 
                            [*userHelper] => JUserWrapperHelper Object
                                (
                                )

                            [*_errors] => Array
                                (
                                )

                            [aid] => 0
                            [chronoform] => User_Registration
                            [event] => submit
                            [MoCast_BindNo] => +85299999999
                            [passwd] => test
                            [passwd2] => test
                            [cf_user_id] => id
                            [coupon_id] => 
                            [company_name] => testc
                            [company_addr] => sdef
                            [city] => 45t sdf
                            [state] => sdf
                            [postal_code] => 563465
                            [country] => sdf
                            [email_address] => asdf@dfg.com
                            [phone_number] => +85299999999
                            [QS_Plans] => QS Deluxe
                            [MoCast_Service] => 
                            [FT_Plans] => 
                            [LT_Plans] => 
                            [coupon_code] => 
                            [requirements] => 
                            [TC_Box] => 1
                            [chrono_verification] => FUd4D
                            [input_submit_6] => Submit & Register
                            [coupon_times] => 
                            [coupon_type] => 
                            [coupon_expiry] => 
                            [todaydate] => 
                            [reseller_id] => 
                            [reg_status] => P
                            [de5b4a7cb38c6c0c719547caa4bbd55a] => 1
                            [coup] => Array
                                (
                                )

                            [password2] => test
                            [usertype] => deprecated
                        )

                )

            [chronoform_data] => Array
                (
                    [cf_uid] => 8ea19fca6244233b072186c69abb671a
                    [cf_created] => 2016-04-06 04:33:22
                    [cf_created_by] => 0
                    [cf_ipaddress] => 183.178.53.72
                    [cf_user_id] => 712
                    [chronoform] => User_Registration
                    [event] => submit
                    [username] => tyt
                    [MoCast_BindNo] => +85299999999
                    [passwd] => test
                    [passwd2] => test
                    [coupon_id] => 
                    [name] => test
                    [company_name] => testc
                    [company_addr] => sdef
                    [city] => 45t sdf
                    [state] => sdf
                    [postal_code] => 563465
                    [country] => sdf
                    [email_address] => asdf@dfg.com
                    [phone_number] => +85299999999
                    [QS_Plans] => QS Deluxe
                    [MoCast_Service] => 
                    [FT_Plans] => 
                    [LT_Plans] => 
                    [coupon_code] => 
                    [requirements] => 
                    [TC_Box] => 1
                    [chrono_verification] => FUd4D
                    [input_submit_6] => Submit & Register
                    [coupon_times] => 
                    [coupon_type] => 
                    [coupon_expiry] => 
                    [todaydate] => 
                    [reseller_id] => 
                    [reg_status] => P
                    [de5b4a7cb38c6c0c719547caa4bbd55a] => 1
                    [coup] => Array
                        (
                        )

                    [email] => asdf@dfg.com
                    [password] => test
                    [password2] => test
                    [_PLUGINS_] => Array
                        (
                            [joomla_registration] => Array
                                (
                                    [*isRoot] => 
                                    [id] => 712
                                    [name] => test
                                    [username] => tyt
                                    [email] => asdf@dfg.com
                                    [password] => $2y$10$Ugj/TIFq73QrBWFGlCZBiucBDqzZUsxvxyAZpLQzpMRUiKTs7N6Ua
                                    [password_clear] => test
                                    [block] => 1
                                    [sendEmail] => 0
                                    [registerDate] => 2016-04-06 04:33:22
                                    [lastvisitDate] => 
                                    [activation] => f0c5d4400a4585a75088818fb1f6336e
                                    [groups] => Array
                                        (
                                            [0] => 2
                                        )

                                    [lastResetTime] => 
                                    [resetCount] => 
                                    [requireReset] => 
                                    [*_params] => Joomla\Registry\Registry Object
                                        (
                                            [data:protected] => stdClass Object
                                                (
                                                )

                                            [separator] => .
                                        )

                                    [*_authGroups] => Array
                                        (
                                            [0] => 1
                                        )

                                    [*_authLevels] => Array
                                        (
                                            [0] => 1
                                            [1] => 1
                                        )

                                    [*_authActions] => 
                                    [*_errorMsg] => 
                                    [*userHelper] => JUserWrapperHelper Object
                                        (
                                        )

                                    [*_errors] => Array
                                        (
                                        )

                                    [aid] => 0
                                    [chronoform] => User_Registration
                                    [event] => submit
                                    [MoCast_BindNo] => +85299999999
                                    [passwd] => test
                                    [passwd2] => test
                                    [cf_user_id] => id
                                    [coupon_id] => 
                                    [company_name] => testc
                                    [company_addr] => sdef
                                    [city] => 45t sdf
                                    [state] => sdf
                                    [postal_code] => 563465
                                    [country] => sdf
                                    [email_address] => asdf@dfg.com
                                    [phone_number] => +85299999999
                                    [QS_Plans] => QS Deluxe
                                    [MoCast_Service] => 
                                    [FT_Plans] => 
                                    [LT_Plans] => 
                                    [coupon_code] => 
                                    [requirements] => 
                                    [TC_Box] => 1
                                    [chrono_verification] => FUd4D
                                    [input_submit_6] => Submit & Register
                                    [coupon_times] => 
                                    [coupon_type] => 
                                    [coupon_expiry] => 
                                    [todaydate] => 
                                    [reseller_id] => 
                                    [reg_status] => P
                                    [de5b4a7cb38c6c0c719547caa4bbd55a] => 1
                                    [coup] => Array
                                        (
                                        )

                                    [password2] => test
                                    [usertype] => deprecated
                                )

                        )

                    [cf_id] => 122
                )

            [chronoform_data_cf_id] => 122
        )

    [email] => asdf@dfg.com
    [password] => test
    [password2] => test
    [_PLUGINS_] => Array
        (
            [joomla_registration] => Array
                (
                    [*isRoot] => 
                    [id] => 712
                    [name] => test
                    [username] => tyt
                    [email] => asdf@dfg.com
                    [password] => $2y$10$Ugj/TIFq73QrBWFGlCZBiucBDqzZUsxvxyAZpLQzpMRUiKTs7N6Ua
                    [password_clear] => test
                    [block] => 1
                    [sendEmail] => 0
                    [registerDate] => 2016-04-06 04:33:22
                    [lastvisitDate] => 
                    [activation] => f0c5d4400a4585a75088818fb1f6336e
                    [groups] => Array
                        (
                            [0] => 2
                        )

                    [lastResetTime] => 
                    [resetCount] => 
                    [requireReset] => 
                    [*_params] => Joomla\Registry\Registry Object
                        (
                            [data:protected] => stdClass Object
                                (
                                )

                            [separator] => .
                        )

                    [*_authGroups] => Array
                        (
                            [0] => 1
                        )

                    [*_authLevels] => Array
                        (
                            [0] => 1
                            [1] => 1
                        )

                    [*_authActions] => 
                    [*_errorMsg] => 
                    [*userHelper] => JUserWrapperHelper Object
                        (
                        )

                    [*_errors] => Array
                        (
                        )

                    [aid] => 0
                    [chronoform] => User_Registration
                    [event] => submit
                    [MoCast_BindNo] => +85299999999
                    [passwd] => test
                    [passwd2] => test
                    [cf_user_id] => id
                    [coupon_id] => 
                    [company_name] => testc
                    [company_addr] => sdef
                    [city] => 45t sdf
                    [state] => sdf
                    [postal_code] => 563465
                    [country] => sdf
                    [email_address] => asdf@dfg.com
                    [phone_number] => +85299999999
                    [QS_Plans] => QS Deluxe
                    [MoCast_Service] => 
                    [FT_Plans] => 
                    [LT_Plans] => 
                    [coupon_code] => 
                    [requirements] => 
                    [TC_Box] => 1
                    [chrono_verification] => FUd4D
                    [input_submit_6] => Submit & Register
                    [coupon_times] => 
                    [coupon_type] => 
                    [coupon_expiry] => 
                    [todaydate] => 
                    [reseller_id] => 
                    [reg_status] => P
                    [de5b4a7cb38c6c0c719547caa4bbd55a] => 1
                    [coup] => Array
                        (
                        )

                    [password2] => test
                    [usertype] => deprecated
                )

        )

    [chronoform_data] => Array
        (
            [cf_uid] => 8ea19fca6244233b072186c69abb671a
            [cf_created] => 2016-04-06 04:33:22
            [cf_created_by] => 0
            [cf_ipaddress] => 183.178.53.72
            [cf_user_id] => 712
            [chronoform] => User_Registration
            [event] => submit
            [username] => tyt
            [MoCast_BindNo] => +85299999999
            [passwd] => test
            [passwd2] => test
            [coupon_id] => 
            [name] => test
            [company_name] => testc
            [company_addr] => sdef
            [city] => 45t sdf
            [state] => sdf
            [postal_code] => 563465
            [country] => sdf
            [email_address] => asdf@dfg.com
            [phone_number] => +85299999999
            [QS_Plans] => QS Deluxe
            [MoCast_Service] => 
            [FT_Plans] => 
            [LT_Plans] => 
            [coupon_code] => 
            [requirements] => 
            [TC_Box] => 1
            [chrono_verification] => FUd4D
            [input_submit_6] => Submit & Register
            [coupon_times] => 
            [coupon_type] => 
            [coupon_expiry] => 
            [todaydate] => 
            [reseller_id] => 
            [reg_status] => P
            [de5b4a7cb38c6c0c719547caa4bbd55a] => 1
            [coup] => Array
                (
                )

            [email] => asdf@dfg.com
            [password] => test
            [password2] => test
            [_PLUGINS_] => Array
                (
                    [joomla_registration] => Array
                        (
                            [*isRoot] => 
                            [id] => 712
                            [name] => test
                            [username] => tyt
                            [email] => asdf@dfg.com
                            [password] => $2y$10$Ugj/TIFq73QrBWFGlCZBiucBDqzZUsxvxyAZpLQzpMRUiKTs7N6Ua
                            [password_clear] => test
                            [block] => 1
                            [sendEmail] => 0
                            [registerDate] => 2016-04-06 04:33:22
                            [lastvisitDate] => 
                            [activation] => f0c5d4400a4585a75088818fb1f6336e
                            [groups] => Array
                                (
                                    [0] => 2
                                )

                            [lastResetTime] => 
                            [resetCount] => 
                            [requireReset] => 
                            [*_params] => Joomla\Registry\Registry Object
                                (
                                    [data:protected] => stdClass Object
                                        (
                                        )

                                    [separator] => .
                                )

                            [*_authGroups] => Array
                                (
                                    [0] => 1
                                )

                            [*_authLevels] => Array
                                (
                                    [0] => 1
                                    [1] => 1
                                )

                            [*_authActions] => 
                            [*_errorMsg] => 
                            [*userHelper] => JUserWrapperHelper Object
                                (
                                )

                            [*_errors] => Array
                                (
                                )

                            [aid] => 0
                            [chronoform] => User_Registration
                            [event] => submit
                            [MoCast_BindNo] => +85299999999
                            [passwd] => test
                            [passwd2] => test
                            [cf_user_id] => id
                            [coupon_id] => 
                            [company_name] => testc
                            [company_addr] => sdef
                            [city] => 45t sdf
                            [state] => sdf
                            [postal_code] => 563465
                            [country] => sdf
                            [email_address] => asdf@dfg.com
                            [phone_number] => +85299999999
                            [QS_Plans] => QS Deluxe
                            [MoCast_Service] => 
                            [FT_Plans] => 
                            [LT_Plans] => 
                            [coupon_code] => 
                            [requirements] => 
                            [TC_Box] => 1
                            [chrono_verification] => FUd4D
                            [input_submit_6] => Submit & Register
                            [coupon_times] => 
                            [coupon_type] => 
                            [coupon_expiry] => 
                            [todaydate] => 
                            [reseller_id] => 
                            [reg_status] => P
                            [de5b4a7cb38c6c0c719547caa4bbd55a] => 1
                            [coup] => Array
                                (
                                )

                            [password2] => test
                            [usertype] => deprecated
                        )

                )

            [cf_id] => 122
        )

    [chronoform_data_cf_id] => 122
    [coup_coupon_id] => 22
)
Validation Errors: 
Array
(
)
Dear test,

Thank you for your interest of signing up our KIMO-V Video Cloud Service Subscription Plan(s). Your subscription details and invoice will be sent to you shortly after we have verified your information.

Looking forward to serving you with our best quality and performance of KIMO-V Video Cloud Services.

Best Regards,
KIMO-V Video Cloud Service Team

Debug Data
db_record_loader
SELECT * FROM `kimov_coupon` AS `coup` WHERE `coupon_code` = ''
Core Captcha
Passed the core captcha check!
email
10
Result
An email has been SENT successfully from (name)email_address to subscribe@kimo-v.com
Body
Below is an service sign-up from a customer on www.kimo-v.com on SERVICE SUBSCRIPTION section:

 

Name: test

UserName: tyt

Password: test

Company Name:

Address: sdef

City: 45t sdf

State: sdf

Code: 563465

Country: sdf

Email address: asdf@dfg.com

Phone Number: +85299999999

Coupon Code:

QS Service: QS Deluxe

MoCast Service:

MoCast Bind Number: +85299999999

File Transcoding Service:

Live Transcoding Service:

Additional Requirements:


Thanks,
Melinda
melindamak 06 Apr, 2016
Bob,

FYI that a new record is created and inserted to the coupon table now for a blank coupon code record, of which I expected that if there is no coupon code entered (EMPTY), then the steps should be ignored including DBSave.

I dont know why it works in joomla 2.5 and not in this joomla 3.5.

Thanks for your advice.

Regards,
Melinda
melindamak 06 Apr, 2016
Hi Bob,

For some reason, i checked the existing site on joomla 2.5, a blank record is existed on the coupon table, but it just didn't complain a duplicate blank record is inserted but it does on joomla 3.5 version.

Regards,
Melinda
melindamak 06 Apr, 2016
Hi Bob,

Attached is the error shown after the form is trying to insert another record instead of updating the blank record. It does not complain with this message on joomla 2.x but it does now on joomla 3.x

Thanks & Rgds,
Melinda
GreyHead 06 Apr, 2016
Hi melindamak,

Where exactly is your code to check the coupon entry? Is that in a Serverside Validation action? If so, what do you have in the Fail box of the action?

There appears to be a loop somewhere as the debugger output show the same data two or three times.

Bob
melindamak 06 Apr, 2016
Yes Bob, there is a serverside validation script as shown in above script and also shown in below"

<?php


if (!empty($form->data['coupon_code']))

{

$form->data['coupon_type'] = $form->data['coup']['coupon_type'];
$form->data['coupon_times'] = $form->data['coup']['coupon_times'];
$form->data['coupon_expiry'] = $form->data['coup']['coupon_expiry'];
$form->data['coupon_id'] = $form->data['coup']['coupon_id'];
$form->data['reseller_id'] = $form->data['coup']['coupon_rid'];
$form->data['todaydate'] = date('Y-m-d');

if (($form->data['coupon_type']) == "T"){ 
  if (($form->data['coupon_times']) <= 0 ) {
      return false;
     }
  else
  {
   $form->data['coupon_times'] = $form->data['coupon_times'] - 1 ;
  }
}

if (($form->data['coupon_type']) == "D"){
  if (($form->data['coupon_expiry']) < $form->data['todaydate']) {
      return false;
     }
}
}
?>

Attached is the events of the form, where the scripts is run at the "Custom Server Side Validation" on the screen cap.

Strange thing is that it works fine under joomla 2.5 but not on joomla 3.5.
GreyHead 06 Apr, 2016
Hi Melinda,

What event is set in the Event Loop actions in the On Submit event?

Your custom code is not checking if the coupon code is empty - if it is empty the code there will be skipped but the form will still be submitted.

In the Debugger output both [coupon_code] and [coup][coupon_code] are empty. Is that correct?

Bob
melindamak 07 Apr, 2016
Hi Bob,

EVent loop just "On Load" as default and quit next action, should I try using other target event?

Yes, it is fine as i still need to process form if coupon code is not provided. If coupon code is provided, i need to check the coupon table to find out the validity of the coupon code and then deduct the number of times if needed, so need to update coupon table again with same coupon_id after running the server side validation script and then updated by using DB Save.

However, firstly, it seems to me that the DB save will create a new BLANK record instead if no matched coupon value record is found. No error is generated for first time on this case.

For second time, If blank record is created on table, I believe in joomla 2.5, this record will still keep updating with DB save while they coupon_code is EMPTY but provided coupon_id, and thus no complaint of updating existing blank record. However, in joomla 3.x, DB save is to create another new blank record instead of updating the blank record with duplicate coupon value (which is blank/null too). From the debugger above, at first the coupon id is null, and then after running dbloader, it becomes 22 for the coupon_id, so i presume at least it will just update this record with blank value, and NOT INSERTING ANOTHER NEW RECORD INSTEAD, I hope you understand my question here.

the coupon id is starting with null then to 22 and then back to null, I think there is something wrong with the event ordering and cause the coupon id becomes null again. Can u help me to point that out? But again, this process ordering does not create any problem on joomla 2.x - which makes me curious on this also?

So, i dont want the form to insert a blank record to coupon table if no coupon is loaded from the dbloader of the coupon table OR if the coupon code form field is EMPTY, how should i do this? I think if this can be done, then the other problems on wrong insert of new record would be solved.


Thanks so much Bob!

Regards,
Melinda
This topic is locked and no more replies can be posted.