No errors in drush wd-show but there are these warnings I was advised to share here:

Warning: htmlspecialchars_decode() expects parameter 1 to be string, array given in Drupal\metatag\MetatagManager->generateElements() (line 299 of /home/zantech0/public_html/benia.biz/modu
Warning: preg_match_all() expects parameter 2 to be string, array given in Drupal\Core\Utility\Token->scan() (line 246 of /home/zantech0/public_html/benia.biz/core/lib/Drupal/Core/Utility/
Warning: htmlspecialchars_decode() expects parameter 1 to be string, array given in Drupal\metatag\MetatagManager->generateElements() (line 299 of /home/zantech0/public_html/benia.biz/modu
Warning: preg_match_all() expects parameter 2 to be string, array given in Drupal\Core\Utility\Token->scan() (line 246 of /home/zantech0/public_html/benia.biz/core/lib/Drupal/Core/Utility/

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Benia created an issue. See original summary.

DamienMcKenna’s picture

Category: Support request » Bug report

That sounds like one of the meta tags stores multiple values and code somewhere is trying to process the meta tag's value array incorrectly..

DamienMcKenna’s picture

Status: Active » Postponed (maintainer needs more info)

I'm unable to identify where this could be happening, please try updating to the latest -dev snapshot and let me know if the problem persists.

If the problem does continue happening, please install the Devel module and see if you use it to identify what is causing the problem.

Benia’s picture

Hi ! can I update the current module version to the latest dev release?

If I can't, I'll just backup the site in Ubuntu, delete the current module with all its data, and try there.

---

Btw, I can use devel; If you need any specific data from Devel, please tell me and I will try to extract it.

DamienMcKenna’s picture

Yes, you should be able to update to the -dev snapshot without any problems, in theory anyway ;-) Please also update Token, the latest version fixes issues with it.

Benia’s picture

I searched in Google how to update a module in D8 to dev version but found mostly data to D7. I tried to replicate the D7 data with drush and did there: drush up metatag 8.x-1.x-dev Though it outputted: "No code updates available."

probably a different way available?

DamienMcKenna’s picture

Try this: drush dl metatag-8.x-1.x-dev

Benia’s picture

Well, I did drush up and updated token to version 8.x-1.0-beta1 ...

I then did drush dl metatag-8.x-1.x-dev and now uses this version.

I did drush cr and then drush ws --full but I still see the exact same errors... :\

DamienMcKenna’s picture

Status: Postponed (maintainer needs more info) » Active
FileSize
1.04 KB

Ok.

Please try this patch, let me know what it outputs.

Benia’s picture

It seems that the patch fixed the issue. Thanks!!! Here is the full drush trace:

zantech0@siteground341 [~/www/benia.biz/modules/metatag]# git apply metatag-n2776785-9.patch
zantech0@siteground341 [~/www/benia.biz/modules/metatag]# drush cr
Cache rebuild complete.                                                                                                                                                                                                           [ok]
zantech0@siteground341 [~/www/benia.biz/modules/metatag]# drush ws --full
 ID      Type      Message                                                                                                                                                                                Severity  Location                                             Hostname      Date
 102894  php       Warning: uasort(): Array was modified by the user comparison function in Drupal\token\Token->getInfo() (line 53 of /home/zantech0/public_html/benia.biz/modules/token/src/Token.php).  warning   http://www.benia.biz/blog/customer-interaction-tips  207.46.13.61  15/Aug 05:18

zantech0@siteground341 [~/www/benia.biz/modules/metatag]#
  • The above token error repeats itself many times.


If you need to check any devel data please tell me what it is and I will gladly extract it (I'm new to Devel, saw an intro do Devel 8 in Youtube but might need a bit detailed explanation where to look for the data).

Thanks again for all your time and help!!!

DamienMcKenna’s picture

The patch couldn't have fixed the problem, it should just display more info when the bug happens. I forgot to mention, you also need to install the "Devel Kint" module that comes with Devel, once you have that installed it should start displaying extra info.

Benia’s picture

I printed kint($variables) under preprocess_html. What data needed?

DamienMcKenna’s picture

The patch should output a bunch of information if it comes across a scenario where htmlspecialchars_decode() is being passed an array, see if you can trigger that scenario again.

Benia’s picture

When I go to kint on a node with Metatag data and all +- 1000 rows appear I can't track htmlspecial or even ().

I think I'm not in the right place.

DamienMcKenna’s picture

You shouldn't need to go to a specific Kint page to see the messages, they should be displayed on the page where the errors were happening.

If the errors only showed in Drush, try changing the lines to use print_r() instead of kint() and run the drush commands again.

Benia’s picture

Okay now drush ws --full does show 2 errors:

 106820  php       Warning: uasort(): Array was modified by the user comparison function in Drupal\token\Token->getInfo() (line 51 of /home/zantech0/public_html/benia.biz/modules/token/src/Token.php).         warning   http://www.benia.biz/blog/should-  66.249.69.4     15/Aug 20:49

you-live-from-advertisements-qm

 106819  php       Warning: htmlspecialchars_decode() expects parameter 1 to be string, array given in Drupal\metatag\MetatagManager->generateElements() (line 304 of /home/zantech0/public_html/benia.biz/modu  warning   http://www.benia.biz/seo-herzliya  66.249.69.12    15/Aug 20:48
DamienMcKenna’s picture

Please see #2671060: Use SortArray::stableUasort instead uasort to prevent warnings (Array was modified by the user comparison function) for the Token issue.

So the htmlspecialchars_decode() error is happening on a specific page. Try changing the lines back to kint() instead of print_r(), viewing that page and see if you can see the errors.

Benia’s picture

Oh I saw that with kint... I happens basically on any page where there is Metadata I added with Metatag...

Given the 99% of such Metadata is in Hebrew, I guess it is related.

DamienMcKenna’s picture

Could you please upload a screenshot of the values, or contact me privately if you don't want to make that information public? That'll be the key to working out what's going wrong.

DamienMcKenna’s picture

FileSize
962 bytes

Try this patch, it should help spot what meta tag is causing the problem.

Benia’s picture

Seems not to apply (Should I worry from such an error? Has something partially changed?)

zantech0@siteground341 [~/www/benia.biz]# cd modules/metatag
zantech0@siteground341 [~/www/benia.biz/modules/metatag]# git apply metatag-n2776785-20.patch
error: patch failed: src/MetatagManager.php:293
error: src/MetatagManager.php: patch does not apply
zantech0@siteground341 [~/www/benia.biz/modules/metatag]#
zantech0@siteground341 [~/www/benia.biz/modules/metatag]#
DamienMcKenna’s picture

In that case, just replace this line:

          $processed_value = PlainTextOutput::renderFromHtml(htmlspecialchars_decode($this->tokenService->replace($tag->value(), $token_replacements, ['langcode' => $langcode])));

with these:

          $value = $tag->value();
          if (is_array($value)) {
            kint($tag_name);
            kint($value);
          }
          $processed_value = PlainTextOutput::renderFromHtml(htmlspecialchars_decode($this->tokenService->replace($value, $token_replacements, ['langcode' => $langcode])));
Benia’s picture

FileSize
118.62 KB

Please look what happens in the file itself when I do so...

DamienMcKenna’s picture

Ok. So what errors are displayed on the page now? You might need to be logged in as an admin in order to see them.

Benia’s picture

zantech0@siteground341 [~/www/benia.biz/modules/metatag]# git apply metatag-n277                                     6785-20.patch
fatal: corrupt patch at line 18
zantech0@siteground341 [~/www/benia.biz/modules/metatag]#

I've sent you Teamviewer details to email.

DamienMcKenna’s picture

Don't worry about the patch at this point, just focus on changing the file to match what is in #22 above and then see what messages are displayed on the website.

DamienMcKenna’s picture

Status: Active » Postponed (maintainer needs more info)

Does the problem still happen with the latest release?

Benia’s picture

Indeed, just did drush ws --full and seems it does...

Benia’s picture

It is most likely a migration issue because another site that was built right on D8 and not migrated from D7 doesn't have these errors even though I use metatag with it as well...

DamienMcKenna’s picture

Does the problem still happen with 1.2 or even the latest dev snapshot?

DamienMcKenna’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)
gngn’s picture

I still see the three described warnings with 8.x-1.16 (not current version but also not 4 years old).
Digging into it...

Update: I think the update_hook messed with the mask_icon configuration.
It changed from

-  mask-icon:
-    href: /safari-pinned-tab.svg
-    color: '#000000'

to

+  mask_icon:
+    href:
+      href: /safari-pinned-tab.svg
+      color: '#000000'

and thus introduced another "array layer".

Setting the correct values at /admin/config/search/ transformed the config back to the old value.
And with that it's working.
So sorry about the false alarm.