3 replies [Last post]
torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Was this information Helpful?

Upon viewing my Order History, Watchdog lists these two errors, one for each line in the order history:

Location http://shop.rifftrax.com/user/6/orders?sort=asc&order=Status
Referrer http://shop.rifftrax.com/user/6/orders
Message strtr() [function.strtr]: The second argument is not an array. in /var/www/vhosts/rifftrax.com/subdomains/shop/httpdocs/includes/common.inc on line 749.

Location http://shop.rifftrax.com/user/6/orders?sort=asc&order=Status
Referrer http://shop.rifftrax.com/user/6/orders
Message Invalid argument supplied for foreach() in /var/www/vhosts/rifftrax.com/subdomains/shop/httpdocs/includes/common.inc on line 734.

These are the two referenced functions:

<?php
file
: common.inc
function t($string, $args = 0) {
  global
$locale;
  if (
function_exists('locale') && $locale != 'en') {
   
$string = locale($string);
  }
  if (!
$args) {
    return
$string;
  }
  else {
   
// Transform arguments before inserting them
   
foreach ($args as $key => $value) {
      switch (
$key[0]) {
       
// Escaped only
       
case '@':
         
$args[$key] = check_plain($value);
        break;
       
// Escaped and placeholder
       
case '%':
        default:
         
$args[$key] = theme('placeholder', $value);
          break;
       
// Pass-through
       
case '!':
      }
    }
    return
strtr($string, $args);
  }
}
?>
<?php
file
: uc_order.module
function uc_order_history($uid) {
 
drupal_set_title(t('My order history'));

 

$breadcrumb = drupal_get_breadcrumb();
 
$breadcrumb[] = l(t('My account'), 'user/'. arg(1));
 
drupal_set_breadcrumb($breadcrumb);

 

$header = array(
    array(
'data' => t('Date'), 'field' => 'o.created', 'sort' => 'desc'),
    array(
'data' => t('Order #'), 'field' => 'o.order_id'),
    array(
'data' => t('Status'), 'field' => 'os.title'),
    array(
'data' => t('Products'), 'field' => 'products'),
    array(
'data' => t('Total'), 'field' => 'o.order_total')
  );

 

$result = pager_query("SELECT o.order_id, o.created, os.title, SUM(op.qty) AS products, o.order_total AS total FROM {uc_orders} AS o LEFT JOIN {uc_order_statuses} AS os ON o.order_status = os.order_status_id LEFT JOIN {uc_order_products} AS op ON o.order_id = op.order_id WHERE o.uid = %d AND o.order_status IN ". uc_order_status_list('general', TRUE) ." GROUP BY o.order_id". tablesort_sql($header), 20, 0, "SELECT COUNT(*) FROM {uc_orders} WHERE uid = %d AND order_status NOT IN ". uc_order_status_list('specific', TRUE), $uid);

 

// Build a table based on the customer's orders.
 
while ($order = db_fetch_object($result)){
   
$link = l($order->order_id, 'user/'. $uid .'/order/'. $order->order_id);
    if (
user_access('view all orders')){
     
$link .= '<span class="order-admin-icons">'. uc_order_actions($order, TRUE) .'</span>';
    }
   
$rows[] = array(
      array(
'data' => date('m/d/Y', $order->created)),
      array(
'data' => $link, 'nowrap' => 'nowrap'),
      array(
'data' => $order->title),
      array(
'data' => (!is_null($order->products) ? $order->products : 0), 'align' => 'center'),
      array(
'data' => uc_currency_format($order->total, TRUE), 'align' => 'right'),
    );
  }

 

$output = theme('table', $header, $rows) . theme('pager', NULL, 20, 0);

  return

$output;
}
?>

The errors look like they have to do with returning a message using the t('') function. Not sure where else to look at this point. I would hate to have these errors clogging up our database since we have thousands of users with dozens of orders each. It'd make cleaning out the watchdog table a chore!

Anyway - I haven't changed anything in the order module, except for how the order_id is created (it is now based on unix timestamp and not just the next incremental integer in the db). Using drupal5.2 and Alpha7e (latest bzr update).

--
Help directly fund development: Donate via PayPal!

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Errors generated in My Order History - strtr in common.inc

I think you can disregard this. I re-installed 7e over top of my previous files. Even after my change to the order_id construction it still seems to work okay.

One thing I noticed, after reuploading 7e, is that now my Order History is not sortable. It was sortable before, when this error was occurring. Very strange, but it works without any errors now, so all is well.

EDIT: It looks like the "Store Admin > View Orders" page is still generating this error. It only happens when I go in and view the details of a particular order. (Viewing the order or editing it). Not sure at this point what the commonalities are, yet.

--
Help directly fund development: Donate via PayPal!

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15450
Re: Re: Errors generated in My Order History - strtr in common.i

Hmm... I'm not showing any such errors on the Livetest. Also, my order history is still sortable. It may be that these are bugs I've fixed since then... I can't remember if my fix to remove hook_order_actions() was done then yet or not, but that hook has been removed and uc_order_actions() has been modified since, too.

logik's picture
Offline
Joined: 09/12/2007
Juice: 2
Re: Errors generated in My Order History - strtr in common.inc

I'm having an error in the same area. It seems like when pager_query is used, the table prefixes aren't inserted in the query. How do those prefixes get set?