There is a patch to fix #1423482: Anonymous checkout for Recurring Product not listed properly under Subscription Manager and My Account already, but there is not anything to retroactively fix recurring orders that had already been affected by the bug. I've attached a drush script which will fix all of the old recurring orders that had a uid of 0.

To run the script simply drush scr fix_missing_users_for_recurring_orders.drush after copying the following code into fix_missing_users_for_recurring_orders.drush


// Get all of the recurring orders with 0 for uid.
$query = db_query("SELECT rfid, order_id FROM {uc_recurring_users} WHERE uid=%d", 0);

// For each recurring order, get the uid.
while ($obj = db_fetch_object($query)) {
  $order_uid = db_result(db_query("SELECT uid FROM {uc_orders} WHERE order_id=%d", $obj->order_id));

  // Set the uid for the recurring order.
  echo "Attempting to fix recurring order '" . $obj->rfid . "'\n";

  $record = array(
    'rfid' => $obj->rfid,
    'uid' => $order_uid,
  );
  $query_success_status = drupal_write_record("uc_recurring_users", $record, 'rfid');

  echo "Return status: $query_success_status\n";
}

Should this be rolled into the module with a version update?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tinker’s picture

Version: 6.x-2.0-beta2 » 6.x-2.x-dev
Category: task » bug
FileSize
1.09 KB

Created patch with module update to find all fees with uid 0, where the order has a uid, and update the fees.

/**
 * Fix fees that have uid 0.
 */
function uc_recurring_update_6013() {
  $ret = array();
  $fees = db_query("SELECT r.rfid, o.uid
                      FROM {uc_recurring_users} r
                      LEFT JOIN {uc_orders} o ON (o.order_id = r.order_id)
                      WHERE r.uid = 0 AND o.uid <> 0");
  while ($fee = db_fetch_object($fees)) {
    $ret[] = update_sql("UPDATE {uc_recurring_users} SET uid = $fee->uid WHERE rfid = $fee->rfid");
  }
  return $ret;
}

Apply patch using git am uc_recurring-update-fee-uid-zero-2007252-1.patch