This is a fairly simple callback, but it does have the ability to throw exceptions. There's also a patch for 8.x to have it through different classes of exception, which will add complexity. Hence worth documenting. Patch coming!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Status: Active » Needs review
FileSize
1.68 KB
Crell’s picture

Status: Needs review » Reviewed & tested by the community
jhodgdon’s picture

Nice! Thanks!

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x. Thanks again!

Status: Fixed » Closed (fixed)

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

joachim’s picture

Version: 8.0.x-dev » 7.x-dev
Status: Closed (fixed) » Patch (to be ported)
Issue tags: +Novice

Let's backport this to 7. Tagging as novice.

er.pushpinderrana’s picture

Status: Patch (to be ported) » Needs review
FileSize
1.58 KB

Here is patch for D7.

joachim’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! Looks great.

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks again, and sorry for the delay -- committed to 7.x.

  • jhodgdon committed 76e3d53 on 7.x
    Issue #2208649 by joachim, er.pushpinderrana: document queue worker...
joachim’s picture

Oops. Looks like this has got placed into the hooks topic rather than callbacks!

jhodgdon’s picture

Status: Fixed » Needs work

Ah, well it should be a quick patch to move it? Thanks for noticing...

jhodgdon’s picture

To clarify:

Inside system.api.php, there is an "@addtogroup callbacks".

The callback defined in this patch, callback_queue_worker(), needs to be moved from its present location in that file to inside the addtogroup callbacks section.

areke’s picture

Status: Needs work » Needs review
FileSize
1.71 KB
David_Rothstein’s picture

Status: Needs review » Needs work

I think there's a couple other things to fix in the original patch also:

- * - 'worker callback': The name of the function to call. It will be called
- * with one argument, the item created via DrupalQueue::createItem().
+ * - 'worker callback': A PHP callable to call that is an implementation of
+ * callback_queue_worker().

"PHP callable" isn't true unless you're running PHP 5.4 or higher - otherwise it must be a standard function, at least for now. See #2342667: Cron and batch processing of queues are not accepting callables

+ * @throws \Exception

The leading slash isn't correct for Drupal 7.

+  $node->save();

That's really not correct for Drupal 7 :) It should be node_save().

areke’s picture

FileSize
2.34 KB

How's this?

areke’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 16: 2208649-16.patch, failed testing.

areke’s picture

Status: Needs work » Needs review
FileSize
2.35 KB

Silly me :P

joachim’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Needs review
- *   - 'worker callback': A PHP callable to call that is an implementation of
- *     callback_queue_worker().
+ *   - 'worker callback': The name of the function to call. It will be called
+ *     with one argument, the item created via DrupalQueue::createItem().

Do we really want to remove the reference to callback_queue_worker()? If we do it seems like it would be a lot harder for people to find it in the documentation.

joachim’s picture

Status: Needs review » Needs work

Oh yes you're right! That needs to be linked to.

David_Rothstein’s picture

Status: Needs work » Needs review
FileSize
2.18 KB
807 bytes

Here's a new version to move this along. This just uses similar phrasing to what's used for other callbacks in system.api.php.

David_Rothstein’s picture

FileSize
2.19 KB
714 bytes

I actually see a couple more problems here - see the interdiff.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks fine to me!

jhodgdon’s picture

David: do you want me to commit this one? If so assign it to me.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Fixed

Nah, I can go ahead and take care of it.

Committed to 7.x - thanks!

  • David_Rothstein committed edf23f2 on 7.x
    Issue #2208649 by areke, David_Rothstein, joachim, er.pushpinderrana,...

Status: Fixed » Closed (fixed)

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