Commit 1aaec842 authored by Sven Berg Ryen's avatar Sven Berg Ryen
Browse files

Issue #3230858 by svenryen: Drupal 9 and Simplenews 3.x compatibility?

parent 1e59f641
Loading
Loading
Loading
Loading

.tugboat/config.yml

0 → 100644
+53 −0
Changes for .tugboat/config.yml: 53 added lines, 0 removed lines.
Original line number Diff line number Diff line
services:
  php:
    image: q0rban/tugboat-drupal:9.3
    default: true
    http: false
    depends: mysql
    commands:
      update: |
        set -eux
        # Check out a branch using the unique Tugboat ID for this repository, to
        # ensure we don't clobber an existing branch.
        git checkout -b $TUGBOAT_REPO_ID
        # Composer is hungry. You need a Tugboat project with a pretty sizeable
        # chunk of memory.
        export COMPOSER_MEMORY_LIMIT=-1
        # This is an environment variable we added in the Dockerfile that
        # provides the path to Drupal composer root (not the web root).
        cd $DRUPAL_COMPOSER_ROOT
        # We configure the Drupal project to use the checkout of the module as a
        # Composer package repository.
        composer config repositories.tugboat vcs $TUGBOAT_ROOT
        # Now we can require this module, specifing the branch name we created
        # above that uses the $TUGBOAT_REPO_ID environment variable.
        composer require drupal/simplenews:dev-3.x
        composer require drupal/ultimate_cron:2.0-alpha5
        composer require drupal/simplenews_scheduler:dev-$TUGBOAT_REPO_ID
        # Install Drupal on the site.
        vendor/bin/drush \
          --yes \
          --db-url=mysql://tugboat:tugboat@mysql:3306/tugboat \
          --site-name="Live preview for ${TUGBOAT_PREVIEW_NAME}" \
          --account-pass=admin \
          site:install standard
        # Set up the files directory permissions.
        mkdir -p $DRUPAL_DOCROOT/sites/default/files
        chgrp -R www-data $DRUPAL_DOCROOT/sites/default/files
        chmod 2775 $DRUPAL_DOCROOT/sites/default/files
        chmod -R g+w $DRUPAL_DOCROOT/sites/default/files
        # Enable the module.
        vendor/bin/drush --yes pm:enable simplenews,simplenews_scheduler,ultimate_cron
      build: |
        set -eux
        # Delete and re-check out this branch in case this is built from a Base Preview.
        git branch -D $TUGBOAT_REPO_ID && git checkout -b $TUGBOAT_REPO_ID || true
        export COMPOSER_MEMORY_LIMIT=-1
        cd $DRUPAL_COMPOSER_ROOT
        composer install --optimize-autoloader
        # Update this module, including all dependencies.
        composer update drupal/simplenews_scheduler --with-all-dependencies
        vendor/bin/drush --yes updb
        vendor/bin/drush cache:rebuild
  mysql:
    image: tugboatqa/mariadb
+1 −1
Changes for composer.json: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -4,6 +4,6 @@
  "type": "drupal-module",
  "license": "GPL-2.0-or-later",
  "require": {
    "drupal/simplenews": "^2.0"
    "drupal/simplenews": "^3.0"
  }
}
+11 −9
Changes for simplenews_scheduler.api.php: 11 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -5,19 +5,21 @@
 * Hooks provided by the Simplenews scheduler module.
 */

use Drupal\node\Entity\Node;

/**
 * Alter the node object that was cloned from the template node before it gets saved.
 * Alter node object that was cloned from template node before it gets saved.
 *
 * The node is passed as node object and therefore passed by reference. This hook
 * is for example usefull if you have fields in the template node that contain
 * information about data that should get rendered dynamically into the edition
 * node depenedent on the current schedule date.
 * The node is passed as node object and therefore passed by reference. This
 * hook is for example usefull if you have fields in the template node that
 * contain information about data that should get rendered dynamically into the
 * edition node depenedent on the current schedule date.
 *
 * @param $edition_node
 * @param \Drupal\node\Entity\Node $edition_node
 *   The cloned node object based on the scheduler node.
 * @param $scheduler_node
 * @param \Drupal\node\Entity\Node $scheduler_node
 *   The original scheduler node object.
 */
