Opengraph keys are arrays in some cases - that should be prevented

Created on 9 June 2015, over 9 years ago
Updated 20 February 2023, over 1 year ago
 // Override with OpenGraph vars
  if (isset($variables['metatags']) && isset($variables['metatags']['og']) && is_array($variables['metatags']['og'])) {
    foreach ($keys as $key) {
      if (isset($variables['metatags']['og'][$key])) {
          $variables['tags'][$key] = $variables['metatags']['og'][$key];
      }
    }
  }

should be

 // Override with OpenGraph vars
  if (isset($variables['metatags']) && isset($variables['metatags']['og']) && is_array($variables['metatags']['og'])) {
    foreach ($keys as $key) {
      if (isset($variables['metatags']['og'][$key])) {
        if (is_array($variables['metatags']['og'][$key])) {
          $variables['tags'][$key] = array_pop($variables['metatags']['og'][$key]);
        }
        else {
          $variables['tags'][$key] = $variables['metatags']['og'][$key];
        }
      }
    }
  }

to remove array values.
It would even be better to find out where the array comes from and why this happens. This fix solves it somehow.

Any ideas for the reason? I think it doesn't make sense to write a patch for my quickfix?

The problem for example happens for this URL: http://fiskejournalen.se

πŸ› Bug report
Status

Fixed

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024