Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I get this strict warning when I ask a question in faq_ask module: Strict warning: Only variables should be passed by reference in faq_ask_node_insert(). The PHP file is faq_ask module and the path to it's location is: sites\all\modules\faq_ask\faq_ask.module). The code looks like this:

  // Are we notifying the expert(s)?
   if (variable_get('faq_ask_notify',FALSE)) {
   // Use only the first term entered in the correct vocabulary.
   $term = taxonomy_term_load(array_shift(array_keys($terms)));

The code is found around line 466 in the faq_ask module file. I've been looking around for a solution to this probleme but I dont know much PHP, I just started focusing on the subject, and the fact is; I'll probabely never be a expert.

share|improve this question
Welcome to Drupal Answers :) Unfortunately this isn't the place to report bugs with contributed modules. The module issue queue would be the best place to report it; please feel free to copy the code from the answer below as a suggested fix – Clive Nov 6 '12 at 0:18

closed as off topic by Clive Nov 6 '12 at 0:16

Questions on Drupal Answers are expected to relate to drupal within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

You're getting the warning because array_shift() takes its first argument by reference, and to pass a variable by reference it needs to be defined. At the moment you're passing the evaluation of a function call (array_keys($terms)), which isn't a variable.

You can remove the warning by changing your code to:

$tids = array_keys($terms);
$term = taxonomy_term_load(array_shift($tids));
share|improve this answer
1  
The answer is correct, but that is, I think, a contrib module and this should reported as a bug, not asked here. We can't answer a bug away :) – Berdir Nov 6 '12 at 0:14
@Berdir Oops yes you're right, I didn't notice it was a contrib module :) – Clive Nov 6 '12 at 0:16
Sorry if I made someone do something they're not supposed to do, but I'm all new to this and I've been searching for a week to find a solution to this warning. I will report this as a bug asap, and by the way; THANKYOU for helping me with this. – Jon Vikan Nov 6 '12 at 8:44

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