You are here

function system_update_172 in Drupal 4

Same name and namespace in other branches
  1. 5 modules/system/system.install \system_update_172()

File

database/updates.inc, line 1561

Code

function system_update_172() {

  // Multi-part update
  if (!isset($_SESSION['system_update_172'])) {
    $_SESSION['system_update_172'] = 0;
    $_SESSION['system_update_172_max'] = db_result(db_query('SELECT MAX(cid) FROM {comments}'));
  }
  include_once './modules/comment.module';
  $limit = 20;
  $result = db_query_range("SELECT cid, thread FROM {comments} WHERE cid > %d ORDER BY cid ASC", $_SESSION['system_update_172'], 0, $limit);
  while ($comment = db_fetch_object($result)) {
    $_SESSION['system_update_172'] = $comment->cid;
    $thread = explode('.', rtrim($comment->thread, '/'));
    foreach ($thread as $i => $offset) {

      // Decode old-style comment codes: 1,2,...,9,90,91,92,...,99,990,991,...
      $thread[$i] = int2vancode((strlen($offset) - 1) * 10 + substr($offset, -1, 1));
    }
    $thread = implode('.', $thread) . '/';
    db_query("UPDATE {comments} SET thread = '%s' WHERE cid = %d", $thread, $comment->cid);
  }
  if ($_SESSION['system_update_172'] == $_SESSION['system_update_172_max']) {
    unset($_SESSION['system_update_172']);
    unset($_SESSION['system_update_172_max']);
    return array();
  }
  return array(
    '#finished' => $_SESSION['system_update_172'] / $_SESSION['system_update_172_max'],
  );
}