/[drupal]/contributions/modules/links/update-weblinks-old.php
ViewVC logotype

Contents of /contributions/modules/links/update-weblinks-old.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Thu Feb 2 04:50:59 2006 UTC (3 years, 9 months ago) by syscrusher
Branch: MAIN
CVS Tags: DRUPAL-5--1-12-BETA1, DRUPAL-5--1-7, DRUPAL-5--1-9, DRUPAL-5--1-8, DRUPAL-5--1-5, DRUPAL-5--1-6, DRUPAL-5--1-3, DRUPAL-5--1-2, DRUPAL-6--1-0, DRUPAL-6--1-1, DRUPAL-6--1-2, DRUPAL-4-7--1-1, DRUPAL-5--1-4, DRUPAL-6--1-0-BETA15, DRUPAL-6--1-0-BETA14, DRUPAL-6--1-0-BETA13, DRUPAL-6--1-0-BETA12, DRUPAL-6--1-0-BETA11, DRUPAL-6--1-0-BETA10, DRUPAL-5--1-11, DRUPAL-5--1-10, DRUPAL-5--1-13, DRUPAL-5--1-12, DRUPAL-6--1-0-BETA9, DRUPAL-6--1-0-BETA8, DRUPAL-6--1-0-BETA3, DRUPAL-6--1-0-BETA2, DRUPAL-6--1-0-BETA1, DRUPAL-6--1-0-BETA7, DRUPAL-6--1-0-BETA6, DRUPAL-6--1-0-BETA5, HEAD
Branch point for: DRUPAL-4-7, DRUPAL-6--1, DRUPAL-6--2, DRUPAL-5
Changes since 1.2: +7 -7 lines
File MIME type: text/x-php
Lots of improvements to the update scripts, including the addition of a
new script for recent weblinks versions. The latter is UNTESTED as of now
due to lack of a test site. Test reports welcome if someone else gets
time to test it before I do.

Also added first draft of upgrade instructions.
1 <?php
2 // $Id: update-weblinks-old.php,v 1.2 2006/01/21 19:21:28 syscrusher Exp $
3
4 /**
5 * @file
6 * PHP page for updating legacy "weblink" nodes, from the old table format prior to
7 * Drupal 4.6.
8 *
9 * WARNING 1: This script will NOT work with Ber Kessels' new weblink.module for
10 * Drupal 4.6. Use update-weblinks.php instead!
11 *
12 * WARNING 2: Monitoring is not yet supported, and therefore this script does not
13 * migrate URL monitoring parameters. If you need that feature, you need to wait
14 * a bit before deploying the new links package.
15 *
16 * TO USE: First, update your site to Drupal 4.7 so that your {node} table gets
17 * converted.
18 *
19 * Second, install the new links module package, including links_related and
20 * links_weblink.
21 *
22 * Next, copy this script to your Drupal root directory (the "top level" of
23 * your Drupal site) and run it. It will convert no more than 1000 links at
24 * a time, to minimize the chance of timeouts. You can safely re-run the
25 * script multiple times.
26 *
27 * THIS CODE IS EXPERIMENTAL -- NOT FOR PRODUCTION USE
28 */
29
30 require_once './includes/bootstrap.inc';
31 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
32
33 $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";
34 $sql2 = "INSERT INTO {links_node} (lid,nid,link_title,weight,clicks,module) values (%d,%d,'%s',-5,%d,'links_weblink')";
35
36 print('<html><body>');
37 $count=0;
38 $result = db_query($sql);
39 while ($row = db_fetch_object($result)) {
40 $n_url = links_normalize_url($row->weblink);
41 if (empty($n_url)) {
42 print("<br>Node ".$row->nid." was not converted (empty URL)");
43 continue;
44 }
45 $lid = links_put_link($n_url);
46 if (! $lid) {
47 print("<br>Node ".$row->nid." was not converted (failed link insert)");
48 continue;
49 }
50 links_delete_links_for_node($row->nid);
51 $title = links_suggest_link_title($lid, $row->title);
52 $clicks = $row->click;
53 $result2 = db_query($sql2, $lid, $row->nid, $title, $clicks);
54 $count++;
55 }
56 print("<P>Processed $count weblink records. The script limits the number in one run to prevent timeouts. If no errors, rerun this script until the count is zero; it may take several iterations.");
57 print("<P>WARNING: Monitoring parameters are not yet supported and are currently ignored.");
58 print('</body></html>');
59 ?>

  ViewVC Help
Powered by ViewVC 1.1.2