API page: http://api.drupal.org/api/drupal/includes%21form.inc/group/batch/7

Enter a descriptive title (above) relating to Batch operations, then describe the problem you have found:

 *   $node = node_load(array('uid' => $uid, 'type' => $type));

node_load() does not work this way any more!

Comments

jhodgdon’s picture

Hm, good point. I'm not sure it's a Novice issue to fix it, but maybe... I guess we'd need to do a query to find a node authored by the given user, of the given type, presumably via EntityFieldQuery?

The Drupal 8 version uses the entity_load_multiple_by_properties() function, but we don't have that in 7...

joachim’s picture

> I guess we'd need to do a query to find a node authored by the given user, of the given type, presumably via EntityFieldQuery?

Oh yeah you're right. I was just thinking it would be case of changing the params to node_load(), but I didn't properly read what the code was doing. I wonder if the example should be simplified instead?

jhodgdon’s picture

There's another error on the page too: the "finished" callback has one name in the $batch definition but the function name is something else (this is noted in one of the comments below).

The whole thing really ought to be documented with our new callbacks anywy... didn't we make an issue on that?

And... really I have no idea what that example function is supposed to illustrate. Can't we find a more realistic example?

joachim’s picture

Issue tags: -Novice

Untagging.

Berdir’s picture

If we change it to a better example, we should probably update 8.x too. I just updated at some point when I noticed this in 8.x with something that's technically correct, but it remains weird :)