db_backup.sql ) * 3) Make sure, that you do not have feedapi_node and feedapi_aggregator named content-types. * 4) Enable FeedAPI 1.1 module and FeedAPI Node module and one of the parsers (You can grab FeedAPI 1.1 package from here: http://www.drupal.org/module/feedapi). * 5) If you do not have PHP5, you HAVE TO install SimplePie. Otherwise, upgrade will fail. * 6) Run this php from the command line (if not possible, call it from the browser and set php timeout as big value as possible) * 7) Check out how it worked * 8) If good, uninstall Leech + other Leech-related modules. If not so good, restore the database dump -> nothing happened. * 9) Go to online mode * * +1 WARNING: you should not experiment this script on a production site. You'll lose minor leech settings. * */ header("Content-type: text/plain"); include('includes/bootstrap.inc'); require_once('includes/common.inc'); drupal_bootstrap(DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE); // Because of FeedAPI settings function, let's load the enabled modules module_load_all(); _leech2feedapi_output("Migration script from Leech to FeedAPI has started."); _leech2feedapi_output("Transform leech-enabled content-types to FeedAPI content-types"); $result = db_query("SELECT substring(name, 11) as name FROM {variable} where name LIKE 'leech_for_%' AND value='i:1;'"); // The FeedAPI Node content-type will be copied $target = variable_get('feedapi_settings_feedapi_node', FALSE); while ($row = db_fetch_object($result)) { variable_set('feedapi_settings_'. $row->name, $target); db_query("DELETE FROM {variable} WHERE name LIKE 'leech_news_%_%s' OR (name='leech_for_%s')", $row->name, $row->name); } // Then the variable-modification is effective immediately cache_clear_all(); variable_init(); _leech2feedapi_output("Reading feeds and moving them to FeedAPI"); $result = db_query("SELECT l.nid, l.url, l.checked, f.link, f.items_delete, f.items_promote FROM {leech} l NATURAL JOIN {leech_news_feed} f"); // Set meaningful defaults $processors = 'a:1:{i:0;s:12:"feedapi_node";}'; // Decide between parsers $commonsynd = db_result(db_query("SELECT status FROM {system} WHERE name='parser_common_syndication'")); if ((!version_compare(5, PHP_VERSION, '<=') || !function_exists('simplexml_load_file')) || $commonsynd == 0) { _leech2feedapi_output("Parser in use is simplepie\n"); $parsers = 'a:1:{i:0;s:16:"parser_simplepie";}'; } else { _leech2feedapi_output("Parser in use is parser_common_syndication\n"); $parsers = 'a:1:{i:0;s:25:"parser_common_syndication";}'; } while ($row = db_fetch_object($result)) { db_query("INSERT INTO {feedapi} ( nid, url, link, feed_type, processors, parsers, checked, settings) VALUES (%d, '%s', '%s', '%s', '%s', '%s', %d, '%s')", $row->nid, $row->url, $row->link, "XML feed", $processors, $parsers, $row->checked, serialize(array()) ); // FeedAPI 1.1 function renamed from _feedapi_get_settings to feedapi_get_settings $settings = feedapi_get_settings(array('node_type' => 'feedapi_node')); $settings['items_delete'] = $row->items_delete; $settings['processors']['feedapi_node']['promote'] = $row->items_promote; $feed_items_content_type = db_result(db_query("SELECT n.type FROM leech_news_item AS l NATURAL JOIN node AS n WHERE fid = %d LIMIT 1", $row->nid)); if (is_string($feed_items_content_type) && !empty($feed_items_content_type)) { $settings['processors']['feedapi_node']['content_type'] = $feed_items_content_type; } _feedapi_store_settings(array('nid' => $row->nid), $settings); } // Use the node's created field to set the timestamp on the feedapi_node_item _leech2feedapi_output("Reading feed items and moving them to FeedAPI"); $result = db_query("SELECT leech_news_item.nid, fid, link, guid, created FROM {leech_news_item} JOIN {node} ON ({leech_news_item}.nid={node}.nid)"); while ($row = db_fetch_object($result)) { db_query("INSERT INTO {feedapi_node_item} (nid, url, timestamp, arrived, guid) VALUES (%d, '%s', %d, %d, '%s')", $row->nid, $row->link, $row->created, $row->created, $row->guid); } // Disable leech modules db_query("UPDATE {system} SET status=0 WHERE name='leech' OR name='node_template' OR name='leech_feed_taxonomy' OR name='leech_views'"); _leech2feedapi_output("NOTE: Be sure to confirm that all leech modules have been disabled."); _leech2feedapi_output("Migration script has successfully ended."); function _leech2feedapi_output($msg) { print $msg. "\n\r"; flush(); }