machine name rather than class name.
MigrationBase::getInstance now takes a machine name rather than a class name.
Migration class names are no longer required to end in 'Migration'.
-
+- #992898 - Pass options to source and destination constructors as arrays.
Add logging of fetch queries and dqp() function to translate DBTNG query object into full SQL.
Inherit default settings for promote, sticky, status, status from content type
configuration. Already done in D7.
}
/**
+ * Return an options array for comment destinations.
+ *
+ * @param string $language
+ * Default language for comments created via this destination class.
+ * @param string $text_format
+ * Default text format for comments created via this destination class.
+ */
+ static public function options($language, $text_format) {
+ return compact('language', 'text_format');
+ }
+
+ /**
* Basic initialization
*
* @param string $bundle
* A.k.a. the content type (page, article, etc.) of the ... comment?.
- * @param string $language
- * Language of the node content.
- * @param string $text_format
- * Default text format for fields on this comment. Can be overridden.
+ * @param array $options
+ * Options applied to comments.
*/
- public function __construct($bundle, $language = NULL, $text_format = NULL) {
- parent::__construct('comment', $bundle, $language, $text_format);
+ public function __construct($bundle, array $options = array()) {
+ parent::__construct('comment', $bundle, $options);
}
/**
*
* @param array $key_schema
*/
- public function __construct($entity_type, $bundle,
- $language = NULL, $text_format = NULL) {
+ public function __construct($entity_type, $bundle, array $options = array()) {
parent::__construct();
$this->entityType = $entity_type;
$this->bundle = $bundle;
- $this->language = isset($language) ? $language : LANGUAGE_NONE;
- $this->textFormat = isset($text_format) ? $text_format : filter_fallback_format();
+ $this->language = isset($options['language']) ? $options['language'] : LANGUAGE_NONE;
+ $this->textFormat = isset($options['text_format']) ? $options['text_format'] : filter_fallback_format();
}
public function __toString() {
}
/**
+ * Return an options array for node destinations.
+ *
+ * @param string $language
+ * Default language for nodes created via this destination class.
+ * @param string $text_format
+ * Default text format for nodes created via this destination class.
+ */
+ static public function options($language, $text_format) {
+ return compact('language', 'text_format');
+ }
+
+ /**
* Basic initialization
*
* @param string $bundle
* A.k.a. the content type (page, article, etc.) of the node.
- * @param string $language
- * Default language for nodes created via this destination class.
+ * @param array $options
+ * Options applied to nodes.
*/
- public function __construct($bundle, $language = NULL, $text_format = NULL) {
- parent::__construct('node', $bundle, $language, $text_format);
+ public function __construct($bundle, array $options = array()) {
+ parent::__construct('node', $bundle, $options);
}
/**
$type_info = node_get_types('type', $node->type);
if (empty($node->nid)) {
// Avoids notice in forum module and maybe more - http://drupal.org/node/839770 is similar.
- $node->nid = NULL;
+ $node->nid = NULL;
}
// Save changed timestamp and set it later, node_save sets it unconditionally
if (isset($node->created)) {
$node->created = MigrationBase::timestamp($node->created);
}
-
+
// Generate teaser from Body if teaser not specified and Body is in use.
if ($type_info->has_body && empty($node->teaser) && !empty($node->body)) {
$node->teaser = node_teaser($node->body);
}
-
+
// Set defaults as per content type settings. Can't call node_object_prepare()
// since that clobbers existing values.
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
migrate_instrument_stop('node_save');
if (isset($node->nid)) {
-
+
// Unfortunately, http://drupal.org/node/722688 was not accepted, so fix
// the changed timestamp
if (isset($changed)) {
->execute();
$node->changed = $changed;
}
-
+
// Potentially fix uid and timestamp in node_revisions.
$query = db_update('node_revisions')
->condition('vid', $node->vid);
$query->execute();
}
}
-
+
$this->complete($node, $row);
// Clear the node cache periodically
}
/**
+ * Return an options array for term destinations.
+ *
+ * @param string $language
+ * Default language for terms created via this destination class.
+ * @param string $text_format
+ * Default text format for terms created via this destination class.
+ */
+ static public function options($language, $text_format) {
+ return compact('language', 'text_format');
+ }
+
+ /**
* Basic initialization
+ *
+ * @param array $options
+ * Options applied to terms.
*/
- public function __construct($bundle, $language = NULL, $text_format = NULL) {
- parent::__construct('taxonomy_term', $bundle, $language, $text_format);
+ public function __construct($bundle, array $options = array()) {
+ parent::__construct('taxonomy_term', $bundle, $options);
}
/**
}
/**
+ * Return an options array for user destinations.
+ *
+ * @param string $language
+ * Default language for usrs created via this destination class.
+ * @param string $text_format
+ * Default text format for users created via this destination class.
+ */
+ static public function options($language, $text_format) {
+ return compact('language', 'text_format');
+ }
+
+ /**
* Basic initialization
+ *
+ * @param array $options
+ * Options applied to comments.
*/
- public function __construct($language = NULL, $text_format = NULL) {
- parent::__construct('user', 'user', $language, $text_format);
+ public function __construct(array $options = array()) {
+ parent::__construct('user', 'user', $options);
}
/**
protected $mapJoinable = FALSE;
/**
+ * Return an options array for MS SQL sourcews.
+ *
+ * @param int $batch_size
+ * Number of rows to pull at once (defaults to 500).
+ */
+ static public function options($batch_size) {
+ return compact('batch_size');
+ }
+
+ /**
* Simple initialization.
*/
public function __construct(array $configuration, $query, $count_query,
- array $fields, $batch_size = 500) {
+ array $fields, array $options = array()) {
parent::__construct();
$this->query = $query;
$this->countQuery = $count_query;
$this->configuration = $configuration;
$this->fields = $fields;
- $this->batchSize = $batch_size;
+ $this->batchSize = isset($options['batch_size']) ? $options['batch_size'] : 500;
}
/**
protected $usingHighwater = FALSE;
/**
+ * Return an options array for PDO sources.
+ *
+ * @param boolean $map_joinable
+ * Indicates whether the map table can be joined directly to the source query.
+ */
+ static public function options($map_joinable) {
+ return compact('map_joinable');
+ }
+
+ /**
* Simple initialization.
*
* @param SelectQuery $query
* @param SelectQuery $count_query
* Optional - an explicit count query, primarily used when counting the
* primary query is slow.
- * @param boolean $map_joinable
- * Indicates whether the map table can be joined directly to the source query.
+ * @param boolean $options
+ * Options applied to this source.
*/
- public function __construct(SelectQuery $query,
- array $fields = array(), SelectQuery $count_query = NULL, $map_joinable = NULL) {
+ public function __construct(SelectQuery $query, array $fields = array(),
+ SelectQuery $count_query = NULL, array $options = array()) {
parent::__construct();
$this->originalQuery = $query;
$this->query = clone $query;
$this->countQuery = $count_query;
}
- if (!is_null($map_joinable)) {
- $this->mapJoinable = $map_joinable;
+ if (isset($options['map_joinable'])) {
+ $this->mapJoinable = $options['map_joinable'];
}
else {
// TODO: We want to automatically determine if the map table can be joined