Issue #2930101 by maxocub, heddn, alexpott, phenaproxima, catch, masipila: i18n / statistics - node counter not updated for translations
parent
d47cfa0efd
commit
d45dc9d26a
|
|
@ -43634,6 +43634,30 @@ $connection->insert('node_counter')
|
||||||
'daycount' => '1',
|
'daycount' => '1',
|
||||||
'timestamp' => '1478755314',
|
'timestamp' => '1478755314',
|
||||||
))
|
))
|
||||||
|
->values(array(
|
||||||
|
'nid' => '10',
|
||||||
|
'totalcount' => '5',
|
||||||
|
'daycount' => '1',
|
||||||
|
'timestamp' => '1521137459',
|
||||||
|
))
|
||||||
|
->values(array(
|
||||||
|
'nid' => '11',
|
||||||
|
'totalcount' => '3',
|
||||||
|
'daycount' => '1',
|
||||||
|
'timestamp' => '1521137463',
|
||||||
|
))
|
||||||
|
->values(array(
|
||||||
|
'nid' => '12',
|
||||||
|
'totalcount' => '3',
|
||||||
|
'daycount' => '0',
|
||||||
|
'timestamp' => '1521137469',
|
||||||
|
))
|
||||||
|
->values(array(
|
||||||
|
'nid' => '13',
|
||||||
|
'totalcount' => '2',
|
||||||
|
'daycount' => '1',
|
||||||
|
'timestamp' => '1521137470',
|
||||||
|
))
|
||||||
->values(array(
|
->values(array(
|
||||||
'nid' => '14',
|
'nid' => '14',
|
||||||
'totalcount' => '1',
|
'totalcount' => '1',
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
id: statistics_node_translation_counter
|
||||||
|
label: Node translation counter
|
||||||
|
migration_tags:
|
||||||
|
- Drupal 6
|
||||||
|
- Drupal 7
|
||||||
|
- Content
|
||||||
|
source:
|
||||||
|
plugin: node_counter
|
||||||
|
process:
|
||||||
|
nid:
|
||||||
|
-
|
||||||
|
plugin: migration_lookup
|
||||||
|
migration:
|
||||||
|
- d6_node_translation
|
||||||
|
- d7_node_translation
|
||||||
|
source: nid
|
||||||
|
-
|
||||||
|
plugin: skip_on_empty
|
||||||
|
method: row
|
||||||
|
-
|
||||||
|
plugin: extract
|
||||||
|
index:
|
||||||
|
- 0
|
||||||
|
totalcount: totalcount
|
||||||
|
daycount: daycount
|
||||||
|
timestamp: timestamp
|
||||||
|
destination:
|
||||||
|
plugin: node_counter
|
||||||
|
migration_dependencies:
|
||||||
|
required:
|
||||||
|
- statistics_node_counter
|
||||||
|
optional:
|
||||||
|
- d6_node_translation
|
||||||
|
- d7_node_translation
|
||||||
|
|
@ -81,15 +81,24 @@ class NodeCounter extends DestinationBase implements ContainerFactoryPluginInter
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function import(Row $row, array $old_destination_id_values = []) {
|
public function import(Row $row, array $old_destination_id_values = []) {
|
||||||
|
$nid = $row->getDestinationProperty('nid');
|
||||||
|
$daycount = $row->getDestinationProperty('daycount');
|
||||||
|
$totalcount = $row->getDestinationProperty('totalcount');
|
||||||
|
$timestamp = $row->getDestinationProperty('timestamp');
|
||||||
|
|
||||||
$this->connection
|
$this->connection
|
||||||
->insert('node_counter')
|
->merge('node_counter')
|
||||||
|
->key('nid', $nid)
|
||||||
->fields([
|
->fields([
|
||||||
'nid' => $row->getDestinationProperty('nid'),
|
'daycount' => $daycount,
|
||||||
'daycount' => $row->getDestinationProperty('daycount'),
|
'totalcount' => $totalcount,
|
||||||
'totalcount' => $row->getDestinationProperty('totalcount'),
|
'timestamp' => $timestamp,
|
||||||
'timestamp' => $row->getDestinationProperty('timestamp'),
|
|
||||||
])
|
])
|
||||||
|
->expression('daycount', 'daycount + :daycount', [':daycount' => $daycount])
|
||||||
|
->expression('totalcount', 'totalcount + :totalcount', [':totalcount' => $totalcount])
|
||||||
|
->expression('timestamp', 'CASE WHEN timestamp > :timestamp THEN timestamp ELSE :timestamp END', [':timestamp' => $timestamp])
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
return [$row->getDestinationProperty('nid')];
|
return [$row->getDestinationProperty('nid')];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ class MigrateNodeCounterTest extends MigrateDrupal6TestBase {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static $modules = [
|
public static $modules = [
|
||||||
|
'content_translation',
|
||||||
|
'language',
|
||||||
'menu_ui',
|
'menu_ui',
|
||||||
'node',
|
'node',
|
||||||
'statistics',
|
'statistics',
|
||||||
|
|
@ -29,16 +31,20 @@ class MigrateNodeCounterTest extends MigrateDrupal6TestBase {
|
||||||
|
|
||||||
$this->installEntitySchema('node');
|
$this->installEntitySchema('node');
|
||||||
$this->installConfig('node');
|
$this->installConfig('node');
|
||||||
|
$this->installSchema('node', ['node_access']);
|
||||||
$this->installSchema('statistics', ['node_counter']);
|
$this->installSchema('statistics', ['node_counter']);
|
||||||
|
|
||||||
$this->executeMigrations([
|
$this->executeMigrations([
|
||||||
|
'language',
|
||||||
'd6_filter_format',
|
'd6_filter_format',
|
||||||
'd6_user_role',
|
'd6_user_role',
|
||||||
'd6_node_settings',
|
'd6_node_settings',
|
||||||
'd6_user',
|
'd6_user',
|
||||||
'd6_node_type',
|
'd6_node_type',
|
||||||
|
'd6_language_content_settings',
|
||||||
'd6_node',
|
'd6_node',
|
||||||
'statistics_node_counter'
|
'd6_node_translation',
|
||||||
|
'statistics_node_counter',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,6 +57,13 @@ class MigrateNodeCounterTest extends MigrateDrupal6TestBase {
|
||||||
$this->assertNodeCounter(3, 1, 0, 1471428153);
|
$this->assertNodeCounter(3, 1, 0, 1471428153);
|
||||||
$this->assertNodeCounter(4, 1, 1, 1478755275);
|
$this->assertNodeCounter(4, 1, 1, 1478755275);
|
||||||
$this->assertNodeCounter(5, 1, 1, 1478755314);
|
$this->assertNodeCounter(5, 1, 1, 1478755314);
|
||||||
|
$this->assertNodeCounter(10, 5, 1, 1521137459);
|
||||||
|
$this->assertNodeCounter(12, 3, 0, 1521137469);
|
||||||
|
|
||||||
|
// Tests that translated node counts include all translation counts.
|
||||||
|
$this->executeMigration('statistics_node_translation_counter');
|
||||||
|
$this->assertNodeCounter(10, 8, 2, 1521137463);
|
||||||
|
$this->assertNodeCounter(12, 5, 1, 1521137470);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ class MigrateNodeCounterTest extends MigrateDrupal7TestBase {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public static $modules = [
|
public static $modules = [
|
||||||
|
'content_translation',
|
||||||
|
'language',
|
||||||
'menu_ui',
|
'menu_ui',
|
||||||
'node',
|
'node',
|
||||||
'statistics',
|
'statistics',
|
||||||
|
|
@ -29,14 +31,18 @@ class MigrateNodeCounterTest extends MigrateDrupal7TestBase {
|
||||||
|
|
||||||
$this->installEntitySchema('node');
|
$this->installEntitySchema('node');
|
||||||
$this->installConfig('node');
|
$this->installConfig('node');
|
||||||
|
$this->installSchema('node', ['node_access']);
|
||||||
$this->installSchema('statistics', ['node_counter']);
|
$this->installSchema('statistics', ['node_counter']);
|
||||||
|
|
||||||
$this->executeMigrations([
|
$this->executeMigrations([
|
||||||
|
'language',
|
||||||
'd7_user_role',
|
'd7_user_role',
|
||||||
'd7_user',
|
'd7_user',
|
||||||
'd7_node_type',
|
'd7_node_type',
|
||||||
|
'd7_language_content_settings',
|
||||||
'd7_node',
|
'd7_node',
|
||||||
'statistics_node_counter'
|
'd7_node_translation',
|
||||||
|
'statistics_node_counter',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -47,6 +53,11 @@ class MigrateNodeCounterTest extends MigrateDrupal7TestBase {
|
||||||
$this->assertNodeCounter(1, 2, 0, 1421727536);
|
$this->assertNodeCounter(1, 2, 0, 1421727536);
|
||||||
$this->assertNodeCounter(2, 1, 0, 1471428059);
|
$this->assertNodeCounter(2, 1, 0, 1471428059);
|
||||||
$this->assertNodeCounter(4, 1, 1, 1478755275);
|
$this->assertNodeCounter(4, 1, 1, 1478755275);
|
||||||
|
|
||||||
|
// Tests that translated node counts include all translation counts.
|
||||||
|
$this->executeMigration('statistics_node_translation_counter');
|
||||||
|
$this->assertNodeCounter(2, 2, 0, 1471428153);
|
||||||
|
$this->assertNodeCounter(4, 2, 2, 1478755314);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue