1

This question already has an answer here:

module name: User Relationships.

module version is: 7.x-1.0-alpha5

whenever i try to add relationship type or edit it give me this error:

Strict warning: Only variables should be passed by reference in theme_user_relationship_implications_form_table() (line 103 of C:\wamp\www\drupal\modules\user_relationships\user_relationship_implications\user_relationship_implications.module).
Strict warning: Only variables should be passed by reference in theme_user_relationship_implications_form_table() (line 104 of C:\wamp\www\drupal\modules\user_relationships\user_relationship_implications\user_relationship_implications.module).
Strict warning: Only variables should be passed by reference in theme_user_relationship_implications_form_table() (line 105 of C:\wamp\www\drupal\modules\user_relationships\user_relationship_implications\user_relationship_implications.module).

the code in user_relationship_implications.module is as follows:

function theme_user_relationship_implications_form_table($variables) {
$form = $variables['form'];
$headers = array(t('Relationship Type'), t('Strict'), t('Reverse'));
$rows = array();

foreach ($form['opts'] as $rtid => $elements) {
if (!is_numeric($rtid)) {
  continue;
}
$rows[$rtid] = array(
  drupal_render(array_shift($elements)), 
  drupal_render(array_shift($elements)),
  drupal_render(array_shift($elements)),
);
}
return theme('table', array('header' => $headers, 'rows' => $rows));
}

in the above code line 103-105 is:

drupal_render(array_shift($elements)), 
drupal_render(array_shift($elements)),
drupal_render(array_shift($elements)),

Can you please help me solve the error and also bring to my knowledge why does this occur?

marked as duplicate by kiamlaluno 7 Apr 3 '16 at 12:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

IMHO, this is a bug in the User Relationships module, and should be reported to that module's issue queue.

If you look at the documentation, you see that the template for drupal_render is:

drupal_render(&$elements)

Passing a function call by reference not good coding practice (but it will not have adverse effects if you never use the return value passed by reference).

The following will do the same thing and not produce the warning:

$_shift1 = array_shift($elements);
$_shift2 = array_shift($elements);
$_shift3 = array_shift($elements);
$rows[$rtid] = array(
  drupal_render($_shift1),
  drupal_render($_shift2), 
  drupal_render($_shift3), 
);

The module author probably doesn't have PHP-warnings enabled, and never saw the warning.

Not the answer you're looking for? Browse other questions tagged or ask your own question.