After installing the select_or_other module and changing the Google+ Page Type to Other, this errors comes up on the edit node page

Notice: Undefined index: #other_delimiter in select_or_other_element_process
Notice: Undefined index: #other_delimiter in select_or_other_element_process

Then when viewing the node this message comes up:

Warning: preg_match_all() expects parameter 2 to be string, array given in preg_match_all()
Warning: html_entity_decode() expects parameter 1 to be string, array given in html_entity_decode()

Only way to get rid of the error is to disable MetaTag Google+

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

demandajmenso’s picture

Same here.

If you replace the token ( [node:summary] ) for google plus description with a random text (or a token that returns a value) both errors go away. It seems that this token doesn't work at all. The same for [term:name] on taxonomy pages.
It's true that google plus metatag submodule has code for select_or_other intergration. Disabling either of them fixes (or hides?) all errors.

From my experience so far if your tokens return a string value there is no error what so ever.

s427’s picture

Same here. Moreover, it seems that the value entered in the "other" field (in my case it was "ImageGallery") is disregarded. On the summary page, it only says "Page type: " (empty string). (On the edit page, the field shows the correct value, though...)

I tried reverting the change by setting back the Google+ Page Type to one of the default values (e.g. "Article"), but the error messages still showed up, and the summary page still displayed an empty value for "page type".

I had to disable the select_or_other module for things to get back to normal.

DamienMcKenna’s picture

What version of select_or_other are you using?

DamienMcKenna’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
4.95 KB

Seeing as there are two different tags that use the module, I figured it might be worthwhile extending the API to allow addition all tags to add select_or_other support for all select tags.

DamienMcKenna’s picture

FYI I'm not expecting that the patch will specifically fix this issue, but if we centralize the code it'll make it easier to fix for all cases.

DamienMcKenna’s picture

Title: preg_match_all() expects parameter 2 to be string » select_or_other: preg_match_all() expects parameter 2 to be string
SeeWatson’s picture

I'm getting a similar error and figured I'd document it here.

I enabled Metatag 7.x-1.4 and various submodules of it(metatag, metatag_google_plus, metatag_opengraph, metatag_twitter_cards, metatag_panels) on my site , and I'm getting the following errors on every page:

Warning: preg_match_all() expects parameter 2 to be string, array given in token_scan() (line 124 of .../includes/token.inc).
Warning: html_entity_decode() expects parameter 1 to be string, array given in decode_entities() (line 463 of .../includes/unicode.inc).

They only appear the first time I load a page, and disappear on subsequent loads. If I clear the Drupal cache, they reappear for the first page load and then disappear.

I'm using the included defaults, don't have select_or_other installed, and haven't actually set any metatag values on any pages/nodes on the site.

The issue disappears if I disable metatag_google_plus.

noovocreative’s picture

I am getting the same error with only the metatag module enabled... never had google+ enabled.

Any ideas how to solve this?

roberttstephens’s picture

I get the preg_match_all() warning as well. Steps to reproduce.

- Go to admin/config/search/metatags
- Click Override next to global
- Don't change anything, just save it.
- Edit a node
- Put the following into the metatag page title field: [node:metatag:keywords]
- Save the node
- Flush all caches

The following shows

Warning: preg_match_all() expects parameter 2 to be string, array given in token_scan() (line 124 of /var/www/drupal7/includes/token.inc).
DamienMcKenna’s picture

DamienMcKenna’s picture

Status: Needs review » Fixed

I've committed the patch above because it's a good improvement to the API. I also tested out the latest select_or_other v3 codebase and it worked fine, so I suggest starting there.

  • DamienMcKenna committed ea11a17 on 7.x-1.x
    Issue #2449425 by DamienMcKenna: Refactored select_or_other usage, API...

  • DamienMcKenna committed 14de900 on 7.x-1.x
    Issue #2449425 by DamienMcKenna: Follow-up for select_or_other bug.
    

Status: Fixed » Closed (fixed)

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

roberttstephens’s picture

Status: Closed (fixed) » Active
FileSize
76.67 KB

DamienMcKenna, I am reopening this issue as it does not appear to be fixed. I can reproduce this issue using a clean installation with the following

- Drupal 7.38
- Metatag 7.x-1.x as of 2015-06-17 (commit 5e95cb624d4a17670d9cc84c2cbc3e22cf593a38)
- Token 7.x-1.6
- Ctools 7.x-1.7
- php 5.3.10

Steps to reproduce

  • Create article
    • title of node/2449425
    • body of node/2449425
    • Add [node:metatag:keywords] to the Page title field (overriding the default)
  • Go to admin/config/search/metatags
  • Click Override next to global
  • Don't change anything, just save it.
  • Flush all caches
  • View node

At this point, each time you flush cache and view the node you will see the following.

Warning: preg_match_all() expects parameter 2 to be string, array given in token_scan() (line 124 of /var/www/vm-www.example.com/includes/token.inc).

A screenshot is attached.

It has to do with the robots metatag value being an array, when loading metatags in the following manner.

$metatags = metatag_config_load_with_defaults('node:article');
var_dump($metatags['robots']['value']); # Returns an array. All other values return strings.

Around line 137 of metatag.tokens.inc, token_scan is called for each metatag value (title, description, etc). The function token_scan expects a string instead of an array.

If you would like me to open a new ticket instead of reopening this one, please let me know!

DamienMcKenna’s picture

Status: Active » Needs review
FileSize
588 bytes

This patch will skip any values that are arrays.

DamienMcKenna’s picture

DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

  • DamienMcKenna committed fa265be on 7.x-1.x
    Issue #2449425 by DamienMcKenna: Only process string values for token...

Status: Fixed » Closed (fixed)

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

jstoller’s picture

Status: Closed (fixed) » Active

Sorry to say, but I'm still seeing these PHP warnings in watchdog:

Warning: html_entity_decode() expects parameter 1 to be string, array given in decode_entities() (line 463 of /path/to/www/includes/unicode.inc).

Warning: preg_match_all() expects parameter 2 to be string, array given in token_scan() (line 124 of /path/to/www/includes/token.inc).

I'm running:

  • Drupal 7.39
  • Metatag 7.x-1.7
  • CTools 7.x-1.9
  • Select or Other 7.x-2.22
  • Token 7.x-1.6
  • PHP 5.5.9
DamienMcKenna’s picture

Status: Active » Postponed (maintainer needs more info)

@jstoller: I've tested this with select_or_other v2.22 and am unable to reproduce the problem? Where are you using select_or_other - as part of a configuration set or in an entity's values?

DamienMcKenna’s picture

Status: Postponed (maintainer needs more info) » Fixed
DamienMcKenna’s picture

Please open a new issue if the problem persists.

Status: Fixed » Closed (fixed)

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