Problem/Motivation

We need an upgrade path from D7 for the core Tracker module.

Remaining Tasks

Write migrations, with tests, to cover the following:

  • Any variables maintained by Tracker need to be moved into configuration
  • The tracker_node and tracker_user tables may need to be migrated
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quietone’s picture

Assigned: Unassigned » quietone
quietone’s picture

Just need to figure out how to test this properly. How do I retrieve the data from the tracker tables?

quietone’s picture

Here's a working patch that still needs tests.

quietone’s picture

Assigned: quietone » Unassigned
phenaproxima’s picture

Status: Active » Needs work

Except for the lack of asserts, looks pretty good to me. Some minor things, though:

  1. +++ b/core/modules/migrate_drupal/src/Tests/Table/d7/TrackerUser.php
    @@ -63,7 +63,7 @@ public function load() {
    -      'uid' => '1',
    +      'uid' => '2',
    

    The dump file hash doesn't appear to have been updated; this needs to be regenerated with migrate-db.sh.

  2. +++ b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerNode.php
    @@ -0,0 +1,50 @@
    + * @MigrateSource(
    + *   id = "tracker_node",
    + *   source_provider = "tracker"
    + * )
    + *
    

    Unnecessary extra line after the annotation.

  3. +++ b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerNode.php
    @@ -0,0 +1,50 @@
    +    $query = $this->select('tracker_node', 'tn')
    +      ->fields('tn', array('nid', 'published', 'changed'));
    +    return $query;
    

    Can be all one line: return $this->select('tracker_node' ,'tn')->fields('tn'). We don't generally need to cherry-pick the fields we're returning.

  4. +++ b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerUser.php
    @@ -0,0 +1,52 @@
    + * Drupal 7 tracker user source from database.
    + *
    + * @MigrateSource(
    + *   id = "tracker_user",
    + *   source_provider = "tracker"
    + * )
    + *
    + */
    +
    

    There are extra lines after the annotation and after the doc block.

  5. +++ b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerUser.php
    @@ -0,0 +1,52 @@
    +class TrackerUser extends DrupalSqlBase {
    +  /**
    +   * {@inheritdoc}
    +   */
    

    Nit: Needs an extra line before the query() doc comment.

  6. +++ b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerUser.php
    @@ -0,0 +1,52 @@
    +  public function query() {
    +    $query = $this->select('tracker_user', 'tu')
    +      ->fields('tu', array('nid', 'uid', 'published', 'changed'));
    +    return $query;
    

    This can be streamlined as well.

  7. +++ b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerUser.php
    @@ -0,0 +1,52 @@
    +    return [
    +      'nid' => $this->t('The {user}.nid this record tracks.'),
    +      'uid' => $this->t('The {users}.uid of the node author or commenter.'),
    +      'publisehd' => $this->t('Boolean indicating whether the user is published.'),
    +      'changed' => $this->t('The Unix timestamp when the user was most recently saved or commented on.'),
    +    ];
    

    We're not generally supposed to mix array() and [] syntaxes in the same file.

  8. +++ b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerNodeTest.php
    @@ -0,0 +1,54 @@
    + * Tests migration of Tracker settings to configuration.
    

    This doesn't migrate configuration.

  9. +++ b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerNodeTest.php
    @@ -0,0 +1,54 @@
    +  static $modules = array(
    

    Should be public static.

  10. +++ b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerNodeTest.php
    @@ -0,0 +1,54 @@
    +    $this->executeMigration('d7_user_role');
    +    $this->executeMigration('d7_user');
    +    $this->executeMigration('d7_node_type');
    +    $this->executeMigration('d7_node__test_content_type');
    +    $this->executeMigration('d7_tracker_node');
    

    It might be prudent to add optional dependencies on d7_node:* and d7_user to the d7_tracker_node and d7_tracker_user migrations, respectively.

  11. +++ b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerUserTest.php
    @@ -0,0 +1,54 @@
    + * Tests migration of Tracker settings to configuration.
    

    No it doesn't :)

  12. +++ b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerUserTest.php
    @@ -0,0 +1,54 @@
    +  static $modules = array(
    

    public static

  13. +++ b/core/modules/tracker/tests/src/Unit/Plugin/migrate/source/d7/TrackerNodeTest.php
    @@ -0,0 +1,49 @@
    + * @coversDefaultClass \Drupal\tracker\Plugin\migrate\source\d7\TrackerNode
    

    We don't actually need this, since it's not truly a unit test that tests actual methods of TrackerNode.

  14. +++ b/core/modules/tracker/tests/src/Unit/Plugin/migrate/source/d7/TrackerNodeTest.php
    @@ -0,0 +1,49 @@
    +    $this->databaseContents['tracker_node'][] = [
    +      'nid' => '2',
    +      'published' => '1',
    +      'changed' => '1421727536',
    +    ];
    

    $this->databaseContents['tracker_node'] = $this->expectedResults is preferable to repeating the rows.

  15. +++ b/core/modules/tracker/tests/src/Unit/Plugin/migrate/source/d7/TrackerUserTest.php
    @@ -0,0 +1,51 @@
    + * @coversDefaultClass \Drupal\tracker\Plugin\migrate\source\d7\TrackerUser
    

    Let's ditch this, since it doesn't really apply to these source plugin tests.

  16. +++ b/core/modules/tracker/tests/src/Unit/Plugin/migrate/source/d7/TrackerUserTest.php
    @@ -0,0 +1,51 @@
    +    $this->databaseContents['tracker_user'][] = [
    +      'nid' => '1',
    +      'uid' => '2',
    +      'published' => '1',
    +      'changed' => '1421727536',
    +    ];
    

    $this->databaseContents['tracker_user'] = $this->expectedResults

quietone’s picture

I think I've addressed everything in #5.

How does one get the tracker data to test it?

rajeevk’s picture

Status: Needs work » Needs review

The last submitted patch, 3: 2500535-3.patch, failed testing.

The last submitted patch, 3: 2500535-3.patch, failed testing.

phenaproxima’s picture

Status: Needs review » Needs work

This is a good start, but @quietone is right -- how can we get some tracker data for testing? I'm thinking we should simply enable Tracker in the D7 database and use the site a bit like normal -- publishing nodes, browsing as different users, etc. -- that should collect at least a little data.

  1. +++ b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerNode.php
    @@ -0,0 +1,47 @@
    +      'publisehd' => $this->t('Boolean indicating whether the node is published.'),
    

    "publisehd"? Oops :)

  2. +++ b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerUser.php
    @@ -0,0 +1,49 @@
    +      'publisehd' => $this->t('Boolean indicating whether the user is published.'),
    

    Is this necessary? I don't think users are considered published...?

  3. +++ b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerNodeTest.php
    @@ -0,0 +1,54 @@
    +  public static $modules = [
    

    Needs @inheritdoc.

  4. +++ b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerNodeTest.php
    @@ -0,0 +1,54 @@
    +    $this->executeMigration('d7_user_role');
    +    $this->executeMigration('d7_user');
    +    $this->executeMigration('d7_node_type');
    +    $this->executeMigration('d7_node__test_content_type');
    +    $this->executeMigration('d7_tracker_node');
    

    Better to use executeMigrations() here, since that'll put things in dependency order. $this->executeMigrations(['d7_user_role', 'd7_user', ...])

  5. +++ b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerUserTest.php
    @@ -0,0 +1,55 @@
    +  public static $modules = [
    

    Also needs @inheritdoc.

  6. +++ b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerUserTest.php
    @@ -0,0 +1,55 @@
    +    $this->executeMigration('d7_user_role');
    +    $this->executeMigration('d7_user');
    +    $this->executeMigration('d7_node_type');
    +    $this->executeMigration('d7_node__test_content_type');
    +    $this->executeMigration('d7_tracker_node');
    +        $this->executeMigration('d7_tracker_user');
    

    Should also use executeMigrations().

quietone’s picture

Status: Needs work » Needs review
FileSize
9.69 KB
4.21 KB

Fixed all the issues in #10.

quietone’s picture

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests
  1. +++ b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerNode.php
    @@ -0,0 +1,47 @@
    +<?php
    +/**
    + * @file
    + * Contains \Drupal\tracker\Plugin\migrate\source\d7\TrackerNode.
    + */
    

    There should be an extra line between <?php and the file comment, but that can be fixed on commit.

  2. +++ b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerUser.php
    @@ -0,0 +1,49 @@
    +<?php
    +/**
    + * @file
    + * Contains \Drupal\tracker\Plugin\migrate\source\d7\TrackerUser.
    + */
    

    Ditto here.

Other than these nits, I see no problems here. Big props to @quietone for sticking with it! RTBC.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.0.x. Thanks!

  • webchick committed ef8e66d on 8.0.x
    Issue #2500535 by quietone, phenaproxima: Upgrade path for Tracker 7.x
    

The last submitted patch, 11: 2500535-11.patch, failed testing.

Status: Fixed » Needs work

The last submitted patch, 12: 2500535-12.patch, failed testing.

webchick’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Wim Leers’s picture