function hook_simplenews_scheduler_edition_node_alter($edition_node, $scheduler_node) {
  $edition_node->setTitle('Your newsletter from ' . REQUEST_TIME);
function hook_simplenews_scheduler_edition_node_alter(Node $edition_node, Node $scheduler_node) {
  $edition_node->setTitle('Your newsletter from ' . \Drupal::time()->getRequestTime());
}
+1 −1
Changes for simplenews_scheduler.info.yml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -4,5 +4,5 @@ core: 8.x
core_version_requirement: ^8 || ^9
package: Mail
dependencies:
  - simplenews:simplenews (>=8.x-2.x)
  - simplenews:simplenews (>=3.x)
type: module
+39 −39
Changes for simplenews_scheduler.install: 39 added lines, 39 removed lines.
Original line number Diff line number Diff line
@@ -9,107 +9,107 @@
 * Implements hook_schema().
 */
function simplenews_scheduler_schema() {
  $schema['simplenews_scheduler'] = array(
  $schema['simplenews_scheduler'] = [
    'description' => 'Scheduled newsletter data.',
    'fields' => array(
      'nid' => array(
    'fields' => [
      'nid' => [
        'description' => 'The node id for a scheduled newsletter.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'last_run' => array(
      ],
      'last_run' => [
        'description' => 'The timestamp the scheduled newsletter was last sent.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'next_run' => array(
      ],
      'next_run' => [
        'description' => 'The future timestamp the next scheduled newsletter is due to be sent.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'activated' => array(
      ],
      'activated' => [
        'description' => 'Whether the schedule is active.',
        'type' => 'int',
        'size' => 'tiny',
        'not null' => TRUE,
        'default' => 0,
      ),
      'send_interval' => array(
      ],
      'send_interval' => [
        'description' => 'The interval at which to send, as a text string.',
        'type' => 'varchar',
        'length' => 10,
      ),
      'interval_frequency' => array(
      ],
      'interval_frequency' => [
        'description' => 'The number of intervals between newsletter transmission.',
        'type' => 'int',
        'default' => 1,
        'not null' => TRUE,
      ),
      'start_date' => array(
      ],
      'start_date' => [
        'description' => 'The timestamp at which to start sending editions.',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'stop_type' => array(
      ],
      'stop_type' => [
        'description' => 'How to determine when to stop sending editions.',
        'type' => 'int',
        'not null' => TRUE,
      ),
      'stop_date' => array(
      ],
      'stop_date' => [
        'description' => 'The timestamp at which to stop sending editions.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 1388447999,
      ),
      'stop_edition' => array(
      ],
      'stop_edition' => [
        'description' => 'The edition count at which to stop sending editions.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'title' => array(
      ],
      'title' => [
        'description' => 'The title of new edition nodes.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
    ),
    'primary key' => array('nid'),
  );
      ],
    ],
    'primary key' => ['nid'],
  ];

  $schema['simplenews_scheduler_editions'] = array(
  $schema['simplenews_scheduler_editions'] = [
    'description' => 'Stores data for each edition of a scheduled newsletter.',
    'fields' => array(
      'eid' => array(
    'fields' => [
      'eid' => [
        'description' => 'The node id for the edition.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'pid' => array(
      ],
      'pid' => [
        'description' => 'The node id for the parent scheduled newsletter node.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
      'date_issued' => array(
      ],
      'date_issued' => [
        'description' => 'The timestamp on which this edition was sent.',
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array('eid'),
  );
      ],
    ],
    'primary key' => ['eid'],
  ];
  return $schema;
}

/**
 * Implementation of hook_uninstall().
 * Implements hook_uninstall().
 */
function simplenews_scheduler_uninstall() {
  drupal_uninstall_schema('simplenews_scheduler');
Loading