Received the following errors when previewing a new node:
- Warning: preg_match_all() expects parameter 2 to be string, array given in token_scan() (line 119 of /var/www/XPortal/includes/token.inc).
- Warning: strip_tags() expects parameter 1 to be string, array given in _metatags_quick_add_head() (line 389 of /var/www/XPortal/sites/all/modules/contrib/metatags_quick/metatags_quick.module).
- Warning: Parameter 1 to icl_content_node_view() expected to be a reference, value given in module_invoke_all() (line 819 of /var/www/XPortal/includes/module.inc).
- Warning: explode() expects parameter 2 to be string, array given in metatags_quick_field_widget_form() (line 353 of /var/www/XPortal/sites/all/modules/contrib/metatags_quick/metatags_quick.module).
I've tracked it down to $item['content'] in _metatags_quick_add_head() being an array, not a string. I'm not sure why it's an array instead of a string, or even if it's supposed to be an array already as I didn't go too far down that rabbit hole.
I've corrected the errors with a quick fix by placing an if(!is_array($item['content'])) around the portion that deals with $item['content'].
As for the errors on line 353, $items[$delta]['metatags_quick'] is already an array, so I've removed the explode().
I'll post my patch file, but it's not a great fix since I didn't track down the actual issue.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | metatags_quick-errors_when_previewing_a_node-1252270.patch | 1.15 KB | bdimaggio |
| #1 | fixed_node_preview_warnings-1252270-1.patch | 2.73 KB | mas5d2 |
Comments
Comment #1
mas5d2 commentedHere's my quick fix patch.
Comment #2
colinstables commentedHi i get the similar error message:
Warning: preg_match_all() expects parameter 2 to be string, array given in token_scan() (line 119 of C:\wamp\www\wds\includes\token.inc).
Warning: strip_tags() expects parameter 1 to be string, array given in _metatags_quick_add_head() (line 389 of C:\wamp\www\wds\sites\all\modules\metatags_quick\metatags_quick.module).
Warning: explode() expects parameter 2 to be string, array given in metatags_quick_field_widget_form() (line 353 of C:\wamp\www\wds\sites\all\modules\metatags_quick\metatags_quick.module).
However i don't know how to apply patch and by reading the guide i think i'll wait untill an update is made.
Can you tell me when this is likely to happen?
Thanks
Colin
Comment #3
valthebaldI would like to investigate the problem root before patching. Issue seems not critical, so there's only little chance I will get there soon. If anyone is interested - patches are welcome.
Comment #4
Anonymous (not verified) commentedI've had some of these errors as well but only when I opened the screen to create a new node from a certain content type that had some meta fields on it.
The problem was that I created the fields using the Drupal 7 custom field creator and used 'Add existing field' to copy a meta field from another content type. This isn't the way you should add meta fields. If you want to add meta fields, go to
admin/config/search/metatags_quickand choose to wich content types you want to add some of the default fields. This solved the problem for me.If you still want to add custom meta fields just add them using the Drupal 7 custom field creator but default meta fields should always be added through the metatags admin panel.
Comment #5
valthebaldComment #6
bdimaggioI'm seeing this problem too, and I definitely have not added the meta fields via the custom field GUI. I turned the module on, added only the "robots" field for nodes at /admin/config/search/metatags_quick, and immediately went to preview a page. I got
Looks like the Robots field sends its data to_metatags_quick_add_head() as an array rather than a string., and a couple of functions in there complain. I've just worked around those functions to produce this patch (against the current dev). Hope it helps!
Comment #7
bdimaggioHI there--I ended up back at this issue again with a need for... my very own patch! Any possibility of getting it committed?
Comment #8
valthebaldHi there!
I have a question - there is a check for is_array($content).
What should happen in else clause?
Comment #9
colinstables commented