warning: array_shift() [function.array-shift]: The argument should be an array in C:\webserver\Apache2.2\htdocs\drupal\includes\form.inc on line 1333.

This error present even in clean installations, after update taxonomy vocabulary to use HS.

What I have:

Clean Drupal Installations
Clean URLs +
Hierarchical Select 6.x-3.5 2010-Sep-08
Hierarchical Select Taxonomy 6.x-3.5 2010-Sep-08

Status report of Hierarchical Select:

All updates installed. Implementation modules are installed correctly.

What I do:

1) I set up clean Drupal Installations
2) was Enabled Hierarchical Select
3) was Enabled Hierarchical Select Taxonomy
4) was Created Vocabulary (no specific configuration, only vocabulary name)
5) was Enabled Hierarchical Select for this (in 4 steps) vocabulary
6) When I saved configuration, I seen a error:

warning: array_shift() [function.array-shift]: The argument should be an array in C:\webserver\Apache2.2\htdocs\drupal\includes\form.inc on line 1333.
CommentFileSizeAuthor
#33 hs_taxonomy.module-910798.patch2.21 KBtacituseu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Assigned: Unassigned » Wim Leers

I'll look into this when I get back from my current vacation.

Thanks for the very clear bug report, the way it should be! :) What a relief, to see a proper bug report, once in a hundred or so times :)

Andrew Gorokhovets’s picture

Thanks :-)

gamesmasta’s picture

Assigned: Wim Leers » gamesmasta

I received the same message under similar circumstances:

warning: array_shift() [function.array-shift]: The argument should be an array in /usr/local/projects/drupal/drupal-6.14/includes/form.inc on line 1331

Also tried it on my local XAMPP server, same issue:

array_shift() expects parameter 1 to be array, null given in C:\xampp\htdocs\drupal-6.19\includes\form.inc on line 1337.

This was received after saving a vocabulary.

gamesmasta’s picture

Assigned: gamesmasta » Unassigned

Sorry for double post: I'm not sure if this is a result of the above issue or an unrelated issue:

Before: http://imgur.com/7If3P.png
After: http://imgur.com/ahaee.png

If I add the selected tag for Armenian as Advanced, then my previously selected languages (Arabic & Bengali) will automatically be populated with Advanced entries also. Expected outcome is that it does not populate other languages.

Vocabulary list contains terms of languages and 3 proficiency terms (Beginner, Intermediate, Advanced), which are set with the previous languages being set as parents.

marcxy’s picture

same exact bug.

Subscribed.

Wim Leers’s picture

Assigned: Unassigned » Wim Leers
tobiberlin’s picture

subscribed

no2e’s picture

(same bug here)
subscribed

kpm’s picture

same... subscribed

DavidBoo’s picture

same

Alessandro S.’s picture

same... subscribed

vip_sa’s picture

Same bug here

dallasw1983’s picture

I'm running into the same problem...

I had this before on another module. I believe the problem to be PHP5. I found the fix to my other problem here http://drupal.org/node/36408

a quick look into the PHP manual reveals that "The behavior of array_merge()
was modified in PHP 5". Read Example 3 at http://us3.php.net/manual/en/function.array-merge.php.

I don't know much about PHP code, but I'm guessing that line 1337 should be array_merge

 $parent = array_shift($parents);

should be something like

 $parent = array_merge((array)$data, (array)$parents);

I did try this but I got the WSOD, so yet again, I don't know much about PHP...

yamenshahin’s picture

Same error here

REMUU’s picture

Having the same problem unfortunately

shiolo’s picture

same problem..

botris’s picture

Subscribe

Berliner-dupe’s picture

Subscribe

kpm’s picture

Issue tags: +null

I'm not sure if this info helps...
I have created a few vocabularies, 'Section', 'Location', and 'Tags'. The first two use Hierarchical Select, the last is standard Drupal free tagging.
I have vertical tabs enabled and on the 'Vocabularies' tab, where the list of vocabularies should appear when editing a post that has terms, what I see is this:

Vocabularies
null,
Tags: example 1, example 2

