The situation, the bug

This code in "uc_cart.module" produce an error with file "uc_cart_checkout_review.tpl.php".

function uc_cart_theme() {
...
'uc_cart_checkout_review' => array(
      'arguments' => array('help' => NULL, 'panes' => NULL, 'form' => NULL),
      'file' => 'uc_cart.pages.inc',
    ),
...

$panes is not available for the foreach

foreach ($panes as $title => $data) {
    $output .= '<tr class="pane-title-row"><td colspan="2">'. $title

in template file.

Quick fix for this bug

This code produce no error:

function uc_cart_theme() {
...
'uc_cart_checkout_review' => array(
      'arguments' => array('panes' => NULL, 'form' => NULL),
      'file' => 'uc_cart.pages.inc',
    ),
...

with template file "uc_cart_checkout_review.tpl.php".

CommentFileSizeAuthor
#5 ubercart-497872-5.patch515 bytescedarm
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rszrama’s picture

Version: 6.x-2.0-rc3 » 6.x-2.x-dev

So... I don't understand why you also dropped $help or what exactly it is you're trying to do. : ?

quiptime’s picture

The variable $help produce an error in the file "uc_cart_checkout_review.tpl.php".

The error message is:

warning: Invalid argument supplied for foreach() in /.../sites/all/themes/.../uc_cart_checkout_review.tpl.php on line 12.

The line 12 is:

foreach ($panes as $title => $data) {

This is the part of the function uc_cart_theme() call the theme function:

    'uc_cart_checkout_review' => array(
      'arguments' => array('help' => NULL, 'panes' => NULL, 'form' => NULL),
      'file' => 'uc_cart.pages.inc',
    ),

This is the first line of the theme function theme_uc_cart_checkout_review():

function theme_uc_cart_checkout_review($panes, $form) {

The parameter variable $help no exist in this function. This produce the error in the template file.

Without the variable $help in the function uc_cart_theme() no error with "uc_cart_checkout_review.tpl.php".

rszrama’s picture

Ok, so I'm not really sure what you're pointing out as a bug. Is it that we should be defaulting panes to array() instead of NULL in that hook_theme() implementation and removing the $title variable from it?

rszrama’s picture

Issue tags: +theme layer, +ubercamp sprint
cedarm’s picture

FileSize
515 bytes

The theme function is defined as
function theme_uc_cart_checkout_review($panes, $form) {
and appears to only be called from uc_cart_checkout_review()
$output = theme('uc_cart_checkout_review', $data, $form);
where $data is pane information. I can't reproduce the warning, but shouldn't hook_theme be changed to match?

Looks to me like removing help is the appropriate change.

Island Usurper’s picture

Status: Active » Fixed

So, yes, it's a bug to declare that theme_uc_cart_checkout_review() takes three parameters when it only takes two. However, symptoms don't appear until someone alters the theme registry to use a template file instead of the theme function. I think it's worth fixing.

Committed patch.

Status: Fixed » Closed (fixed)
Issue tags: -theme layer, -ubercamp sprint

Automatically closed -- issue fixed for 2 weeks with no activity.