Issue #2232391 by alexpott: Revert drupal 8 changes made to generate-d7-content.sh and generate-d6-content.sh.
parent
99385d755f
commit
005025d1d1
|
|
@ -131,7 +131,7 @@ for ($i = 0; $i < 24; $i++) {
|
||||||
else {
|
else {
|
||||||
$node->taxonomy = $node_terms;
|
$node->taxonomy = $node_terms;
|
||||||
}
|
}
|
||||||
$node->save();
|
node_save($node);
|
||||||
path_set_alias("node/$node->nid", "content/$node->created");
|
path_set_alias("node/$node->nid", "content/$node->created");
|
||||||
if ($node->revision) {
|
if ($node->revision) {
|
||||||
$user = user_load($uid + 3);
|
$user = user_load($uid + 3);
|
||||||
|
|
@ -140,7 +140,7 @@ for ($i = 0; $i < 24; $i++) {
|
||||||
$node->body = str_repeat("node revision body ($node->type) - $i", 100);
|
$node->body = str_repeat("node revision body ($node->type) - $i", 100);
|
||||||
$node->log = "added $i revision";
|
$node->log = "added $i revision";
|
||||||
$node->taxonomy = $node_terms;
|
$node->taxonomy = $node_terms;
|
||||||
$node->save();
|
node_save($node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -171,7 +171,7 @@ for ($i = 0; $i < 12; $i++) {
|
||||||
for ($c = 0; $c < $nbchoices; $c++) {
|
for ($c = 0; $c < $nbchoices; $c++) {
|
||||||
$node->choice[] = array('chtext' => "Choice $c for poll $i");
|
$node->choice[] = array('chtext' => "Choice $c for poll $i");
|
||||||
}
|
}
|
||||||
$node->save();
|
node_save($node);
|
||||||
path_set_alias("node/$node->nid", "content/poll/$i");
|
path_set_alias("node/$node->nid", "content/poll/$i");
|
||||||
path_set_alias("node/$node->nid/results", "content/poll/$i/results");
|
path_set_alias("node/$node->nid/results", "content/poll/$i/results");
|
||||||
|
|
||||||
|
|
@ -202,5 +202,5 @@ $node->revision = 0;
|
||||||
$node->promote = 0;
|
$node->promote = 0;
|
||||||
$node->created = 1263769200;
|
$node->created = 1263769200;
|
||||||
$node->log = "added $i node";
|
$node->log = "added $i node";
|
||||||
$node->save();
|
node_save($node);
|
||||||
path_set_alias("node/$node->nid", "content/1263769200");
|
path_set_alias("node/$node->nid", "content/1263769200");
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@
|
||||||
/**
|
/**
|
||||||
* Generate content for a Drupal 7 database to test the upgrade process.
|
* Generate content for a Drupal 7 database to test the upgrade process.
|
||||||
*
|
*
|
||||||
* Run this script at the root of an existing Drupal 6 installation.
|
* Run this script at the root of an existing Drupal 7 installation.
|
||||||
|
*
|
||||||
* Steps to use this generation script:
|
* Steps to use this generation script:
|
||||||
* - Install drupal 7.
|
* - Install drupal 7.
|
||||||
* - Run this script from your Drupal ROOT directory.
|
* - Run this script from your Drupal ROOT directory.
|
||||||
|
|
@ -30,6 +31,7 @@ include_once './includes/bootstrap.inc';
|
||||||
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
|
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
|
||||||
|
|
||||||
// Enable requested modules
|
// Enable requested modules
|
||||||
|
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
|
||||||
include_once './modules/system/system.admin.inc';
|
include_once './modules/system/system.admin.inc';
|
||||||
$form = system_modules();
|
$form = system_modules();
|
||||||
foreach ($modules_to_enable as $module) {
|
foreach ($modules_to_enable as $module) {
|
||||||
|
|
@ -44,13 +46,12 @@ drupal_cron_run();
|
||||||
|
|
||||||
// Create six users
|
// Create six users
|
||||||
$query = db_insert('users')->fields(array('uid', 'name', 'pass', 'mail', 'status', 'created', 'access'));
|
$query = db_insert('users')->fields(array('uid', 'name', 'pass', 'mail', 'status', 'created', 'access'));
|
||||||
$password_hasher = \Drupal::service('password');
|
|
||||||
for ($i = 0; $i < 6; $i++) {
|
for ($i = 0; $i < 6; $i++) {
|
||||||
$name = "test user $i";
|
$name = "test user $i";
|
||||||
$pass = md5("test PassW0rd $i !(.)");
|
$pass = md5("test PassW0rd $i !(.)");
|
||||||
$mail = "test$i@example.com";
|
$mail = "test$i@example.com";
|
||||||
$now = mktime(0, 0, 0, 1, $i + 1, 2010);
|
$now = mktime(0, 0, 0, 1, $i + 1, 2010);
|
||||||
$query->values(array(db_next_id(), $name, $password_hasher->hash($pass), $mail, 1, $now, $now));
|
$query->values(array(db_next_id(), $name, user_hash_password($pass), $mail, 1, $now, $now));
|
||||||
}
|
}
|
||||||
$query->execute();
|
$query->execute();
|
||||||
|
|
||||||
|
|
@ -66,17 +67,16 @@ $required = array(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1);
|
||||||
$voc_id = 0;
|
$voc_id = 0;
|
||||||
$term_id = 0;
|
$term_id = 0;
|
||||||
for ($i = 0; $i < 24; $i++) {
|
for ($i = 0; $i < 24; $i++) {
|
||||||
|
$vocabulary = new stdClass;
|
||||||
++$voc_id;
|
++$voc_id;
|
||||||
$vocabulary = entity_create('taxonomy_vocabulary', array(
|
$vocabulary->name = "vocabulary $voc_id (i=$i)";
|
||||||
'name' => "vocabulary $voc_id (i=$i)",
|
$vocabulary->machine_name = 'vocabulary_' . $voc_id . '_' . $i;
|
||||||
'machine_name' => 'vocabulary_' . $voc_id . '_' . $i,
|
$vocabulary->description = "description of ". $vocabulary->name;
|
||||||
'description' => "description of " . $vocabulary->name,
|
$vocabulary->multiple = $multiple[$i % 12];
|
||||||
'multiple' => $multiple[$i % 12],
|
$vocabulary->required = $required[$i % 12];
|
||||||
'required' => $required[$i % 12],
|
$vocabulary->relations = 1;
|
||||||
'relations' => 1,
|
$vocabulary->hierarchy = $hierarchy[$i % 12];
|
||||||
'hierarchy' => $hierarchy[$i % 12],
|
$vocabulary->weight = $i;
|
||||||
'weight' => $i,
|
|
||||||
));
|
|
||||||
taxonomy_vocabulary_save($vocabulary);
|
taxonomy_vocabulary_save($vocabulary);
|
||||||
$field = array(
|
$field = array(
|
||||||
'field_name' => 'taxonomy_'. $vocabulary->machine_name,
|
'field_name' => 'taxonomy_'. $vocabulary->machine_name,
|
||||||
|
|
@ -93,7 +93,7 @@ for ($i = 0; $i < 24; $i++) {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
entity_create('field_entity', $field)->save();
|
field_create_field($field);
|
||||||
$node_types = $i > 11 ? array('page') : array_keys(node_type_get_types());
|
$node_types = $i > 11 ? array('page') : array_keys(node_type_get_types());
|
||||||
foreach ($node_types as $bundle) {
|
foreach ($node_types as $bundle) {
|
||||||
$instance = array(
|
$instance = array(
|
||||||
|
|
@ -132,7 +132,7 @@ for ($i = 0; $i < 24; $i++) {
|
||||||
'settings' => array(),
|
'settings' => array(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
entity_create('field_instance', $instance)->save();
|
field_create_instance($instance);
|
||||||
}
|
}
|
||||||
$parents = array();
|
$parents = array();
|
||||||
// Vocabularies without hierarchy get one term, single parent vocabularies get
|
// Vocabularies without hierarchy get one term, single parent vocabularies get
|
||||||
|
|
@ -151,9 +151,9 @@ for ($i = 0; $i < 24; $i++) {
|
||||||
'weight' => $i * 3 + $j,
|
'weight' => $i * 3 + $j,
|
||||||
));
|
));
|
||||||
taxonomy_term_save($term);
|
taxonomy_term_save($term);
|
||||||
$terms[] = $term->id();
|
$terms[] = $term->tid;
|
||||||
$term_vocabs[$term->id()] = 'taxonomy_' . $vocabulary->machine_name;
|
$term_vocabs[$term->tid] = 'taxonomy_' . $vocabulary->machine_name;
|
||||||
$parents[] = $term->id();
|
$parents[] = $term->tid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$node_id = 0;
|
$node_id = 0;
|
||||||
|
|
@ -171,7 +171,7 @@ for ($i = 0; $i < 36; $i++) {
|
||||||
else if ($i < 24) {
|
else if ($i < 24) {
|
||||||
$node->type = 'story';
|
$node->type = 'story';
|
||||||
}
|
}
|
||||||
else if (\Drupal::moduleHandler()->moduleExists('blog')) {
|
else if (module_exists('blog')) {
|
||||||
$node->type = 'blog';
|
$node->type = 'blog';
|
||||||
}
|
}
|
||||||
$node->sticky = 0;
|
$node->sticky = 0;
|
||||||
|
|
@ -204,7 +204,7 @@ for ($i = 0; $i < 36; $i++) {
|
||||||
$node->{$field_name}[LANGUAGE_NONE][] = array('tid' => $tid);
|
$node->{$field_name}[LANGUAGE_NONE][] = array('tid' => $tid);
|
||||||
}
|
}
|
||||||
$node->path = array('alias' => "content/$node->created");
|
$node->path = array('alias' => "content/$node->created");
|
||||||
$node->save();
|
node_save($node);
|
||||||
if ($node->revision) {
|
if ($node->revision) {
|
||||||
$user = user_load($uid + 3);
|
$user = user_load($uid + 3);
|
||||||
++$revision_id;
|
++$revision_id;
|
||||||
|
|
@ -220,7 +220,7 @@ for ($i = 0; $i < 36; $i++) {
|
||||||
$field_name = $term_vocabs[$tid];
|
$field_name = $term_vocabs[$tid];
|
||||||
$node->{$field_name}[LANGUAGE_NONE][] = array('tid' => $tid);
|
$node->{$field_name}[LANGUAGE_NONE][] = array('tid' => $tid);
|
||||||
}
|
}
|
||||||
$node->save();
|
node_save($node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,12 +247,12 @@ for ($i = 0; $i < 12; $i++) {
|
||||||
for ($c = 0; $c < $nbchoices; $c++) {
|
for ($c = 0; $c < $nbchoices; $c++) {
|
||||||
$node->choice[] = array('chtext' => "Choice $c for poll $i", 'chvotes' => 0, 'weight' => 0);
|
$node->choice[] = array('chtext' => "Choice $c for poll $i", 'chvotes' => 0, 'weight' => 0);
|
||||||
}
|
}
|
||||||
$node->save();
|
node_save($node);
|
||||||
$path = array(
|
$path = array(
|
||||||
'alias' => "content/poll/$i/results",
|
'alias' => "content/poll/$i/results",
|
||||||
'source' => "node/$node->nid/results",
|
'source' => "node/$node->nid/results",
|
||||||
);
|
);
|
||||||
\Drupal::service('path.alias_storage')->save($path['source'], $path['alias']);
|
path_save($path);
|
||||||
|
|
||||||
// Add some votes
|
// Add some votes
|
||||||
$node = node_load($node->nid);
|
$node = node_load($node->nid);
|
||||||
|
|
@ -289,7 +289,7 @@ $node->promote = 0;
|
||||||
$node->created = 1263769200;
|
$node->created = 1263769200;
|
||||||
$node->log = "added a broken node";
|
$node->log = "added a broken node";
|
||||||
$node->path = array('alias' => "content/1263769200");
|
$node->path = array('alias' => "content/1263769200");
|
||||||
$node->save();
|
node_save($node);
|
||||||
db_update('node')
|
db_update('node')
|
||||||
->fields(array(
|
->fields(array(
|
||||||
'type' => $node_type,
|
'type' => $node_type,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue