$form_state incorrectly passed by reference to hs_taxonomy_form_alter()

digi24 - November 7, 2009 - 01:40
Project:Hierarchical Select
Version:6.x-3.x-dev
Component:Code - Taxonomy
Category:bug report
Priority:minor
Assigned:Unassigned
Status:needs review
Description

Hey,

please correct me, if I am wrong, but should $form_state be really passed by reference? (it creates trouble for me, when using the functions from a custom module.

Index: hierarchical_select/modules/hs_taxonomy.module
===================================================================
--- hierarchical_select/modules/hs_taxonomy.module      (revision 1003)
+++ hierarchical_select/modules/hs_taxonomy.module      (working copy)
@@ -227,7 +227,7 @@
/**
  * Implementation of hook_form_alter().
  */
-function hs_taxonomy_form_alter(&$form, &$form_state, $form_id) {
+function hs_taxonomy_form_alter(&$form, $form_state, $form_id) {
   // Change the term selection of nodes. Only affects hierarchical
   // vocabularies.
   if (isset($form['type']) && isset($form['#node']) && (variable_get('taxonomy_override_selector', FALSE)) && $form['type']['#value'] .'_node_form' == $form_id) {

#1

Wim Leers - November 7, 2009 - 12:53
Title:Variable reference in hs_taxonomy_form_alter» $form_state incorrectly passed by reference to hs_taxonomy_form_alter()
Status:active» postponed (maintainer needs more info)

Interesting. I suppose that's indeed not needed. Probably a typo or copy/paste error.

If you can confirm everything keeps working for you, I'll commit it.

#2

digi24 - November 7, 2009 - 23:10
Status:postponed (maintainer needs more info)» needs review

It works for me and my users.

I haven't tested it in a setup with multiple hs forms, but as far as I can see, the function is not altering any $form_state data, its only checking for preview, so it should not make any difference.

Setting to "needs review" in case someone else would like to check too, but in my opinion it can be committed.

 
 

Drupal is a registered trademark of Dries Buytaert.