14 replies [Last post]
bioben's picture
Offline
Bug FinderEarly adopter... addicted to alphas.
Joined: 08/09/2007
Juice: 93
Was this information Helpful?

We recently updated a couple sites to the latest release of Ubercart. We've realized all of our credit card data, which was stored in past orders has since been erased. Has this happened to anyone else? Is there anything we can do to get that data back? Help!

Drupal + Ubercart = Sundays Energy
_____________________

Analog Hero - Vintage Gadgets

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: CC data where are you?

Hasn't happened here... are you saying it got wiped from the DB or it just isn't visible through the order administration any more?

bioben's picture
Offline
Bug FinderEarly adopter... addicted to alphas.
Joined: 08/09/2007
Juice: 93
Re: CC data where are you?

It got wiped from the database on all of our sites that were updated.

Drupal + Ubercart = Sundays Energy
_____________________

Analog Hero - Vintage Gadgets

webmasterkai's picture
Offline
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 299
Re: CC data where are you?

We're actually seeing the database cc info getting cleared almost every day.

Biodiesel * (ubercart + drupal) = Sundays Energy

cosmo83@drupal.org's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik
Joined: 08/08/2007
Juice: 236
Re: Re: CC data where are you?

Same here. I thought this was a setting in the payment settings

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
"Oh snap!" I'll check it

"Oh snap!" Shocked I'll check it out... that's not cool.

EDIT: Apparently, there was a check in there for order_status = 0. This wasn't updated with the new order status system. Fixing and committing as soon as I can... until then I'd recommend stopping your cron runs. (Just rename cron.php until the fix goes in.)

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: "Oh snap!" I'll check it

Alright, I had searched for the old functions and made the changes, but there were two queries in uc_credit_cron() that needed to be updated, too. The function should resemble this:

<?php
function uc_credit_cron() {
 
// Empty anonymous carts.
 
$time = strtotime(variable_get('uc_cart_anon_duration', '4') .' '
                 
. variable_get('uc_cart_anon_unit', 'hours') .' ago');
 
db_query("DELETE upc.* FROM {uc_orders} AS uo LEFT JOIN {uc_payment_credit} "
         
."AS upc ON uo.order_id = upc.order_id WHERE uo.modified <= %d AND "
         
."uo.order_status = '%s'", $time, uc_order_state_default('in_checkout'));

 

// Mask old stored credit card numbers.
 
$time = strtotime(variable_get('uc_credit_number_duration', '1') .' '
                 
. variable_get('uc_credit_number_unit', 'years') .' ago');
 
db_query("UPDATE {uc_orders} AS uo LEFT JOIN {uc_payment_credit} AS upc "
         
."ON uo.order_id = upc.order_id SET upc.cc_number = "
         
."RIGHT(upc.cc_number, 4), upc.cc_cvv = '000' WHERE uo.modified "
         
."<= %d AND uo.order_status = '%s' AND CHAR_LENGTH(upc.cc_number) > 4",
          
$time, variable_get('uc_credit_clear_status', uc_order_state_default('completed')));
}
?>

Changes are in Bazaar.

webmasterkai's picture
Offline
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 299
Re: Re: "Oh snap!" I'll check it

Updated to latest bazaar and I get "Fatal error: require_once() [function.require]: Failed opening required 'uc_payment_workflow.inc' (include_path='.:/usr/local/lib/php') in /home/ograce/public_html/sites/all/modules/ubercart/payment/uc_payment/uc_payment.module on line 19"

Biodiesel * (ubercart + drupal) = Sundays Energy

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: "Oh snap!" I'll check it

Whoops! Adding it now!

z3b
z3b's picture
Offline
Joined: 08/15/2007
Juice: 51
Hi Guys, I've got a related

Hi Guys,
I've got a related problem, with a fresh install of UC Alpha7e, anytime I run cron.php i got a warning :

user warning: Not unique table/alias: 'upc' query: DELETE upc.* FROM uc_orders AS uo LEFT JOIN uc_payment_credit AS upc ON uo.order_id = upc.order_id WHERE uo.modified <= 1193501589 AND uo.order_status = 0

Any help would be greatly appreciated,
Thanks

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Hi Guys, I've got a related

Check to make sure lines 60-62 in your uc_credit.module look like this:

<?php
db_query
("DELETE upc.* FROM {uc_orders} AS uo LEFT JOIN {uc_payment_credit} "
       
."AS upc ON uo.order_id = upc.order_id WHERE uo.modified <= %d AND "
       
."uo.order_status = '%s'", $time, uc_order_state_default('in_checkout'));
?>

If not, it may be you were updating from a version prior to the directory structure changes and as such will need to remove duplicate directories from root that exist in the /payment and /shipping subdirectories.

