We have two sites using 6.x-2.0-aplha1 which has been unsupported for a longtime and our client is bugging us regularly about it.

I was unsuccessful finding an issue where reverting is discussed. I thought I had raised it, but I can't locate it now.

What is our best path? If we revert to 1.x, would we lose all of our work?

If we revert, should we completely uninstall 2.0 before starting with 1.x?

All tips are appreciated.

Comments

DamienMcKenna’s picture

It has been a while since I tested this, but a key issue is that v2 used tokens whereas v1 doesn't (yet), so I would definitely recommend heavily testing it first.

danyg’s picture

Issue summary: View changes

Hi!

I had a same issue. I downgrade the module by deleting the 2.0-alpha1 nodewords directory and replace with the latest 1.x branch stable (1.4). THen I run update.php - it makes some updates.
Then check on admin/content/nodewords your settings. If you set some defaults in 2.0 version and used tokens, you should replace them from database. I've checked mine and there was some tokens in my description field: [metatags-description-raw]
So I wrote a batch process to replace these values in the database to current teaser value.

Here's my code I hope it helps - I run it from devel/php:

function _mymodule_nodewords_rebuild() {
  $batch = _mymodule_nodewords_rebuild_batch();
  batch_set($batch);
  batch_process('devel/php');

}

function _mymodule_nodewords_rebuild_batch() {
  $operations = array(
    array('_mymodule_nodewords_rebuild_operation', array())
  );

  $batch = array(
    'title' => t('Processing nodewords data rebuild'),
    'operations' => $operations,
    'finished' => '_mymodule_nodewords_rebuild_finished',
    'progress_message' => t('Processing...'),
    'error_message' => t('Nodewords migration has encountered an error.'),
  );

  return $batch;
}

function _mymodule_nodewords_rebuild_operation(&$context) {
  if (empty($context['sandbox'])) {
    $all = db_fetch_object(db_query("SELECT count(id) as allpost FROM {nodewords} n WHERE n.name = 'description' AND n.content LIKE '%[metatags-description-raw]%' AND id > 0"));
    $context['sandbox']['total_node'] = $all->allpost;

    // Initialize some variables.
    $context['sandbox']['node_count'] = 0;
    $context['sandbox']['batch_start'] = 1;
  }
  $limit = 50;

  $query = "SELECT n.mtid, n.content, nr.teaser, nr.nid FROM {nodewords} n LEFT JOIN {node_revisions} nr ON n.id = nr.nid WHERE n.name = 'description' AND n.content LIKE '%[metatags-description-raw]%' AND id > 0 ORDER BY mtid ASC";
  $result = db_query_range($query, 0, $limit);
  while ($row = db_fetch_array($result)) {
    $data = unserialize($row['content']);
    $teaser_raw = trim(strip_tags($row['teaser']));
    $suffix = '';
    if (strlen($teaser_raw) >= 128) {
      $sentence_end = strpos($teaser_raw, '.', 128);
    }
    else {
      $sentence_end = strlen($teaser_raw);
    }
    // Meta description recommended length is 155 character, so we should cut them
    if ($sentence_end >= 155 && strlen($teaser_raw) >= 155) {
      $sentence_end = strpos($teaser_raw, ' ', 155);
      $suffix = '...';
    }
    $data['value'] = substr($teaser_raw, 0, $sentence_end) . $suffix;
    $sql = "UPDATE {nodewords} SET content = '%s' WHERE mtid = %d";
    $args = array(serialize($data), $row['mtid']);
    $update = db_query($sql, $args);

    $context['results'][] = $row['nid'];
    $context['sandbox']['node_count']++;
  }

  $context['message'] = t('Nodes !node_count of !total_lines processed', array(
      '!node_count' => $context['sandbox']['node_count'],
      '!total_lines' => $context['sandbox']['total_node'],
    ));

  $context['finished'] = floor($context['sandbox']['node_count'] / $context['sandbox']['total_node'] * 100) / 100;
}

function _mymodule_nodewords_rebuild_finished($success, $results, $operations) {
  if ($success) {
    drupal_flush_all_caches();
    // Here we could do something meaningful with the results.
    // We just display the number of nodes we processed...
    $message = count($results) . ' processed.';
  }
  else {
    // An error occurred.
    // $operations contains the operations that remained unprocessed.
    $error_operation = reset($operations);
    $message = 'An error occurred while processing ' . $error_operation[0] . ' with arguments :' . print_r($error_operation[0], TRUE);
  }
  drupal_set_message($message);
}