I wanted to integrate Feeds with the UUID module, using Parent Feed UUIDs to see if Nodes existed already. I am seemingly able to do that via:
hook_feeds_node_processor_targets_alter()
..I could add a new target like so:

'uuid' => array(
        'name' => t('UUID'),
        'description' => t('The external UUID of the node. May be unique.'),
        'optional_unique' => TRUE,
      ),

BUT I cannot check (or process) whether that item is Unique. That is done via "protected function existingItemId()". It is both protected and does not have a hook attached to it. Is there a reason for this? It would help me greatly.

Or maybe I'm asking for something I don't understand? Since my project is time-sensitive, for now I will attempt to hack the module and see if we can get a better fix implemented.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

btopro’s picture

were you able to find a resolution to this?

Offlein’s picture

Yeah, eh, I was in dire straits, as I said, so I just hacked [with the feeds module directory] "/plugins/FeedsNodeProcessor.inc" to have a case for UUID.

After

case 'guid':
          $nid = db_result(db_query("SELECT nid FROM {feeds_node_item} WHERE feed_nid = %d AND id = '%s' AND guid = '%s'", $source->feed_nid, $source->id, $value));
          break;

I put..

case 'uuid':
          $nid = db_result(db_query("SELECT nid FROM {uuid_node} WHERE uuid = '%s'", $value));
          break;

And, instead of hooking into hook_feeds_node_processor_targets as mentioned above, hacked the "public function getMappingTargets()" section to do the same thing.

I'm afraid I don't have time to cut a patch that would do what we want appropriately, but what you'd probably want to do is modify the existingItemId() function to implement something like: drupal_alter('feeds_node_processor_targets_processor_callback', $functions);, that generates an array with keys corresponding to targets (such as "nid", or "url", or in this case "uuid") and whose values correspond to a callback function that would process the target.

Then any module could add targets and a function to process them.

btopro’s picture

hmm... interesting. I have UUIDs importing correctly as long as I have the GUID set to a UUID on import. The only issue I'm running into now is that you can't update things after the fact.

Offlein’s picture

The GUID is unique to items imported via Feeds (if that makes sense).

So you have Site A disseminating a data Feed of some sort -- in my case, and seemingly yours, it's a feed of Drupal node datas -- one of whose data values is a UUID (as created by the Drupal UUID module).

Drupal Site B is passed the feed from Site A and, with your method, sets the "Feeds" module's GUID to Site A's node's UUID.

..That should work - your GUID can be anything. In fact, if Site B reimports Site A's feed later, as long as the nodes retain the same UUID, Feeds module should sync Site A Drupal UUIDs to the same Site B Feeds Module GUIDs, you dig? It would tell what nodes are the same and update instead of duplicating them (as long as Feeds is set to the, I think it's called, "Update nodes (takes longer)" option). Perhaps that's really what's causing your issue?

Why isn't your method good enough for me? Because I have a Parent site and a Child site which share the same codebase and share the same origin database. I need to be importing nodes to Site B based on Site A's UUIDs and then RETAINING the same UUIDs across Site B. That way, if nodes that existed in Site B [before the database branched off of A to form B] are updated on Site A, their updates propagate retrospectively to Site B.

btopro’s picture

No that makes perfect sense, seems to be very similar to what I'm going for as well. https://drupal.psu.edu/blog/305 is a video about the portability aspect of Site A and Site B having branched content yet being able to synchronize via feeds.

My current problem is that the retroactive updating functionality recognizes that the nodes are the same but then it doesn't update the fields it just ignores it. So I get no duplicates but I also don't get a true synchronization (new title says to be "Cool stuff" yet current title is "stuff", it ignores the title update). Maybe I have to associate it to a node type or something but the stand-alone form doesn't seem to do anything unless I need a node id mapper or something in order to let it realize that it can load the node and update these things.

core44’s picture

Hi offllein, Its been a while since you posted this temporary fix. Did you ever find a cleaner way to check UUID against UUID. Ive just done the same hack but for drupal 7 and it works fine but im not keen on having hacked modules of course.

My use case is a network of sites that share central taxonomy vocabularies. Its imperative my terms on all sites keep the same UUID to avoid duplicates and track reference counts. I was hoping that since october 2011 there might have been some sort of fix/work around rather than a hack but I cant seem to find anything.

msmithcti’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev
Status: Active » Needs review
FileSize
1.5 KB

I'm having the same trouble trying to add integration for UUID. Attached it a patch that provides an additional hook in the most generic way to allow existing entities to be loaded for any entity type.

@see #1800730: Include UUID mapper for Feeds module for my patch combining this with the UUID module.

msmithcti’s picture

Added entry for new hook into feeds_hook_info().

twistor’s picture

Status: Needs review » Needs work

This is great.

I'm wondering if we shouldn't iterate over module_implements() directly so that we can break on the first value returned. Also, module_invoke() will return an array of values if multiple are returned.

twistor’s picture

Issue summary: View changes
Status: Needs work » Closed (duplicate)