Hi,

I've encountered a rather strange bug on a client's site. They are using Organic Groups with custom themes and had Nodewords basic running for quite some time. Recently they needed the ability to control what's shared on Facebook, so we enabled nodewords_og. Doing so resulted in all groups with custom themes showing the main site theme.

I was able to trace the problem down to nodewords_og_nodewords_tags_info(). Not sure what exactly is happening as:

  • adding a return at the beginning of the function brings back the custom themes
  • we suspected it may be a namespace conflict, OG API coincidence with the tags callbacks, but renaming them didn't work.
  • renaming the module to nodewords_opengraph and replacing all "og" occurrences other than the actual tags to "opengraph" did not help either

The way OG works is by determining the context in hook_init() and if the user is on a OG, it sets the theme to the group's theme by changing the global variable $custom_theme among other things. To determine context, it calls node_load(). Normally all this happens before the theme layer kicks in, so init_theme() can pick up any changes to $custom_theme

However, nodewords implements hook_nodeapi() and it is in $op == 'load' where it tries to load all its tags. And somehow this triggers init_theme() before OG sets its context and custom theme.

The only solution I could find was to change $op from "load" to "view", but I am not sure what the implications on other modules are.

Any ideas?

Thank you,
Dan

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nicholas.alipaz’s picture

This seems to affect people using admin themes too. Our admin theme is not used in various places node/*/edit for example.

kepford’s picture

I can confirm that this issue exists outside of Organic Groups. I was able to reproduce this with both themekey module and a custom theme switching module.

DamienMcKenna’s picture

Does this also happen if the 'nodewords_extra' submodule is enabled instead of the OG submodule?

kepford’s picture

No, the issue does not occur with nodewords_extra enabled.

DamienMcKenna’s picture

Version: 6.x-1.14 » 6.x-1.x-dev

I have a testbed with the Nodewords dev release, Themekey and the following other modules:

  • block
  • color
  • comment
  • dblog
  • filter
  • help
  • menu
  • node
  • php
  • system
  • taxonomy
  • update
  • user
  • admin_menu
  • ctools
  • page_manager
  • devel
  • memcache_status
  • nodewords
  • nodewords_basic
  • nodewords_extra
  • nodewords_og
  • panels
  • panels_mini
  • phonetic
  • themekey
  • themekey_ui
  • token

The theme selection works just fine with the default Themekey settings and a configuration that changes the theme for a specific content type.

Could you please test out Nodewords v1.15-beta1 to see if that makes any difference?

DamienMcKenna’s picture

Status: Active » Postponed (maintainer needs more info)

Other than a namespace conflict purely because the module is named "nodewords_og" (thus matches the string "{$modulename}_og"), I don't see how this could be caused by Nodewords. I'm changing the status to Postponed until someone can show otherwise.

DamienMcKenna’s picture

Title: Organic Group loses custom theme when Nodewords Open Graph module is enabled » ThemeKey doesn't work when Nodewords Open Graph module is enabled
Status: Postponed (maintainer needs more info) » Fixed

So it turns out that the problem is because of module weights, the solution is to change the weight of the ThemeKey module until the switching starts working again. Check out #754970: Skipped rule checking because another module already initialized the theme engine for a long discussion about it. Thanks to kepford for finding that one.

DamienMcKenna’s picture

Status: Fixed » Needs review
FileSize
616 bytes

I'm going to add this note to the README.txt file.

DamienMcKenna’s picture

Committed.

  • Commit 4b57434 on 6.x-1.x by DamienMcKenna:
    Issue #1986230 by DamienMcKenna: Added a note to README.txt about the...
DamienMcKenna’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

zerolab’s picture

Hi,

I know this has been marked as closed for a while now, but changing weights did not solve the issue in the Organic Groups context.
Finally got some time to revisit this and found the issue: nodewords_og_get_tags() uses a %count token for the "og:description" description. As per https://api.drupal.org/api/drupal/includes%21common.inc/function/t/6, "%variable: escape text and theme as a placeholder for user-submitted content (check_plain + theme_placeholder)" -- thus triggers init_theme()

Attaching patch that changes %count to @count which fixes the issue.

DamienMcKenna’s picture

Status: Closed (fixed) » Needs review

@zerolab: Nice catch, thanks.

Status: Needs review » Needs work

The last submitted patch, 13: nodewords-og-theme-fix-1986230-13.patch, failed testing.

zerolab’s picture

Attaching a patch rolled against 6.x-1.x, rather than 1.14

zerolab’s picture

Status: Needs work » Needs review
DamienMcKenna’s picture

Status: Needs review » Closed (won't fix)

Thank you for taking the time to work on this. However, the module is no longer supported, so I'm closing this issue.