Commit 7190a52e authored by catch's avatar catch
Browse files

Issue #3270564 by quietone: Handle NULL for data blob in User source plugin

(cherry picked from commit c8b2c112)
parent f462b560
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ public function prepareRow(Row $row) {
      ->fetchCol();
    $row->setSourceProperty('roles', $roles);

    $row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));
    $row->setSourceProperty('data', unserialize($row->getSourceProperty('data') ?? ''));

    // If this entity was translated using Entity Translation, we need to get
    // its source language to get the field values in the right language.
+59 −0
Original line number Diff line number Diff line
@@ -54,6 +54,18 @@ public function providerSource() {
        'field_file_display' => 1,
        'field_file_description' => 'None',
      ],
      [
        'entity_type' => 'user',
        'bundle' => 'user',
        'deleted' => 0,
        'entity_id' => 3,
        'revision_id' => NULL,
        'language' => 'und',
        'delta' => 0,
        'field_file_fid' => 42,
        'field_file_display' => 1,
        'field_file_description' => 'None',
      ],
    ];
    $tests[0]['source_data']['role'] = [
      [
@@ -81,12 +93,34 @@ public function providerSource() {
        'init' => 'odo@local.host',
        'data' => 'a:1:{s:7:"contact";i:1;}',
      ],
      [
        'uid' => '3',
        'name' => 'foo',
        'pass' => 'password',
        'mail' => 'foo@local.host',
        'theme' => '',
        'signature' => '',
        'signature_format' => 'filtered_html',
        'created' => '1647752102',
        'access' => '0',
        'login' => '0',
        'status' => '1',
        'timezone' => 'America/Chicago',
        'language' => '',
        'picture' => '0',
        'init' => 'foo@local.host',
        'data' => NULL,
      ],
    ];
    $tests[0]['source_data']['users_roles'] = [
      [
        'uid' => 2,
        'rid' => 2,
      ],
      [
        'uid' => 3,
        'rid' => 2,
      ],
    ];

    // The expected results.
@@ -118,6 +152,31 @@ public function providerSource() {
          ],
        ],
      ],
      [
        'uid' => '3',
        'name' => 'foo',
        'pass' => 'password',
        'mail' => 'foo@local.host',
        'signature' => '',
        'signature_format' => 'filtered_html',
        'created' => '1647752102',
        'access' => '0',
        'login' => '0',
        'status' => '1',
        'timezone' => 'America/Chicago',
        'language' => '',
        'picture' => '0',
        'init' => 'foo@local.host',
        'roles' => [2],
        'data' => FALSE,
        'field_file' => [
          [
            'fid' => 42,
            'display' => 1,
            'description' => 'None',
          ],
        ],
      ],
    ];

    return $tests;