Hello, I've updated from 1.1 to 1.2 and I've had this error. The error message is:
PHP Fatal error: Unsupported operand types in /home/drupal7/public_html2/sites/translatedweb.com/modules/lang_dropdown/lang_dropdown.module on line 232
I saw the error yesterday after creating a node, the node was created but it wasn't showed. Today I've tried to see the node but I can't, the same error appears in the apache log. Here is the node, it's unpublished and you should be redirected to the login page, but the error happens to me too with the admin account. I've created other content without problems, so I think that it is not a big trouble.
I'm using Drupal 7.12 in Ubuntu Server with Apache2. This is my first bug report in drupal.org, please tell me if you need more information or I've done something wrong.
Kind regards.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | lang-dropdown-unsupported-operand-error-1461238-12.patch | 946 bytes | manfer |
| #9 | debug-languages-es.txt | 794 bytes | igalarza |
| #7 | debug-node-before-publish.txt | 1.5 KB | igalarza |
| #7 | debug-node-after-publish.txt | 1.5 KB | igalarza |
| #5 | lang-dropdown-unsupported-operand-error-1461238-5.patch | 524 bytes | manfer |
Comments
Comment #1
manfer commentedI can't see anything wrong in line 232. There is an union of arrays in that line and the operands are arrays so I don't see why you receive an unsupported operand types error.
Line 32
The only thing I can imagine is that $hidden_elements is NULL. But that shouldn't happen ever.
So I only can suggest to debug to try to understand why that's happening. You can just add before that line 232:
And with all that output probably we can try to guess what's happening.
Comment #2
igalarza commentedThanks for your fast reply, I've added your debug lines in the module and I've seen this notice in the logs:
Notice: Undefined variable: hidden_elements in lang_dropdown_form() (line 234 of /home/drupal7/public_html2/sites/translatedweb.com/modules/lang_dropdown/lang_dropdown.module).
You was right, hidden_elements is NULL. I've attached the values of the other variables.
Kind regards, and thank you again!
Comment #3
manfer commentedI don't understand how you have created that node in a way that all languages claims there is no translation.
so no of them has a href property. I can make a check to just don't show the language switcher at all in that case to avoid that weird problem. Adding this just before line 232:
should resolve that. But you should look why that is happening. What happens on that node if you enable the Drupal core language switcher block?
It seems as if you had created a node with no language but it is not a language neutral node either and I can't understand how you have done that. When you create a node in its language select you can choose one language or the "language neutral" option. There isn't any "no language" option.
The only thing I can imagine is if maybe the node is created with a language and later that language is removed from the list of available languages. Maybe in that case the node falls in that 'no language' state.
Comment #4
manfer commentedOk I think that is the problem, a node in a language that later is disabled or deleted.
The solution is to don't show language switcher at all in that case. Changing line 232:
to:
As a protection to avoid this weird problem that can happen in this case.
But the real solution is reenable the language in which that node is writen if you pretend to use that language.
Comment #5
manfer commentedComment #6
igalarza commentedHello, I've added your code and I can see the node now. However, the node's language is Spanish, and was set to spanish when was created, and this language is enabled in my site since the beggining (is my mother language).
Maybe happened something wrong when I created the node, but now I can see the node, with the spanish language selected.
Thank you again for your help, and kind regards.
Comment #7
igalarza commentedMore weird things.
I've moved all to my devel enviroment, and I've get the node info using the Devel module (it's attached), after that, I've published the node so you could see it, and now the dropdown is showed!! I don't know what happened but the "broken thing" has been repaired when the node was published.
Then I've unpublished the node, and the dropdown fails again! I'm using a boolean field and rules to publish/unpublish the nodes, could this be related?
Here is the node in the devel env.
Thank you again.
Comment #8
manfer commentedCould you edit node just to save it and then debug again the $languages variable to show here its content?
In that variable Spanish should have a href with the node url and language-link as a class in attributes:
Comment #9
igalarza commentedThere are not href nor language-link properties in $languages variable, when the dropdown works and also when it doesn't work. I've attached the output. In both cases the $languages variable is the same.
Regards.
Comment #10
manfer commentedI don't know whats wrong with that node that in my opinion has incorrect values in $languages variable.
Can you show your $languages variable in different node? Same debug in language dropdown switcher but in a node in which language switcher works fine.
I'm going to include the check code in language dropdown switcher to avoid this situation but the problem with your node is not related to language dropdown switcher and is really strange.
Comment #11
igalarza commentedYou are right, the other nodes have the href field:
...
'es' =>
array (
'href' => 'node/19309',
...
I belive that I know what happened. This must be related to pathauto module; when I created the node, I forgot to put the value in one field, a node relationship which is used to create the URL alias:
[node:field-website:title]/[node:title]
After I had added the value the alias was updated, but the error remained. I'm going to delete the node and re-create it, thank you one more time for your fast support. If I see any other thing I will write you.
Kind regards.
Comment #12
manfer commentedI'm going to push the following patch to solve this.
Comment #13
manfer commentedComment #15
botrisIs this patch committed? If not, it should be RTBC.
Comment #16
brycesenz commentedIf it helps to clarify what may have been happening, here is how I produced the error:
1. Create a site and enable three languages (English, Spanish, French).
2. Create some nodes, and provide translations in all three languages.
3. Later, disable one of the languages (e.g. German).
4. Try to create a new node, then recieve this error.
The patch seems to fix everything, so +1 on getting this committed.
Comment #17
botrisStill a bug but patch fixes everything
Comment #18
botrisJust had a look at the dev it looks like the patch is committed there. No idea when...
Comment #19
manfer commented