Index: nodewords.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodewords/nodewords.module,v
retrieving revision 1.57.2.356
diff -u -p -r1.57.2.356 nodewords.module
--- nodewords.module	30 May 2010 01:44:53 -0000	1.57.2.356
+++ nodewords.module	28 Oct 2010 19:59:14 -0000
@@ -644,30 +644,45 @@ function nodewords_save_tags($tags, $opt
 
   foreach ($tags as $name => $content) {
     if (isset($tags_info[$name])) {
-      $content = serialize($content);
+      $has_value = FALSE;
+      if (!empty($content['value'])) {
+        $has_value = TRUE;
+        // $content['value'] might just contain an array of empty settings, in
+        // which case there isn't anything worth saving to the db.
+        if (is_array($content['value'])) {
+          $filtered = array_filter($content['value']);
+          $has_value = !empty($filtered);
+        }
+      }
+
       $result = _nodewords_get_tags_data($name, $options);
 
       if ($result === FALSE) {
-        $row = _nodewords_init_tags_data($name, $options);
+        // We write a new record to the database only if there's content to write
+        if ($has_value) {
+          $row = _nodewords_init_tags_data($name, $options);
+        }
       }
       else {
         $row = $result;
       }
 
-      $row->content = $content;
-
-      $ret = drupal_write_record('nodewords', $row, isset($row->mtid) ? 'mtid' : array());
-
-      if (!$done && $options['log_message'] && $ret) {
-        watchdog(
-          'meta tags',
-          'User %name changed the meta tags for type %type (%id).',
-          array(
-            '%name' => $user->name, isset($types_str[$options['type']]) ? $types_str[$options['type']] : t('unknown'), '%id' => $options['id']
-          )
-        );
-
-        $done = TRUE;
+      if (isset($row)) {
+        $content = serialize($content);
+        $row->content = $content;
+  
+        $ret = drupal_write_record('nodewords', $row, isset($row->mtid) ? 'mtid' : array());
+  
+        if (!$done && $options['log_message'] && $ret) {
+          watchdog(
+            'meta tags',
+            'User %name changed the meta tags for type %type (%id).',
+            array(
+              '%name' => $user->name, isset($types_str[$options['type']]) ? $types_str[$options['type']] : t('unknown'), '%id' => $options['id']
+            )
+          );
+          $done = TRUE;
+        }
       }
     }
   }