Guest (not verified)
Guest's picture
Re: Re: Hi Guys, I've got a related

Hi Ryan, and thanks for looking into this.
Here are the lines included in ubercart-5.x-1.0-alpha7e.tar.gz /payement/credit/uc_credit.module

function uc_credit_cron() {
  // Empty anonymous carts.
  $time = strtotime(variable_get('uc_cart_anon_duration', '4') .' '
                  . variable_get('uc_cart_anon_unit', 'hours') .' ago');
  db_query("DELETE upc.* FROM {uc_orders} AS uo LEFT JOIN {uc_payment_credit} "
          ."AS upc ON uo.order_id = upc.order_id WHERE uo.modified <= %d AND "
          ."uo.order_status = 0", $time);

  // Mask old stored credit card numbers.
  $time = strtotime(variable_get('uc_credit_number_duration', '1') .' '
                  . variable_get('uc_credit_number_unit', 'years') .' ago');
  db_query("UPDATE {uc_orders} AS uo LEFT JOIN {uc_payment_credit} AS upc "
          ."ON uo.order_id = upc.order_id SET upc.cc_number = "
          ."RIGHT(upc.cc_number, 4), upc.cc_cvv = '000' WHERE uo.modified "
          ."<= %d AND uo.order_status = %d AND CHAR_LENGTH(upc.cc_number) > 4",
           $time, variable_get('uc_credit_clear_status', 4));
}

I did not update from any previous version of UC, it's a clean install, so my directory structure is as it should be (all payement stuff below ubercart/payement/)

I've replaced the query by the one you suggested, but still got the same kind of error:

user warning: Not unique table/alias: 'upc' query: DELETE upc.* FROM uc_orders AS uo LEFT JOIN uc_payment_credit AS upc ON uo.order_id = upc.order_id WHERE uo.modified <= 1193669983 AND uo.order_status = 'in_checkout'

Could it be that there is no order in the tables ? (site is still in construction)
Thanks a lot,
Sebastien

z3b
z3b's picture
Offline
Joined: 08/15/2007
Juice: 51
Re: Re: Hi Guys, I've got a related

// Sorry for double post, was not logged during last post

Hi Ryan, and thanks for looking into this.
Here are the lines included in ubercart-5.x-1.0-alpha7e.tar.gz /payement/credit/uc_credit.module

function uc_credit_cron() {
  // Empty anonymous carts.
  $time = strtotime(variable_get('uc_cart_anon_duration', '4') .' '
                  . variable_get('uc_cart_anon_unit', 'hours') .' ago');
  db_query("DELETE upc.* FROM {uc_orders} AS uo LEFT JOIN {uc_payment_credit} "
          ."AS upc ON uo.order_id = upc.order_id WHERE uo.modified <= %d AND "
          ."uo.order_status = 0", $time);

  // Mask old stored credit card numbers.
  $time = strtotime(variable_get('uc_credit_number_duration', '1') .' '
                  . variable_get('uc_credit_number_unit', 'years') .' ago');
  db_query("UPDATE {uc_orders} AS uo LEFT JOIN {uc_payment_credit} AS upc "
          ."ON uo.order_id = upc.order_id SET upc.cc_number = "
          ."RIGHT(upc.cc_number, 4), upc.cc_cvv = '000' WHERE uo.modified "
          ."<= %d AND uo.order_status = %d AND CHAR_LENGTH(upc.cc_number) > 4",
           $time, variable_get('uc_credit_clear_status', 4));
}

I did not update from any previous version of UC, it's a clean install, so my directory structure is as it should be (all payement stuff below ubercart/payement/)

I've replaced the query by the one you suggested, but still got the same kind of error:

user warning: Not unique table/alias: 'upc' query: DELETE upc.* FROM uc_orders AS uo LEFT JOIN uc_payment_credit AS upc ON uo.order_id = upc.order_id WHERE uo.modified <= 1193669983 AND uo.order_status = 'in_checkout'

Could it be that there is no order in the tables ? (site is still in construction)
Thanks a lot,
Sebastien

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Hi Guys,

Nah, the problem is just with the delete query. You'll notice in your version it's looking for orders with a status of 0 whereas in the current code I posted it's using a %s and a function to get the order status name. This was one place where the order status changes slipped through the cracks. You can replace the code manually, update to the latest Bazaar version (will need Workflow-ng), or wait for Alpha 8 to come out. Shouldn't be too far away.

z3b
z3b's picture
Offline
Joined: 08/15/2007
Juice: 51
Re: Re: Re: Re: Hi Guys,

Thanks Ryan, I'll wait for alpha 8 as it doesnt seems to be a real problem for now Smiling