I installed simplenews scheduler today and whenever I try to create a scheduled newsletter, I keep getting this error message. "Saving or updating schedule settings for "newsletter name" has been unsuccessful."

Can someone point me to a solution for this issue please

I am on the latest drupal 6 release.

Comments

sgabe’s picture

Priority: Major » Normal

Can you provide more details on how to reproduce?

dgtlmoon’s picture

Status: Active » Needs review

Yeah let us know if theres something we can do to reproduce, or try the 2.x branch with simplenews 6.x-2.x

dgtlmoon’s picture

Status: Needs review » Postponed (maintainer needs more info)
Anonymous’s picture

I have the same issue, using simplenews 2.x and simplenews scheduler 2.x

The error message is

* warning: pg_query(): Query failed: ERROR: syntax error at or near "`" LINE 1: ...INTO drupal_simplenews_scheduler (nid, activated, `interval`... ^ in /home/www/www.habeas.com.pt/drupal/includes/database.pgsql.inc on line 138.

* user warning: query: INSERT INTO drupal_simplenews_scheduler (nid, activated, `interval`, start_date, stop, stop_date, stop_edition, php_eval ) VALUES (196, 0, 'day', 1307107080, 0, 1388447940, 0, '') ON DUPLICATE KEY UPDATE last_run = 0, activated = 0, `interval` = 'day', start_date = 1307107080, stop = 0, stop_date = 1388447940, stop_edition = 0, php_eval = '' in /home/www/www.habeas.com.pt/drupal/sites/all/modules/simplenews_scheduler/simplene... on line 153.

* Saving or updating schedule settings for teste has been unsuccessful.

Anonymous’s picture

any quick and dirt fix for this issue?

dgtlmoon’s picture

@lutra -> Are you still getting this problem on latest dev?

Anonymous’s picture

yes, I'm using 6.x-2.0-beta3 with simplenews 6.x-2.0-alpha2

PS

How I get notifications of answers in this ticket? Sorry I'm not yet comfortable with the Drupal tracker.

dgtlmoon’s picture

No idea sorry

Anonymous’s picture

Hi,

no idea about the notifications or about the bug? :)

Azol’s picture

Version: 6.x-2.x-dev » 6.x-1.0-beta3

"Quick and dirty" fix for this issue is as follows (only if you are on MySQL):

change all instances of interval and stop in a query with corresponding simplenews_scheduler.interval and simplenews_scheduler.stop prefixed ones, because INTERVAL and STOP are actual SQL commands.

