I have a custom module that needs to know when a full node import has been completed. But node_import doesn’t have a hook that allows that.

So here's the patch to add a "node_import_complete" hook.

Comments

johnalbin’s picture

Status: Active » Needs review

Needs review, of course.

Robrecht Jacques’s picture

Out of curiosity: what does your custom module use that for?
I'm wondering if this hook would need other parameters...

johnalbin’s picture

I want to batch import some nodes of a particular type that will replace the existing nodes of that type.

So I've…

  1. set the default publishing option for that node type as Unpublished,
  2. used HOOK_node_import_static() to set a variable to the current time (the first time it is called), and
  3. when the HOOK_node_import_complete() function is called, I Unpublish all nodes of that type then publish the ones created after the time I set in #2.

So I personally don't need anymore params besides $type.

Robrecht Jacques’s picture

Status: Needs review » Fixed

Committed to 5.x-1.x-dev. Will be included in 5.x-1.6 release.

johnalbin’s picture

Cool!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

ahabman’s picture

Is this behavior available in 6.x-1.0-rc4?

The code module_invoke_all('node_import_complete', $type) is not present, but I'm wondering if this functionality got rolled into 6.x in a different way. If not, thoughts on the best place to put the module_invoke_all call? My best guess was in node_import.inc just after

    // Cleanup before exit.
    $user = $backup_user;
    session_save_session(TRUE);
    timer_stop('node_import:do_task:'. $taskid);
    node_import_lock_release();

but this gets called after each row, not after the entire import has completed.

ahabman’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new355 bytes

'node_import_complete' callback added to 6.x-1.0-rc4

Robrecht Jacques’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev