When user use pass reset link and submit new password we are getting next warning

Notice: Undefined index: Email_Preference in salsa_profile_email_preference_update() (line 796 of /home/pivica/moje/www/md-systems/unicef.dev.local/sites/all/modules/contrib/salsa_entity/salsa_profile/salsa_profile.module).

This is happening because in

/**
 * Additional edit form callback that updates Email_Preference field.
 */
function salsa_profile_email_preference_update($form, $form_state) {
  if (is_object($form_state['supporter'])) {
    if (module_exists('mimemail')) {
      $form_state['supporter']->Email_Preference = $form_state['values']['mimemail_textonly'] ? EMAIL_PREFERENCE_TEXT : EMAIL_PREFERENCE_HTML;
      $form_state['supporter']->save();
    }
    else {
      $form_state['supporter']->Email_Preference = $form_state['values']['Email_Preference'];
      $form_state['supporter']->save();
    }
  }
}

we are missing $form_state['values']['Email_Preference']. Adding simple !empty() check for this there would be enough to fix this.

Comments

pivica created an issue. See original summary.

pivica’s picture

Status: Active » Needs review
StatusFileSize
new699 bytes

Here is a patch.

Status: Needs review » Needs work

The last submitted patch, 2: user-reset-pass-submit-form-warning-2829267-2.patch, failed testing.

berdir’s picture

!empty() is likely wrong. I'm not sure if the value for the unchecked checkbox is NULL or FALSE, we need isset() if it is FALSE and array_key_exists() if it is NULL. I think it is FALSE, but not 100% sure right now.

pivica’s picture

StatusFileSize
new698 bytes

Yeah was too quick with this you are right !empty() check would be wrong. Did a detail debug with all possible cases and $form['Email_Preference'] can be empty string (FALSE) or have a string definition - this is defined as constants in same module. And in the case when it is producing above warning then the Email_Preference is missing fully in values array.

Here is a new patch with isset() check which should be fine now.

pivica’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 5: user-reset-pass-submit-form-warning-2829267-5.patch, failed testing.

pivica’s picture

Status: Needs work » Needs review

Hmm CI says

15:48:38 PHP Parse error:  syntax error, unexpected '[' in /var/www/html/sites/all/modules/salsa_entity/salsa_entity.drush.inc on line 134
15:48:38 PHP Stack trace:
15:48:38 PHP   1. {main}() /.composer/vendor/drush/drush/drush.php:0
15:48:38 PHP   2. drush_main() /.composer/vendor/drush/drush/drush.php:11
15:48:38 PHP   3. Drush\Boot\BaseBoot->bootstrap_and_dispatch() /.composer/vendor/drush/drush/drush.php:70
15:48:38 PHP   4. drush_dispatch() /.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php:62
15:48:38 PHP   5. call_user_func_array:{/.composer/vendor/drush/drush/includes/command.inc:187}() /.composer/vendor/drush/drush/includes/command.inc:187
15:48:38 PHP   6. drush_command() /.composer/vendor/drush/drush/includes/command.inc:187
15:48:38 PHP   7. _drush_invoke_hooks() /.composer/vendor/drush/drush/includes/command.inc:219
15:48:38 PHP   8. call_user_func_array:{/.composer/vendor/drush/drush/includes/command.inc:368}() /.composer/vendor/drush/drush/includes/command.inc:368
15:48:38 PHP   9. drush_core_pre_site_install() /.composer/vendor/drush/drush/includes/command.inc:368
15:48:38 PHP  10. drush_bootstrap() /.composer/vendor/drush/drush/commands/core/site_install.drush.inc:197
15:48:38 PHP  11. _drush_find_commandfiles() /.composer/vendor/drush/drush/includes/bootstrap.inc:312
15:48:38 PHP  12. _drush_add_commandfiles() /.composer/vendor/drush/drush/includes/command.inc:1404
15:48:38 PHP  13. Drush\Command\Commandfiles->add() /.composer/vendor/drush/drush/includes/command.inc:1465

But there is nothing wrong with that lines there, just checked

        $query   = []; // Line 134
        $query[] = 'object=' . rawurldecode($type);
        $query[] = 'limit=' . rawurldecode($sequence * $paging . ',' . $paging);

Probably some CI failure, but lets try one more time.

Status: Needs review » Needs work

The last submitted patch, 5: user-reset-pass-submit-form-warning-2829267-5.patch, failed testing.

pivica’s picture

Okey see it now, CI is using PHP5.3 and we are using [] here...

pivica’s picture

Status: Needs work » Needs review
StatusFileSize
new1.1 KB

Okey new patch fixing PHP incompatibility.

  • Berdir committed 757a071 on 7.x-1.x authored by pivica
    Issue #2829267 by pivica: PHP warning on user reset pass submit form
    
berdir’s picture

Status: Needs review » Fixed

Thanks, committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.