diff --git a/scripts/dump-database-d6.sh b/scripts/dump-database-d6.sh index 41146b0..0cce580 100644 --- a/scripts/dump-database-d6.sh +++ b/scripts/dump-database-d6.sh @@ -2,13 +2,13 @@ $data) { // Prepare the export of values. $result = db_query('SELECT * FROM {'. $table .'}'); $insert = ''; - while ($record = db_fetch_array($result)) { + foreach ($result as $record) { // users.uid is a serial and inserting 0 into a serial can break MySQL. // So record uid + 1 instead of uid for every uid and once all records // are in place, fix them up. if ($table == 'users') { - $record['uid']++; + $record->uid++; } $insert .= '->values('. drupal_var_export($record) .")\n"; } diff --git a/scripts/generate-d6-content.sh b/scripts/generate-d6-content.sh index 5079c23..fef2820 100644 --- a/scripts/generate-d6-content.sh +++ b/scripts/generate-d6-content.sh @@ -2,11 +2,11 @@ $uid, ':name' => $name, ':pass' => $pass, ':mail' => $mail, ':status' => 1, ':created' => $now, ':access' => $now)); } // Create vocabularies and terms - +include_once('./modules/taxonomy/taxonomy.module'); $terms = array(); // All possible combinations of these vocabulary properties. @@ -63,34 +66,35 @@ $required = array(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1); $voc_id = 0; $term_id = 0; for ($i = 0; $i < 24; $i++) { - $vocabulary = array(); + $vocabulary = new stdClass(); ++$voc_id; - $vocabulary['name'] = "vocabulary $voc_id (i=$i)"; - $vocabulary['description'] = "description of ". $vocabulary['name']; - $vocabulary['nodes'] = $i > 11 ? array('page' => TRUE) : array(); - $vocabulary['multiple'] = $multiple[$i % 12]; - $vocabulary['required'] = $required[$i % 12]; - $vocabulary['relations'] = 1; - $vocabulary['hierarchy'] = $hierarchy[$i % 12]; - $vocabulary['weight'] = $i; - taxonomy_save_vocabulary($vocabulary); + $vocabulary->name = "vocabulary $voc_id (i=$i)"; + $vocabulary->machine_name = "vocab_" . $i; + $vocabulary->description = "description of ". $vocabulary->name; + $vocabulary->nodes = $i > 11 ? array('page' => TRUE) : array(); + $vocabulary->multiple = $multiple[$i % 12]; + $vocabulary->required = $required[$i % 12]; + $vocabulary->relations = 1; + $vocabulary->hierarchy = $hierarchy[$i % 12]; + $vocabulary->weight = $i; + taxonomy_vocabulary_save($vocabulary); $parents = array(); // Vocabularies without hierarcy get one term, single parent vocabularies get // one parent and one child term. Multiple parent vocabularies get three // terms: t0, t1, t2 where t0 is a parent of both t1 and t2. - for ($j = 0; $j < $vocabulary['hierarchy'] + 1; $j++) { - $term = array(); - $term['vid'] = $vocabulary['vid']; + for ($j = 0; $j < $vocabulary->hierarchy + 1; $j++) { + $term = new stdClass(); + $term->vid = $vocabulary->vid; // For multiple parent vocabularies, omit the t0-t1 relation, otherwise // every parent in the vocabulary is a parent. - $term['parent'] = $vocabulary['hierarchy'] == 2 && i == 1 ? array() : $parents; + $term->parent = $vocabulary->hierarchy == 2 && i == 1 ? array() : $parents; ++$term_id; - $term['name'] = "term $term_id of vocabulary $voc_id (j=$j)"; - $term['description'] = 'description of ' . $term['name']; - $term['weight'] = $i * 3 + $j; - taxonomy_save_term($term); - $terms[] = $term['tid']; - $parents[] = $term['tid']; + $term->name = "term $term_id of vocabulary $voc_id (j=$j)"; + $term->description = 'description of ' . $term->name; + $term->weight = $i * 3 + $j; + taxonomy_term_save($term); + $terms[] = $term->tid; + $parents[] = $term->tid; } } @@ -107,7 +111,7 @@ for ($i = 0; $i < 24; $i++) { ++$node_id; ++$revision_id; $node->title = "node title $node_id rev $revision_id (i=$i)"; - $type = node_get_types('type', $node->type); + $type = node_type_get_type($node->type); if ($type->has_body) { $node->body = str_repeat("node body ($node->type) - $i", 100); $node->teaser = node_teaser($node->body); @@ -132,7 +136,8 @@ for ($i = 0; $i < 24; $i++) { $node->taxonomy = $node_terms; } node_save($node); - path_set_alias("node/$node->nid", "content/$node->created"); + $node_path = array('source' => "node/$node->nid", 'alias' => "content/$node->created"); + path_save($node_path); if ($node->revision) { $user = user_load($uid + 3); ++$revision_id; @@ -153,7 +158,7 @@ for ($i = 0; $i < 12; $i++) { $node->type = 'poll'; $node->sticky = 0; $node->title = "poll title $i"; - $type = node_get_types('type', $node->type); + $type = node_type_get_type($node->type); if ($type->has_body) { $node->body = str_repeat("node body ($node->type) - $i", 100); $node->teaser = node_teaser($node->body); @@ -172,8 +177,10 @@ for ($i = 0; $i < 12; $i++) { $node->choice[] = array('chtext' => "Choice $c for poll $i"); } node_save($node); - path_set_alias("node/$node->nid", "content/poll/$i"); - path_set_alias("node/$node->nid/results", "content/poll/$i/results"); + $poll_path = array('source' => "node/$node->nid", 'alias' => "content/poll/$i"); + path_save($poll_path); + $results_path = array('source' => "node/$node->nid/results", 'alias' => "content/poll/$i/results"); + path_save($results_path); // Add some votes for ($v = 0; $v < ($i % 4) + 5; $v++) { @@ -181,7 +188,7 @@ for ($i = 0; $i < 12; $i++) { $form_state = array(); $form_state['values']['choice'] = $c; $form_state['values']['op'] = t('Vote'); - drupal_execute('poll_view_voting', $form_state, $node); + drupal_form_submit('poll_view_voting', $form_state, $node); } } @@ -193,7 +200,7 @@ $node->type = 'broken'; $node->sticky = 0; $node->title = "node title 24"; $node->body = str_repeat("node body ($node->type) - 37", 100); -$node->teaser = node_teaser($node->body); +$node->teaser = "node body ($node->type)"; $node->filter = variable_get('filter_default_format', 1); $node->format = FILTER_FORMAT_DEFAULT; $node->status = 1; @@ -203,4 +210,5 @@ $node->promote = 0; $node->created = 1263769200; $node->log = "added $i node"; node_save($node); -path_set_alias("node/$node->nid", "content/1263769200"); +$content_path = array('source' => "node/$node->nid", 'alias' => "content/1263769200"); +path_save($content_path);