* your Drupal site) and run it. It will convert no more than 1000 links at * a time, to minimize the chance of timeouts. You can safely re-run the * script multiple times. * * THIS CODE IS EXPERIMENTAL -- NOT FOR PRODUCTION USE */ require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); $sql = "SELECT DISTINCT n.nid, n.title, wl.*, wln.link_title, wln.weight FROM {node} n INNER JOIN {weblinks_node} wln ON n.nid=wln.nid INNER JOIN {weblinks} wl ON wl.lid=wln.lid LEFT JOIN {links_node} ln ON wln.nid=ln.nid WHERE n.type='weblink' AND ln.nid IS NULL LIMIT 1000"; $sql2 = "INSERT INTO {links_node} (lid,nid,link_title,weight,clicks,module) values (%d,%d,'%s',%d,%d,'links_weblink')"; $sql3 = "UPDATE {links} SET last_click_time=%d WHERE lid=%d"; print '<html><body>'; $count = 0; $result = db_query($sql); while ($row = db_fetch_object($result)) { $n_url = links_normalize_url($row->url); if (empty($n_url)) { print "<br>Node " . $row->nid . " was not converted (empty URL)"; continue; } $lid = links_put_link($n_url); if (!$lid) { print "<br>Node " . $row->nid . " was not converted (failed link insert)"; continue; } links_delete_links_for_node($row->nid); $title = links_suggest_link_title($lid, empty($row->link_title) ? $row->title : $row->link_title); $clicks = $row->clicks; $clicktime = $row->last_click_time; $result2 = db_query($sql2, $lid, $row->nid, $title, $row->weight, $clicks); $result3 = db_query($sql3, $clicktime, $lid);
* Next, copy this script to your Drupal root directory (the "top level" of * your Drupal site) and run it. It will convert no more than 1000 links at * a time, to minimize the chance of timeouts. You can safely re-run the * script multiple times. * * THIS CODE IS EXPERIMENTAL -- NOT FOR PRODUCTION USE */ require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); $sql = "SELECT DISTINCT n.nid, n.title, wl.* FROM {node} n INNER JOIN {weblink} wl ON n.nid=wl.nid LEFT JOIN {links_node} ln ON wl.nid=ln.nid WHERE n.type='weblink' AND ln.nid IS NULL LIMIT 1000"; $sql2 = "INSERT INTO {links_node} (lid,nid,link_title,weight,clicks,module) values (%d,%d,'%s',-5,%d,'links_weblink')"; print '<html><body>'; $count = 0; $result = db_query($sql); while ($row = db_fetch_object($result)) { $n_url = links_normalize_url($row->weblink); if (empty($n_url)) { print "<br>Node " . $row->nid . " was not converted (empty URL)"; continue; } $lid = links_put_link($n_url); if (!$lid) { print "<br>Node " . $row->nid . " was not converted (failed link insert)"; continue; } links_delete_links_for_node($row->nid); $title = links_suggest_link_title($lid, $row->title); $clicks = $row->click; $result2 = db_query($sql2, $lid, $row->nid, $title, $clicks); $count++; }