Just installed OpenGraph to control thumbnails of sharable items. That works.

Getting LOTS of "already output" messages in watchdog.

opengraph_meta	Feb 6 2012 - 2:28pm	Already output og:site_name	Guest	
opengraph_meta	Feb 6 2012 - 2:28pm	Already output og:url		Guest	
opengraph_meta	Feb 6 2012 - 2:28pm	Already output og:description	Guest	
opengraph_meta	Feb 6 2012 - 2:28pm	Already output og:title		Guest

Oddly only the og:site_name and og:title meta tags are repeated in the head.

How can I tackle this?

Comments

mazdakaps’s picture

having the same issue

doublejosh’s picture

Issue summary: View changes

spacing

quercus020’s picture

I'm having the same issue too. I have open graph set up to work on just one content type, and all works fine on the individual node pages. My frontpage is a view showing 15 teasers of the content type. Unfortunately opengraph tries to output meta tags for all the teasers on the frontpage...one works (the first teaser) the rest just creates 14 sets of warnings in the admin report. Seems to me open graph should only work on full node and not a view but I can't find a work around.
I'm on D7 and opengraph 1.2

doublejosh’s picture

That's good background, but the functions that load up the tags seem to be careful about only full page mode.
I see repeated tags (described in #1) on the full page.

D7

function opengraph_meta_node_load($nodes, $types) {
  foreach($nodes as &$node){
    if (OpenGraphMeta::instance()->tags_are_enabled_for_content_type($node->type)) {
      $node->opengraph_meta = OpenGraphMeta::instance()->load_node_data($node);
    }
  }
}
function opengraph_meta_node_view($node, $view_mode, $langcode){
  // only show meta tags if viewing full node as a page
  if ('full' == $view_mode && !empty($node->opengraph_meta)) {
    OpenGraphMeta::instance()->render_data($node, $node->opengraph_meta);
  }
}

D6

function opengraph_meta_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
  switch ($op) {
// ...
    case 'load':
      if (OpenGraphMeta::instance()->tags_are_enabled_for_content_type($node->type)) {
        return array('opengraph_meta' => OpenGraphMeta::instance()->load_node_data($node));
      }
      break;
    case 'view':
      // only show meta tags if viewing full node as a page
      if (NODE_BUILD_NORMAL == $node->build_mode && !$teaser && $page && !empty($node->opengraph_meta))
        OpenGraphMeta::instance()->render_data($node, $node->opengraph_meta);
  }
}
WillGFP’s picture

Version: 6.x-1.6 » 7.x-1.2

Same problem here, happens on a page with a View that displays many different nodes. Looks like it's trying to write duplicate metatags for each node on the page. Perhaps there's a way to disable the module on certain pages? Or only output one tag for pages with multiple nodes?
Version 7.x - 1.2.

doublejosh’s picture

Think there are two conversations going on here.

#1) My original issue is that I'm seeing duplicate meta tags on full node pages and error messages in the logs.

#2) People are seeing multiple meta tags on pages with multiple nodes.

Island Usurper’s picture

Component: Documentation » Code

This might not be everyone's problem, but I noticed on my site that webform blocks display nodes in 'full' build mode ($page = 1 for D6). This makes opengraph_meta try to display tags for that node as well, even if the page's actual node has been processed.

Maybe in hook_node_view() it should check that it's the same node returned by menu_get_object(). If it's not a node page, then the meta tags are going to supplied by some other code, most of the time. Right?

guybedford’s picture

For me, the "already output" message wasn't stopping the module from working, but was an annoyance in polluting the logs.

As a temporary fix, I disabled the log messages by commenting out line 256 of opengraph_meta.common.inc.

guybedford’s picture

StatusFileSize
new779 bytes

Actually, this does functionally mess up quite badly. I've attached a patch which restricts the module to only work for node pages. Again, this is a quick fix that worked in my particular case, I'm sure there is a much more elegant solution.

doublejosh’s picture

Revisiting, not sure why but the watchdog messages are no longer appearing.
However the duplicates are still in the head for openGraph enabled node pages. Looks like they are being adding at two different times...

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta property="og:site_name" content="My Site Title" />
  <meta property="og:title" content="My Content Title" />
  <meta property="og:site_name" content="My Site Title" />
... other meta and link tags...
  <link rel="canonical" href="/blog/2012/9/my-content-title" />
  <meta property="og:description" content="Description of my content" />
  <meta property="og:title" content="My Content Title" />
  <link rel="shortlink" href="/node/#####" />
  <meta property="og:image" content="http://cdn.mysite.com/sites/default/files/xxxxxxx.png" />
  <title>My Content Title | My Site Title</title>
  <link type="text/css" rel="stylesheet" href="http://cdn.mysite.com/sites/default/files/css/xxxxxxx1.css" media="all" />
  <link type="text/css" rel="stylesheet" href="http://cdn.mysite.com/sites/default/files/css/xxxxxxx2.css" media="all" />
</head>

NOTE: I'm not experiencing the view page issue, however I don't have any full node (or teaser) views.

shaneonabike’s picture

Maybe I shouldn't have created a different issue (#2028913: Cron stops working due to Already output og:xxx messages) but in D6 this is also an issue. An actually while these messages might seem harmless they are causing cron to timeout. This means that content is not being indexed by the search ... oops. :(

I tried to apply a similiar patch to the fix above but it didn't do anything different...

shaneonabike’s picture

Issue summary: View changes

strong

jtsnow’s picture

Issue summary: View changes

This seems to be a pretty major defect.

I've patched my copy of the module to call node_is_page() to check if open graph tags should be rendered in opengraph_meta_node_view().

stevieb’s picture

I'm also seeing this issue ... patch in #8 works

hargobind’s picture

The code that generates the warning looks like this:

opengraph_meta/opengraph_meta.common.inc, line 254: render_data()

      // already written this meta tag to output?
      if (array_key_exists($field, $this->tags_already_output)) {
        $this->warn(t("Already output og:%s",array('%s' => $field)));
        continue;
      }

And that is being called by:

   // only show meta tags if viewing full node as a page
   if ('full' == $view_mode && !empty($node->opengraph_meta)) {
     OpenGraphMeta::instance()->render_data($node, $node->opengraph_meta);
   }

First, there are multiple use-cases where $view_mode == 'full' such as nodes being displayed by Panels or Views. So the idea of tags being generated more than once it's actually pretty common, and it's not a problem.

I think the real "issue" here is the warning message itself. Is "warning" the correct type of status to use here? I think it creates a false sense of emergency. A better solution would be to allow the administrator to choose if they even want to see the message at all. And given my first point above, I think "Do not display the warning" should be the default behavior.

For any sites that I managed, I'm just going to comment out the warning line entirely.

trrroy’s picture

StatusFileSize
new615 bytes

I can't argue with @hargobind that #8 may not be the best solution but I've been using it for a while on my site and it's working fine for my use case.

Attached is a re-roll of #8 which applies cleanly against version 7.x-1.3.

  • torotil committed 32e5b0f on 7.x-1.x
    Issue #1431846 by guybedford, trrroy, doublejosh: Tons of "already...
torotil’s picture

Status: Active » Fixed

This is now fixed in 7.x-1.x. Thanks everyone for contributing!

Status: Fixed » Closed (fixed)

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

ykarthikvarma’s picture

Issue still exists in latest version as well.

Thanks @trrroy the patch does work.