Hi,
I was having a problem that after saving information on admin/content/nodewords/meta-tags, the form shows empty values, but the data was actually saved on the database.

After some investigation, I found that the function nodewords_load_tags didn't return the correct array with the data.

Below is the version of this function after I made some changes to make it work, and seems to be working now.

function nodewords_load_tags($type = NODEWORDS_TYPE_DEFAULT, $id = 0) {
  static $queries = array();

  // If the metatags haven't been loaded before, load them.
  if (!isset($queries[$type][$id])) {
    $result = db_query("SELECT * FROM {nodewords} WHERE type = %d AND id = %d", $type, $id);
    $tags = array();
    $tags_info = nodewords_get_possible_tags();

    while ($row = db_fetch_object($result)) {
      if (isset($tags_info[$row->name])) {
        $tags[$row->name] = unserialize($row->content);
      }
    }

    // If no metatags are found for this term, try loading the vocabulary's.
    if (empty($tags) && $type == NODEWORDS_TYPE_TERM) {
      $tags = nodewords_load_tags(NODEWORDS_TYPE_VOCABULARY, db_result(db_query('SELECT vid FROM {term_data} WHERE tid = %d', $id)));
    }

    // Cache the metatags for later.
    $queries[$type][$id] = $tags;
  }

  return $queries[$type][$id];
}
CommentFileSizeAuthor
#2 nodewords-n1277390.patch1.44 KBdamienmckenna

Comments

madhan mohan’s picture

Hi again,
I've faced some other issue with this version, custom meta tags (set on the node) were not being printed on the page, I was getting always the default tags.

Again some changes on nodewords_load_tags did the trick:

function nodewords_load_tags($type = NODEWORDS_TYPE_DEFAULT, $id = 0) {
  static $queries = array();
  
  if (is_array($type)) {
  	$options = $type;
  	$type = $options['type'];
  	$id = $options['id'];
  }

  // If the metatags haven't been loaded before, load them.
  if (!isset($queries[$type][$id])) {
    $result = db_query("SELECT * FROM {nodewords} WHERE type = %d AND id = %d", $type, $id);
    $tags = array();
    $tags_info = nodewords_get_possible_tags();

    while ($row = db_fetch_object($result)) {
      if (isset($tags_info[$row->name])) {
        $tags[$row->name] = unserialize($row->content);
      }
    }

    // If no metatags are found for this term, try loading the vocabulary's.
    if (empty($tags) && $type == NODEWORDS_TYPE_TERM) {
      $tags = nodewords_load_tags(NODEWORDS_TYPE_VOCABULARY, db_result(db_query('SELECT vid FROM {term_data} WHERE tid = %d', $id)));
    }

    // Cache the metatags for later.
    $queries[$type][$id] = $tags;
  }

  return $queries[$type][$id];
}

This function is called by nodewords_preprocess_page() by using the code: nodewords_load_tags($options), so a checking on the $type variable seems to fixed the problem.

damienmckenna’s picture

StatusFileSize
new1.44 KB

Thanks for finding that, I can't believe that bug slipped past!

Instead of applying the change of your second code snippet I just changed nodewords_preprocess_page() to pass the individual values.

damienmckenna’s picture

Status: Active » Needs review
damienmckenna’s picture

Issue tags: +v6.x-1.12 blocker

Tagging.

damienmckenna’s picture

Status: Needs review » Fixed
Issue tags: -v6.x-1.12 blocker

Committed. Thanks.

cfox612’s picture

I'm having this same issue, but I've never applied a patch. Where exactly do I place this code?

damienmckenna’s picture

Issue tags: +v6.x-1.12 blocker

@cfox612: You can also just try out the 6.x-1.x-dev version, it includes the fix and many more.

cfox612’s picture

I installed the dev version over the previous, and get a nice set of errors on the "other pages" tab:

warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'nodewords_pages_overview' was given in /var/www/development/sites/convention.agc.org/includes/form.inc on line 377.
warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'theme_nodewords_pages_overview' was given in /var/www/development/sites/convention.agc.org/includes/theme.inc on line 668.
damienmckenna’s picture

Getting off-track here, but make sure you clear your site caches and run the database updates.

cfox612’s picture

Priority: Critical » Minor

It's always the little things, thanks much!

damienmckenna’s picture

Priority: Minor » Critical

Resetting the priority. Lets leave this discussion closed, please start a new issue for any further issues. Thanks everyone :)

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