So I'm getting the 'null' reported under the vocabularies section of a create or edit post wherever Hierarchical Select is used. The Tags vocabulary is listed with whatever tags already exist on a post.

If it is a new post, then all that is displayed is the "null, "

Aldus’s picture

subscribe

tobiberlin’s picture

subscribing... changed the vocabulary to use Hierachical Select and got the message.

Amy_M’s picture

Subscribing

Anonymous’s picture

not sure if is coincidental that its on line 1337

tribe_of_dan’s picture

Subscribe

perke’s picture

+1, subscribing

edit: just noticed it is only throwing error when vocabulary is not set to "Multiple select" (and that makes sense to me)

gregoiresan’s picture

Issue tags: -null

Got the error with "Multiple Select" enabled. But, I don't have the error when I re-edit it... only just when I enable Hierarchical Select.

juantoyoshi’s picture

suscribing

Stomper’s picture

I am getting the same error on when I save a taxonomy vocabulary and enable hierarchical select with force user to select deepest level:

"warning: array_shift() [function.array-shift]: The argument should be an array in "

I am running version 6x-3.6 on D6.19 if it matters, as this issue was originally created for version 6x-3.5

ttaylor797’s picture

I am experiencing the same issue as soon as the module is enabled.

dietmarg’s picture

subscribe

NaX’s picture

Version: 6.x-3.5 » 6.x-3.6
Status: Active » Needs work

I think this bug is caused by the validate function hierarchical_select_taxonomy_form_vocabulary_validate() in hs_taxonomy.module on line 756.

I changed this:

  // If Hierarchical Select is enabled, disable freetagging.
  if ($form_state['values']['hierarchical_select_status']) {
    form_set_value($form['tags'], 0, $form_state);
  }

To this:

  // If Hierarchical Select is enabled, disable freetagging.
  if (!empty($form['tags']) && $form_state['values']['hierarchical_select_status']) {
    form_set_value($form['tags'], 0, $form_state);
  }

And the error went away. The problem seems to be that sometimes the tags array does not exist and then when form_set_value() is called there is no #parents attribute to pass to _form_set_value(). I don't know why the tags array is sometimes empty, maybe HS is un-setting it some place.

Suggestion: With regards to PHP bugs like this one.
For community members that what to try and help trace bugs should consider using the Devel module. I traced this bug using the Devel module by setting Error handler to Backtrace. You will start getting a lot of notices and sometimes "Cannot modify header information" errors. These can all be safely ignored. The backtrace will then give you the function execution order in reverse starting at the the point of the error. Even if you not a PHP dev just by being able to point other devs in the right direction can help a lot and save a lot of time and more importantly fix bugs faster.
I hope somebody else finds this useful.

tacituseu’s picture

Version: 6.x-3.6 » 6.x-3.x-dev
Status: Needs work » Needs review
FileSize
2.21 KB

It's caused by $form['tags'] being undefined, it should be $form['settings']['tags']. It happens only when enabling hierarchical taxonomy and not on subsequent edits because this code in hs_taxonomy_form_taxonomy_form_vocabulary_alter() creates it (should set $form['settings']['tags'] and $form['settings']['multiple']):

  if (variable_get("taxonomy_hierarchical_select_$vid", 0)) {
    $form['tags']['#attributes']['disabled'] = TRUE;
    $form['tags']['#description'] = t(
      "This setting is irrelevant when you're using Hierarchical Select.
      <br />Use Hierarchical Select's %editability-settings instead.",
      array('%editability-settings' => t('Editability settings'))
    );
    $form['multiple']['#attributes']['disabled'] = TRUE;
    $form['multiple']['#description'] = t(
      "This setting is managed by the Hierarchical Select configuration, by
      the %enable-dropbox setting.",
      array('%enable-dropbox' => t('Enable the dropbox'))
    );
  }
Wim Leers’s picture

Title: Error: array_shift() [function.array-shift]: The argument should be an array » PHP error when editing a vocabulary
Status: Needs review » Fixed

That must have changed in core then, because this surely was working at some point in time.

Thanks for the excellent patch, tacituseu! :) Committed!

http://drupal.org/cvs?commit=495404

Status: Fixed » Closed (fixed)

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