In using the latest version of Subscriptions I was not able to get cron running properly.

I came across the following error:

Error: Class 'subscriptions_content_data' not found in /subscriptions/subscriptions_mail.cron.inc, line 119

I *think* it relates to the fact that the proper module (subscriptions_content) is not being included, but for the life of me cannot figure out how to make that work properly.

To verify:
* I cleared cache a bunch of times
* Ran updatedb also....

Thoughts?

Comments

shaneonabike’s picture

Status: Active » Needs review
StatusFileSize
new1.62 KB

Ok it turns out that this was my fault actually. When I created the custom module I copied code for the hook_subscriptions call in the 'fields' section.

What's interesting though is that having defined identical fields to subscriptions_content the code ended up creating an array for the variable $data_function (see patch). I realized that in some circumstances maybe folks would want to define the same variables but add their own data_function to deal with some element of changes happening?

Here's a patch... let me know if you want to scrap it but it might at least alleviate others having this issue.

shaneonabike’s picture

Priority: Major » Minor

BTW I recognize this is an edge-case but actually by adding this you'll extend the API a bit (har har)

Status: Needs review » Needs work
salvis’s picture

Title: Cron not executed: Error: Class 'subscriptions_content_data' not found in /subscriptions_mail.cron.inc line 119 » Add support for multiple 'data_function's
Category: bug » feature
Status: Needs work » Closed (won't fix)

Thank you for following through with this.

Please learn and adopt the http://drupal.org/coding-standards. This may seem nit-picky at first, but in the end everyone benefits from uniform code.

I've started to write comments for your patch...

  1. +++ b/subscriptions_mail.cron.inc
    @@ -100,7 +100,8 @@ function _subscriptions_mail_cron() {
    +         // Determine if multiple data functions are defined if not make it into an array
    

    Add semicolon and dot, wrap at 80.

  2. +++ b/subscriptions_mail.cron.inc
    @@ -100,7 +100,8 @@ function _subscriptions_mail_cron() {
    +	  if (!is_array($data_functions)) $data_functions = array($data_functions);
    

    Always use braces.

  3. +++ b/subscriptions_mail.cron.inc
    @@ -116,7 +117,9 @@ function _subscriptions_mail_cron() {
    +	  foreach($data_functions as $data_function) {
    +             $data_function($data, $object, $queue_item);
    +	  }
               drupal_alter('subscriptions_data', $data, $object, $queue_item);
    

    Avoid tabs and indent properly. Add a space after foreach.

... but in the end I'm not convinced that it's a good idea.

We could argue to go to arrays for all the data returned from hook_subscriptions(), but without a demonstrated need and successful implementation, it's just stale code that is never executed.

I doubt your code would have performed as expected, even with this patch.

Please clean up #2014867-10: Subscriptions causing cron to run endlessly.

shaneonabike’s picture

Could be an edge case like I said. I'm happy just to ditch this anyway. I'll try to find some time to work on fixing up coding standards before I post other stuff.