The double check on $args is actually incorrect and causes a notice on PHP 5.3/E_STRICT if $args is not passed.

Comments

fgm’s picture

Status: Active » Needs review
StatusFileSize
new997 bytes

Patch actually removes the useless first check causing the notice.

longwave’s picture

Agreed that the check is unnecessary, but what is the actual notice you see? If $args is not passed then the warning is surely from the function definition, and the hook documentation says $args is not optional. And if $args is empty why would isset($args[0]) generate a warning but isset($args[0]->nid) does not?

tr’s picture

Priority: Normal » Minor

PHP notices in 6.x are minor. What are the steps to reproduce this one?

fgm’s picture

Bad formulation from me: the check is useless, the notice happens on an earlier version (6.x-2.2) where the unnecessary check was not yet wrapped in a isset() as it is now. It looked like this:

function uc_product_forms($form_id, $args) {
  $forms = array();
  if (is_object($args[0]) && isset($args[0]->type)) {

The notice happens on the $args[0] because $args is just array(), which does not have a 0 index, when invoked from drupal_retrieve_form() without additional args on the upstream drupal_get_form(), I guess.

longwave’s picture

Title: Incorrect check in uc_product_forms() » Unnecessary check in uc_product_forms()
Category: bug » task

In that case it's no longer a bug but a minor improvement, thanks for clarifying.

longwave’s picture

Status: Needs review » Fixed

Committed to both branches.

Status: Fixed » Closed (fixed)

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