1 reply [Last post]
dmn2000's picture
Offline
Joined: 11/23/2011
Juice: 6
Was this information Helpful?

After enabling Credit Card and Test Gateway, I tried to enable the PayPal module, and I got this message:

"PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'PRIMARY': INSERT INTO {uc_order_statuses} (title, state, weight, locked) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => PayPal pending [:db_insert_placeholder_1] => payment_received [:db_insert_placeholder_2] => 7 [:db_insert_placeholder_3] => 1 ) in uc_paypal_install() (line 127 of /home/***/sites/all/modules/ubercart/payment/uc_paypal/uc_paypal.install).

The module list shows that PayPal is Enabled even with the error.

These are the records in uc_order_statuses. Google Checkout is showing because I tried to enable it before, but I disabled and uninstalled it.

order_status_id title state weight locked
Primary key:
In Google Checkout in_checkout -7 1
canceled Canceled canceled -20 1
completed Completed completed 20 1
in_checkout In Checkout in_checkout -10 1
payment_received Payment received payment_received 10 1
pending Pending post_checkout 0 1
processing Processing post_checkout 5 1

Since Paypal is showing installed, do I need to worry about this error?

wojtha's picture
Offline
Joined: 09/12/2007
Juice: 39
Re: uc_order_statuses Integrity constraint when enabling PayPal

There is a bug in the PayPal install file.

Replace this

<?php
/**
* Implements hook_install().
*/
function uc_paypal_install() {
 
$t = get_t();

 

db_merge('uc_order_statuses')
    ->
key(array('order_status_id' => 'paypal_pending'))
    ->
insertFields(array(
     
'title' => $t('PayPal pending'),
     
'state' => 'payment_received',
     
'weight' => 7,
     
'locked' => 1,
    ))
    ->
updateFields(array(
     
'state' => 'payment_received',
     
'locked' => 1,
    ))
    ->
execute();
}
?>

With this

<?php
/**
* Implements hook_install().
*/
function uc_paypal_install() {
 
$t = get_t();

 

db_merge('uc_order_statuses')
    ->
key(array('order_status_id' => 'paypal_pending'))
    ->
fields(array(
     
'title' => $t('PayPal pending'),
     
'state' => 'payment_received',
     
'weight' => 7,
     
'locked' => 1,
    ))
    ->
execute();
}
?>

--
Vojtěch Kusý
Lead Developer
AtomicAnt Ltd.