This patch adds the ability to update existing node reference fields.

If you have a lot of existing nodes with corresponding node references that aren't in sync there is currently no way to do so.
You have to remove the reference, save the node, add the reference again and save the node again and then it works.

So this adds a settings tab that allows you to do bulk cnr processing of nodes by content type.

I updated 3500 nodes in just under 30 seconds so it doesn't take that long either.

Patch is against 6.x-3.3

- Also, having no dev branches is a bit annoying for rolling patches as I can't guarantee that the patch will apply cleanly to the latest code without going into cvs to get it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

domidc’s picture

Assigned: Unassigned » domidc
Category: feature » task

Test patch and include feature in next release.

tavaressimon’s picture

Tried applying the patch to the latest version.

I get:

Hunk #1 FAILED at 11.
Hunk #2 FAILED at 150.
Hunk #3 FAILED at 244.

Am I doing something wrong?

sethcohn’s picture

Status: Needs review » Needs work

This should use Batch API... doing this is bad:

 // Set the time limit to zero so we don't time out.
 set_time_limit(0);

Sites with 3500 nodes might take 30 seconds, but sites with 350,000 nodes(and having to node load all of them) would be taking 3000 seconds = ~50 minutes.

Agileware’s picture

Agreed. Will do this if I get some time soon.

Anonymous’s picture

Wow thanks! I was looking for this a while back. Good job, this should definitely be part of the module's features. Maybe even include a Status Report check "Your node references are not in sync".

joaomachado’s picture

I would like this feature as well...this is a great module!

esclapes’s picture

I don't know if this is the place to ask for this, but it would be great if this patch could check if referenced node exist and remove nodereference when it does not.

I used views bulk operations to delete all nodes for a given node-type, but nodereference are still showing in the corresponding node-type.

Nodereference show only [nid:XXX] but node/XXX does not exist.

I will re-import my content (which create cnr without problems) and update again to see if this takes out the outdated references.

esclapes’s picture

No, after re-importing content and updated, the deleted nodes are still referenced. They are not shown in my view, so this is not a big problem, but it would still be great to have that added if possible

DanGarthwaite’s picture

Patch WFM. Thank you.

Agileware’s picture

Category: task » feature
Status: Needs work » Needs review
FileSize
10.99 KB

Here is the original patch modified to use batch processing.

On the update form an additional field allows you to choose how many nodes are processed per batch.

I have tested with 2500ish nodes 50 at a time and all seems to have gone well.

ashedryden’s picture

Applied patch and it worked for me. Thanks!

j0nathan’s picture

Applied patch in #10 on version 3.3 and it works. Thank you.

+1 for the idea in #5 : include a Status Report check "Your node references are not in sync".

momper’s picture

subscribe

isaac.niebeling’s picture

Patch from #10 worked for me.

amonika’s picture

I was having the same problem as tavaressimon. Using >patch < cnr_update_existing.patch instead of >patch corresponding_node_references.module < cnr_update_existing.patch solved that.

The patch is working for me.

Agileware’s picture

If you put the patch from #10 in the cnr module directory it applies with:

patch -p0 < cnr-update_existing-805244-10.patch

For information on this see http://drupal.org/patch/apply

domidc’s picture

Status: Needs review » Fixed

This patch is included in 6.4 release which is currently in dev

Status: Fixed » Closed (fixed)

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