So the query beginning on line 161 of simplenews_scheduler.module should read:

    $result = db_query("INSERT INTO {simplenews_scheduler} (nid, activated, simplenews_scheduler.interval, start_date, simplenews_scheduler.stop, stop_date, stop_edition, php_eval) 
                             VALUES (%d, %d, '%s', %d, %d, %d, %d, '%s')
                             ON DUPLICATE KEY UPDATE last_run = 0, activated = %d, simplenews_scheduler.interval = '%s', start_date = %d, simplenews_scheduler.stop = %d, stop_date = %d, stop_edition = %d, php_eval = '%s' ", $nid, $activated, $interval, $start_date, $stop, $stop_date, $stop_edition, $php_eval, $activated, $interval, $start_date, $stop, $stop_date, $stop_edition, $php_eval);

Hopefully someone will be able to create corresponding patch quick, marking this as Needs work meanwhile.

Azol’s picture

Version: 6.x-1.0-beta3 » 6.x-2.x-dev
Priority: Normal » Major
Status: Postponed (maintainer needs more info) » Needs work
Anonymous’s picture

Hi, thanks for the patch.

after applying it I get

* warning: pg_query(): Query failed: ERROR: syntax error at or near "ON" LINE 3: ON DUPLICATE KEY UPDATE last_ru... ^ in /home/www/www.habeas.com.pt/drupal/includes/database.pgsql.inc on line 138.
* user warning: query: INSERT INTO drupal_simplenews_scheduler (nid, activated, simplenews_scheduler.interval, start_date, simplenews_scheduler.stop, stop_date, stop_edition, php_eval) VALUES (220, 1, 'month', 1308416220, 2, 1388447940, 1, '') ON DUPLICATE KEY UPDATE last_run = 0, activated = 1, simplenews_scheduler.interval = 'month', start_date = 1308416220, simplenews_scheduler.stop = 2, stop_date = 1388447940, stop_edition = 1, php_eval = '' in /home/www/www.habeas.com.pt/drupal/sites/all/modules/simplenews_scheduler/simplene... on line 152.
* Saving or updating schedule settings for teste has been unsuccessful.

Azol’s picture

Version: 6.x-1.0-beta3 » 6.x-2.x-dev

I guess the problem is you are using PostgreSQL and I am using MySQL. I am not too good at DB syntax differences, but the problem here is that PostgreSQL does not support ON DUPLICATE KEY construction. The query this module uses is pure MySQL syntax.

dgtlmoon’s picture

Yes, well I guess either way we need to change those fields.

dgtlmoon’s picture

OK I have created two patches

One addresses the bad SQL directly and the other is a general cleanup (uses isset() etc).

It also includes an update hook to attempt to rename the tables.

update: don't use these patches

Azol’s picture

Status: Needs work » Needs review

Just a quick notice on the pgsql patch:

ON DUPLICATE KEY UPDATE last_run = 0, activated = %d, send_interval = '%s', start_date = %d, stop_type = %d, stop_date = %d, stop_edition = %d, php_eval = '%s' ", $nid, $activated, $interval, $start_date, $stop, $stop_date, $stop_edition, $php_eval, $activated, $interval, $start_date, $stop, $stop_date, $stop_edition, $php_eval, $nid);

Does this really needs a $nid at the very end of the line? I believe it's superfluous, since the last modifier used in query is php_eval='%s'

And yeah, it's not going to work on PostgreSQL due to ON DUPLICATE KEY mentioned above.

dgtlmoon’s picture

StatusFileSize
new10.56 KB

Yeah I don't know who added that DUPLICATE KEY business, heres an improved patch..

Azol’s picture

Status: Needs work » Needs review

These two patches ("improved sql" and "notify cleans") are contradicting each other - you cannot apply them one after another because each patch messes with part of the code the other patch refers to.

Could you possibly combine them into one patch so we can start testing?

Azol’s picture

Status: Needs review » Needs work

oops

dgtlmoon’s picture

Status: Needs review » Needs work

Please just use the patch in #17 I will rework the other patch once this issue is clearedcleared

Anonymous’s picture

To what version of the module the patch applies? I'm having problems to apply it to both the beta and dev verions (6.x-2)

Azol’s picture

Last dev. version works ok. Use only patch from #17

Azol’s picture

StatusFileSize
new10.55 KB

Oh, I can see your problem - the patch that dgtlmoon has provided is not a "fair" patch (I won't tell you why :)
Just use the one I attached here.

Anonymous’s picture

Thanks for the reviewed patch, it applies correctly.

Now the problem comes when cron runs (after having scheduled the day/hour when to send the newsletter), the error message I see is

* warning: pg_query(): Query failed: ERROR: column "full html" does not exist LINE 1: ...format FROM drupal_filter_formats WHERE name like "full html... ^ in /home/www/www.habeas.com.pt/drupal/includes/database.pgsql.inc on line 138.
* user warning: query: SELECT format FROM drupal_filter_formats WHERE name like "full html" in /home/www/www.habeas.com.pt/drupal/sites/all/modules/simplenews_scheduler/simplene... on line 344.

and the newsletter is not sent. Thanks in advance again.

dgtlmoon’s picture

Status: Needs work » Needs review
StatusFileSize
new12.34 KB

Try against latest dev, as I've also commited #1192670: 6.x-2.x HTML mail not sent which may help postgres users

Used the Drupal API for finding the "Full HTML" format instead of the silly SQL statement. (It needs to find the full html output filter to set the generated editions to, as they are static)

Azol’s picture

To lutra: replace "a/simplenews" occurences with "simplenews" and "b/simplenews" with "simplenews" in this patch to apply correctly :)

dgtlmoon’s picture

StatusFileSize
new12.37 KB

Found another glitch... which i hope is the last


     case 'view':
       if(isset($node->simplenews_scheduler_edition)) {
         drupal_set_message(t('You have been redirected to the original newsletter'));
         drupal_goto('node/'.$node->simplenews_scheduler_edition['pid'].'/simplenews');
       }
     break;

Seems to be triggering when sending newsletters.

fixed with

+       if(isset($node->simplenews_scheduler_edition) && arg(0) == 'node' ) {

Also, noticed that if you hit cron.php as a authenticated user, it does not unset your $user, so your newsletters can include [edit] etc

miro_dietiker’s picture

Note that arg(0)=='node' is also valid for test sending a newsletter...

dgtlmoon’s picture

StatusFileSize
new12.53 KB

OK, well i'm leaving that part out until we figure out a nicer way in the UI to show that you are viewing a generated newsletter and not the original.

dgtlmoon’s picture

StatusFileSize
new12.91 KB

Sorry, and this one actually implements the improved function for figuring out the input types instead of the bogus SQL

this contains...

   // Output format for all newly created items should just be Full HTML, incase of Views output etc.
-  if ($format_id = db_result(db_query('SELECT format FROM {filter_formats} WHERE name like "full html"'))) {
+  if ($format_id = _simplenews_scheduler_get_full_html_format() ) {
     $node->format = $format_id;
   }
+  

test against this patch.

dgtlmoon’s picture

StatusFileSize
new17.85 KB

This also takes care of lots of warnings if you have your PHP configured to return all notices/warnings for unset variables etc.

goleyasss’s picture

Simplenews Schuduler is adding stuff to new created editions of newsletters and shown on my home page when a user want to
enter the site.How can I delete this edition?

dgtlmoon’s picture

that's just how it works, it schedules a new copy of the newsletter to be created - also please post a support issue, not in this thread

dgtlmoon’s picture

Status: Needs review » Fixed

committed

dgtlmoon’s picture

Have done a lot of my own testing and seems to work nicely

miro_dietiker’s picture

Cool. Great to see this fixed.

Status: Fixed » Closed (fixed)

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