Unverified Commit 03a57358 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3525170 by benjifisher, catch, greggles, larowlan, mcdruid: Clean up...

Issue #3525170 by benjifisher, catch, greggles, larowlan, mcdruid: Clean up unserialize() in the migration modules
parent 01eecd5c
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ function hook_migrate_prepare_row(Row $row, MigrateSourceInterface $source, Migr
  if ($migration->id() == 'd6_filter_formats') {
    $value = $source->getDatabase()->query('SELECT [value] FROM {variable} WHERE [name] = :name', [':name' => 'my_module_filter_foo_' . $row->getSourceProperty('format')])->fetchField();
    if ($value) {
      $row->setSourceProperty('settings:my_module:foo', unserialize($value));
      $row->setSourceProperty('settings:my_module:foo', unserialize($value, ['allowed_classes' => FALSE]));
    }
  }
}
@@ -179,7 +179,7 @@ function hook_migrate_prepare_row(Row $row, MigrateSourceInterface $source, Migr
function hook_migrate_MIGRATION_ID_prepare_row(Row $row, MigrateSourceInterface $source, MigrationInterface $migration) {
  $value = $source->getDatabase()->query('SELECT [value] FROM {variable} WHERE [name] = :name', [':name' => 'my_module_filter_foo_' . $row->getSourceProperty('format')])->fetchField();
  if ($value) {
    $row->setSourceProperty('settings:my_module:foo', unserialize($value));
    $row->setSourceProperty('settings:my_module:foo', unserialize($value, ['allowed_classes' => FALSE]));
  }
}

+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ public function getDefinitions() {
                if (isset($cached['id'])) {
                  // Explicitly unserialize this to create a new object
                  // instance.
                  $definitions[$cached['id']] = unserialize($cached['content']);
                  $definitions[$cached['id']] = unserialize($cached['content'], ['allowed_classes' => FALSE]);
                }
                continue;
              }
+2 −1
Original line number Diff line number Diff line
@@ -71,7 +71,8 @@ public function query() {
   * {@inheritdoc}
   */
  public function prepareRow(Row $row) {
    $row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));
    // @see \Drupal\Core\Config\DatabaseStorage::decode()
    $row->setSourceProperty('data', unserialize($row->getSourceProperty('data'), ['allowed_classes' => FALSE]));
    return parent::prepareRow($row);
  }

+1 −1
Original line number Diff line number Diff line
@@ -173,7 +173,7 @@ protected function variableGet($name, $default) {
    catch (\Exception) {
      $result = FALSE;
    }
    return $result !== FALSE ? unserialize($result) : $default;
    return $result !== FALSE ? unserialize($result, ['allowed_classes' => ['stdClass']]) : $default;
  }

  /**
+4 −1
Original line number Diff line number Diff line
@@ -129,7 +129,10 @@ protected function values() {
    // Create an ID field so we can record migration in the map table.
    // Arbitrarily, use the first variable name.
    $values['id'] = reset($this->variables);
    return $values + array_map('unserialize', $this->prepareQuery()->execute()->fetchAllKeyed());
    return $values + array_map(
      fn($data) => unserialize($data, ['allowed_classes' => FALSE]),
      $this->prepareQuery()->execute()->fetchAllKeyed(),
    );
  }

  /**
Loading