Update Error "Call to undefined function _subscriptions_send_intervals()"

venusrising - September 29, 2009 - 03:14
Project:Subscriptions
Version:6.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

The update process was aborted prematurely while running update #6101 in subscriptions.module.

An unrecoverable error has occurred. You can find the error message below. It is advised to copy it to the clipboard for reference.
Please continue to the error page
An error occurred.

http://www.xxxxxx.com/update.php?id=256&op=do
Fatal error: Call to undefined function _subscriptions_send_intervals() in /home/xxxxxx/html/sites/all/modules/subscriptions/subscriptions.install on line 416
array(4) { ["type"]=> int(1) ["message"]=> string(58) "Call to undefined function _subscriptions_send_intervals()" ["file"]=> string(73) "/home/xxxxxx/html/sites/all/modules/subscriptions/subscriptions.install" ["line"]=> int(416) } n/a
Starting updates

Anyone see this and know how to fix it?

#1

salvis - September 29, 2009 - 09:48
Priority:normal» critical
Status:active» needs work

Ouch, yes, I see the problem — I'll have a fix in an hour or two.

#2

venusrising - September 29, 2009 - 09:51

Thanks

#3

salvis - September 29, 2009 - 10:10
Priority:critical» normal

@venusrising:

Well, it looks scarier than it is. You can safely ignore the error.

What you've lost are the current last_sent times of your users, but they'll be replaced automatically.

This means, if you have a user with a send_interval of a week, and they received a notification yesterday, they shouldn't get the next one until next week, but because the last_sent times were lost, they'll get the next one immediately. This is a one-time glitch, and the once-a-week rhythm will be back in place automatically after that.

Nonetheless, I'll release 1.2 today to spare others from the unpleasantness of encountering an update error.

Thank you for your quick report!

#4

salvis - September 29, 2009 - 11:26
Title:FATAL Error» Update Error "Call to undefined function _subscriptions_send_intervals()"
Status:needs work» postponed (maintainer needs more info)

@venusrising:

I'm puzzled why you get this error at all. When I run update.php under Drupal 6.13, it does load the 'subscriptions.admin.inc' file, which is apparently not loaded on your site.

The reason for loading on my plain-vanilla Garland test site is that the theme registry is rebuilt, and 'subscriptions.admin.inc' is loaded because it contains the theme_subscriptions_form_table() function, which is advertised in subscriptions_theme() in subscriptions.module.

Could it be that you've overridden (i.e. provided your own) *_subscriptions_form_table() function in a custom theme?

This would explain why this error hasn't been reported for 6.x-1.x-dev before it was released as 6.x-1.1.

#5

venusrising - September 29, 2009 - 23:39

I am running 6.14 and do not have any custom forms but subscription block was enabled if that helps.

#6

venusrising - September 29, 2009 - 23:40

When I disabled all subscription modules etc then re-enabled it went away?

#7

salvis - October 12, 2009 - 21:06

Not "custom form" but "custom theme". My guess is that if you were using the Garland theme, this would not have happened. It's surprising that the theme should make a difference for update.php, but apparently it does here. That is undesirable and I'll add a

<?php
 
include_once drupal_get_path('module', 'subscriptions') .'/subscriptions.admin.inc';
?>

to subscriptions_update_6101() to avoid this dependency, but it seems like this is less urgent than I had thought in the beginning, because no one else is reporting seeing this issue. I've updated 6.x-1.x-dev, but I won't make a 6.x-1.2 release just yet.

When I disabled all subscription modules etc then re-enabled it went away?

I don't understand what you're trying to ask or tell me here. Is the update still pending and you can't get over it? If that's the case, then do this:

1. First try to temporarily switch to Garland and run update.php. Please let us know whether this allows the update to complete or not. If Drupal continues to require running update.php, then

2. add the line above at the beginning of subscriptions_update_6101() and run it once more.

Either way you'll get some database errors (the table and index have already been created and possibly lines inserted into subscriptions_last_sent), but you can ignore these. #1 or #2 should allow the update to complete.

