Today I installed this module on a new site. Before I had a chance to configure it with the account username/password, I noticed that regular users were being redirected to the Mailjet Settings page when they tried to edit and save their account. Digging into the code, I found that mailjet_new() is causing this redirect whenever the username/password are not set up yet.

This redirection appears to happen in the following places:

  • When a user is added, deleted or canceled.
  • When a user edits their account page.
  • When new fields are created and added to content types.
  • When fields are deleted.

I'm changing the Priority on this task to Major since it adversely affects non-admin users of any new site. Ideally the message and redirection should only happen for admins.

Comments

hargobind created an issue. See original summary.

hargobind’s picture

Status: Active » Needs review
StatusFileSize
new2.11 KB

Attached is a patch which does a few things:

  • It tests to see if the user has "administer mailjet module" access. Only in that case will they see the error message.
  • I changed the error message to include the link to the configuration page rather than forcing a redirect. This allows admins to continue configuring their site at their own pace.
  • Now that the redirection isn't happening, continuing to perform operations like syncing a user, etc. will cause an error. Therefore, I added code to exit the current routine if $mailjet = mailjet_new(); returns false. There might be other places in the code where this should be added, including submodules (which I didn't check for).
  • And lastly, a minor comment block change from "###" to "//".

.

If you use this patch or any of the code in it, please follow Drupal's best practices for commit messages. Please have a look at Commit messages - providing history and credit. In short, use the syntax Issue #[issue number] by [comma-separated usernames]: [Short summary of the change]. This helps commits appear in the issue queue automatically, and gives commit credits to people who have authored patches for your projects.

mailjet plugins’s picture

Status: Needs review » Fixed

This issue has been fixed in v. 7.x-2.18

mailjet plugins’s picture

Status: Fixed » Closed (fixed)