db_backup.sql ) * 3) Make sure, that you do not have feedapi_node and feedapi_aggregator named content-types. * 4) Enable FeedAPI 1.0 module and FeedAPI Node module and one of the parsers (You can grab FeedAPI 1.0 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'); 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(); $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"); _leech2feedapi_output("Reading feeds and move to FeedAPI"); // 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) { $parsers = 'a:1:{i:0;s:16:"parser_simplepie";}'; } else { $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()) ); $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); } $result = db_query("SELECT nid, fid, link, guid FROM {leech_news_item}"); _leech2feedapi_output("Reading feed items and move to FeedAPI"); while ($row = db_fetch_object($result)) { $fiid = db_next_id('{feedapi_node_item}_fiid'); db_query("INSERT INTO {feedapi_node_item} (fiid, feed_nid, nid, url, timestamp, arrived, guid) VALUES (%d, %d, %d, '%s', %d, %d, '%s')", $fiid, $row->fid, $row->nid, $row->link, time(), time(), $row->guid); } // Disable leech modules db_query("UPDATE {system} SET status=0 WHERE name='leech' OR name='node_template' OR name='leech_feed_taxonomy'"); _leech2feedapi_output("Migration script has successfully ended."); function _leech2feedapi_output($msg) { print $msg. "\n\r"; flush(); }