backdrop-contrib / smtp

Backdrop CMS port of the SMTP module for Drupal 7
GNU General Public License v2.0
4 stars 5 forks source link

Drupal upgrade path fails on undefined constant #22

Closed jenlampton closed 1 year ago

jenlampton commented 1 year ago

When upgrading from Drupal 7, I get a fatal during update.php, with this error:

Error: Undefined constant "SMTP_LOGGING_NONE" in smtp_update_1301() (line 111 of backdrop/docroot/modules/contrib/smtp/smtp.install).

These constants are not defined during the update phase, because they were placed in the .module file, which is not loaded during this phase. The simplest solution is to use a variable instead.

function smtp_update_1301() {

  // Redefine constants for update purposes.
  $logging_none = 0;
  $logging_all = 1;
  $logging_errors = 2;

  $logging = $logging_none;

  $old_debugging_value = config_get('smtp.settings', 'smtp_debugging');
  if ($old_debugging_value == 1) {
    $logging = $logging_errors;
  }

  config_set('smtp.settings', 'smtp_debugging', $logging);
}

PR on the way.