Skip to content

Commit

Permalink
add backlinking to hook_update from post_update
Browse files Browse the repository at this point in the history
  • Loading branch information
WengerK committed Jul 5, 2024
1 parent 9a56fcb commit 78e45dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 3 additions & 3 deletions backerymails.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* Contains backerymails.install.
*/

use Drupal\Core\Database\Database;
use Drupal\Core\Field\BaseFieldDefinition;
use Symfony\Component\Yaml\Yaml;
use Drupal\Core\Url;
use Drupal\Core\Database\Database;
use Symfony\Component\Yaml\Yaml;

/**
* Implements hook_install().
Expand All @@ -25,7 +25,7 @@ function backerymails_install() {
}

/**
* Implementions of hook_update_N().
* Implementions of hook_update_N().
*/

/**
Expand Down
4 changes: 3 additions & 1 deletion backerymails.post_update.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

/**
* Migrate data from the old existing Backerymails table to the new one.
*
* @see backerymails_update_8001()
*/
function backerymails_post_update_8001_migrate_data(&$sandbox = NULL) {
$database = Database::getConnection();

if ($database->schema()->tableExists('backerymails_sended_mail') && $database->schema()->tableExists('backerymails_sent_mails')) {
$query = $database->select('backerymails_sended_mail', 'sent_mails')
$query = $database->select('backerymails_sended_mail', 'sent_mails')
->fields('sent_mails');

$backerymails_storage = \Drupal::service('entity_type.manager')->getStorage('backerymails_entity');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,17 @@ protected function setDatabaseDumpFiles() {
// This conditional allows tests to pass both before and after 8.8.x. The
// 8.4.0 fixtures were removed in 8.8.x.
// https://www.drupal.org/project/consumers/issues/3115996
// @todo: Remove this conditional after 8.7.x is no longer supported.

// @todo Remove this conditional after 8.7.x is no longer supported.
if (file_exists(DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-8.8.0.bare.standard.php.gz')) {
$this->databaseDumpFiles = [
DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-8.8.0.bare.standard.php.gz',
__DIR__ . '/../../../fixtures/update/drupal-8.backerymails-installed.php',
__DIR__ . '/../../../fixtures/update/drupal-8.backerymails-entity-typos-8001.php',
__DIR__ . '/../../../fixtures/update/drupal-8.backerymails-installed.php',
__DIR__ . '/../../../fixtures/update/drupal-8.backerymails-entity-typos-8001.php',
];
}
else {
$this->databaseDumpFiles = [
// @todo: Remove this fixture after 8.7 is no longer supported.
// @todo Remove this fixture after 8.7 is no longer supported.
DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../fixtures/update/drupal-8.backerymails-installed.php',
__DIR__ . '/../../../fixtures/update/drupal-8.backerymails-entity-typos-8001.php',
Expand Down Expand Up @@ -91,7 +90,7 @@ public function testUpdate8001() {
'en',
'backerymails.subject',
'backerymails.body',
null,
NULL,
])
->execute();
$this->assertEquals(1, $database->query('SELECT count(*) FROM {backerymails_sended_mail}')->fetchField());
Expand Down

0 comments on commit 78e45dd

Please sign in to comment.