(I'll be on the road for the rest of the week and may not be able to reply until I get back.)

[EDIT: #1 apparently doesn't help.]

#8

guidot - October 3, 2009 - 22:54

I got the same error on a Drupal 6.14 install using a Zen-based theme.

1. Switching to Garland did not help.

2. Adding the include_once-statement right at the beginning of subscriptions_update_6101() gave a bunch of errors (this may obviously be the wrong place, but I'm not a developer), moving it below $schema['subscriptions_last_sent'] = array(...); did solve the issue.

#9

guidot - October 3, 2009 - 22:54
Status:postponed (maintainer needs more info)» active

#10

salvis - October 4, 2009 - 16:18

Thanks for chiming in, guidot!

Re 1: I wish I knew what was causing this. According to http://drupal.org/project/usage/subscriptions we had 372 known sites that upgraded to 6.x-1.1 a week ago (on Sep 27), and you're only the second person to report this issue. I still maintain that it's an "unusual" problem...

Re 2: It should not matter where you insert the include_once statement. Right above the foreach is the preferred place, because that's where _subscriptions_send_intervals() will be needed, but at the top of the function should work just as well. Too bad you didn't cut&paste at least the first of those messages.

I committed the fix on Sep 30, but I'm leaving this active as a signpost until 1.2 is out.

If others encounter this issue when upgrading to 1.1, then please let us know, so we get an idea of how frequent it is.

#11

guidot - October 5, 2009 - 22:07

I still have the error-messages. I used drush. So here you are:

The following updates are pending:                                                             

subscriptions module                                                          
6101 - Database update function 6101: Add the {subscriptions_last_sent} table.

Do you wish to run all pending updates? (y/n): y
CREATE TABLE {subscriptions_last_sent} (                             [error]
`uid` INT NOT NULL,                                                        
`send_interval` INT NOT NULL,                                              
`last_sent` INT unsigned NOT NULL DEFAULT 0,                               
PRIMARY KEY (uid, send_interval)                                           
) /*!40100 DEFAULT CHARACTER SET UTF8 */                                   
ALTER TABLE {subscriptions_queue} ADD INDEX uid (uid)                [error]
Finished performing updates.                                         [ok]  
user warning: Table &#039;subscriptions_last_sent&#039; already      [error]
exists                                                                     
query: CREATE TABLE subscriptions_last_sent (                              
`uid` INT NOT NULL,                                                        
`send_interval` INT NOT NULL,                                              
`last_sent` INT unsigned NOT NULL DEFAULT 0,                               
PRIMARY KEY (uid, send_interval)                                           
) /*!40100 DEFAULT CHARACTER SET UTF8 */ in                                
/var/www/vhosts/example.com/html/includes/database.inc on line      
529.                                                                       
user warning: Duplicate key name &#039;uid&#039;                     [error]
query: ALTER TABLE subscriptions_queue ADD INDEX uid (uid) in              
/var/www/vhosts/example.com/html/includes/database.mysql-common.inc 
on line 434.                                                               
user warning: Duplicate entry &#039;3-1&#039; for key 1              [error]
query: INSERT INTO subscriptions_last_sent (uid, send_interval,            
last_sent) SELECT uid, 1, last_sent FROM subscriptions_user WHERE uid      
&gt; 0 in                                                                  
/var/www/vhosts/example.com/html/sites/all/modules/subscriptions/subscriptions.install
on line 418.                                                                                
An error occurred at function : drush_core_updatedb                  [error]                

If I can be of any other help let me know.

#12

salvis - October 6, 2009 - 07:21

@guidot: As far as I can see, these errors are all caused by rerunning the same update again after they've already run. Update 6101 creates a table, creates an index, and inserts some rows. At least the first two operations completed successfully the first time, and they will fail when you run the same update again. This is normal Drupal behavior.

I'm not sure whether the INSERT succeeded or not — the log format is not very clear. As I explained in #3, the INSERT is a nice-to-have, but if it fails it's only a minor glitch.

Is the Update 6101 still shown as pending for you?

#13

guidot - October 6, 2009 - 19:57

Is the Update 6101 still shown as pending for you?

@salvis: No, not anymore.

And thank you for your detailed explanantions!

#14

mrtoner - October 12, 2009 - 05:29

Had this error show up when upgrading from 6.x-1.0 (6.14). Used the suggestions in #7; #1 did not work, #2 did.

#15

salvis - October 12, 2009 - 21:09

Thank you for your feedback — I added a note in #7.

You are only the third person out of over 500 updaters. I'm still puzzled what could be causing this.

#16

mgifford - October 21, 2009 - 20:07

I got this error too when running update.php. Doesn't look like release 1.2 got out.

An error occurred. http://churchill.openconcept.ca/update.php?id=16&op=do <br /> <b>Fatal error</b>: Call to undefined function _subscriptions_send_intervals() in <b>/where/it/is/sites/all/modules/subscriptions/subscriptions.install</b> on line <b>416</b><br /> "

#17

salvis - October 21, 2009 - 22:47

Yes, there's a trade-off between raising update alarms for a thousand sites and fixing a one-time issue that less than one percent of the upgraders encounter.

#18

mgifford - October 22, 2009 - 13:09

Ok, but I'm still not sure how to get rid of it. Tried modifying the .install file so that the function is included specifically using:

include_once drupal_get_path('module', 'subscriptions') .'subscriptions.admin.inc';

However that didn't seem to get anywhere.

Also remember that for every bug reported there are at least 10 folks who just say "hey, this module's bust, I'll have to remove it and wait for the next release to try it again".

So, the numbers of users who have problems is likely higher than you think.

#19

salvis - October 22, 2009 - 22:37

What do you mean with "to get rid of it"? What is it that you want "to get rid of"?

In the light of #3, what makes you think that you need to do anything?

#20

DamienMcKenna - November 3, 2009 - 03:39

Ran into this issue doing a site upgrade from D5 to D6..

#21

DamienMcKenna - November 3, 2009 - 04:25

I can confirm that the current dev release works around this issue, no more errors :) Thanks!

 
 

Drupal is a registered trademark of Dries Buytaert.