Hi guys,

Based on

I've patched UUID features to export:

  1. Entity collections
  2. Users
  3. Taxonomy terms
  4. Nodequeue items (you will need Features Extra).

With this patch the next references will be handled:

  1. From Entity Reference module
  2. Taxonomy term reference
  3. Field collection reference
  4. $uid property in nodes.

It still has some issues with OVERRIDEN state in uuid_node and uuid_user. Also there are hacks to rebuild all the references within at least 2 revert actions. During the first import exceptions about missing references are possible and ignored, but all of them will be normally repaired during the second.

CommentFileSizeAuthor
#44 uuid_features-users-etc-integration-1973770-44.patch51.94 KBdas-peter
#44 interdiff-1973770-43-44-do-not-test.diff641 bytesdas-peter
#43 uuid_features-users-etc-integration-1973770-43.patch51.94 KBdas-peter
#43 interdiff-1973770-42-43-do-not-test.diff3.95 KBdas-peter
#42 uuid_features-users-etc-integration-1973770-42.patch52.22 KBdas-peter
#42 interdiff-1973770-41-42-do-not-test.diff3.31 KBdas-peter
#41 uuid_features-users-etc-integration-1973770-41.patch51.56 KBdas-peter
#41 interdiff-1973770-38-41-do-not-test.diff977 bytesdas-peter
#38 uuid_features-users-etc-integration-1973770-38.patch51.4 KBdas-peter
#38 interdiff-1973770-37-38-do-not-test.diff4.97 KBdas-peter
#37 uuid_features-users-etc-integration-1973770-37.patch49.45 KBdas-peter
#37 interdiff-1973770-36-37-do-not-test.diff4.79 KBdas-peter
#36 interdiff-1973770-35-36-no-spaces-do-not-test.diff32.22 KBdas-peter
#36 interdiff-1973770-35-36-do-not-test.diff60.64 KBdas-peter
#36 uuid_features-users-etc-integration-1973770-36.patch48.45 KBdas-peter
#35 uuid_features-users-etc-integration-1973770-35.patch44.2 KBmsmithcti
#34 uuid_features-users-etc-integration-1973770-34.patch44.2 KBmsmithcti
#29 uuid_features-users-etc-integration-1973770-29.patch44.01 KBjustanothermark
#28 uuid_features.code_.1973770-28.patch44.2 KBclaudiu.cristea
#28 interdiff.txt734 bytesclaudiu.cristea
#26 uuid_features.code_.1973770-26.patch44.17 KBclaudiu.cristea
#26 interdiff.txt1.86 KBclaudiu.cristea
#23 uuid_features-1973770-22.patch88.24 KBmikeharty
#22 uuid_features-1973770-22.patch88.24 KBmikeharty
#17 uuid_features-1973770-17.patch43.9 KBdubois
#16 uuid_features-1973770-13.patch43.55 KBk0teg
#12 uuid_features-1973770-12.patch83.16 KBk0teg
#14 uuid_features-1973770-13.patch43.73 KBk0teg
#11 uuid_features-1973770-6.patch38.18 KBrobinvdvleuten
#10 uuid_features-references-1973770-5.patch18.97 KBrobinvdvleuten
#9 uuid_features-references-1973770-4.patch18.99 KBrobinvdvleuten
#8 uuid_features-references-1973770-do-not-test.patch39.5 KBk0teg
#3 uuid_features-1973770-3.patch35.33 KBk0teg
#1 uuid_features-1973770-1.patch36.25 KBk0teg

Comments

k0teg’s picture

StatusFileSize
new36.25 KB

Here is the patch.

Status: Needs review » Needs work

The last submitted patch, uuid_features-1973770-1.patch, failed testing.

k0teg’s picture

StatusFileSize
new35.33 KB

Reformatted the patch.

k0teg’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, uuid_features-1973770-3.patch, failed testing.

k0teg’s picture

Status: Needs work » Needs review

#3: uuid_features-1973770-3.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, uuid_features-1973770-3.patch, failed testing.

k0teg’s picture

Status: Needs work » Needs review
StatusFileSize
new39.5 KB

Here is the patch with a little clean-up.

robinvdvleuten’s picture

StatusFileSize
new18.99 KB

When I apply the patch, I get some errors about an undefined index of the node types array. I've added the patch which fixes this.

robinvdvleuten’s picture

StatusFileSize
new18.97 KB

I also made the labels of the field_collection more user-friendly. Instead of displaying an UUID, it now displays the type and the label of the collection.

robinvdvleuten’s picture

StatusFileSize
new38.18 KB

Oops, added the same patch twice. This is the one with the field_collection label fixes.

k0teg’s picture

StatusFileSize
new83.16 KB

Here is a new patch (it is merged with #11 - https://drupal.org/node/1973770#comment-7367838).

The patch includes:

  • Handing of files and images in field collections.
  • Import/Export of Current Search Block configurations.
  • Minor code refactoring.

Status: Needs review » Needs work

The last submitted patch, uuid_features-1973770-12.patch, failed testing.

k0teg’s picture

Status: Needs work » Needs review
StatusFileSize
new43.73 KB

Here is the fixed patch.

Status: Needs review » Needs work

The last submitted patch, uuid_features-1973770-13.patch, failed testing.

k0teg’s picture

Status: Needs work » Needs review
StatusFileSize
new43.55 KB

Another try :)

k0teg’s picture

Issue summary: View changes

Fixed typos.

k0teg’s picture

Issue summary: View changes

Removed 1 sentence.

dubois’s picture

StatusFileSize
new43.9 KB

Sharing a few tweaks to patch in #16.

  1. Make uuid_features_entity_node_types consistent when load from variable storage or function. Adjust later code to expect string not object.
  2. Disable all types when variable not set.
saltednut’s picture

#17: uuid_features-1973770-17.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, uuid_features-1973770-17.patch, failed testing.

saltednut’s picture

Looks like this just needs a reroll and probably some code review wouldn't hurt - really love what you're doing here @k0teg

boobaa’s picture

See also: #1932320: Add support for entity references as it may have some other useful information.

mikeharty’s picture

StatusFileSize
new88.24 KB

Re-rolled patch. (Git gave me some whitespace warnings on apply, not sure why, I followed these instructions exactly: https://drupal.org/patch/reroll)

mikeharty’s picture

Status: Needs work » Needs review
StatusFileSize
new88.24 KB

Fixing status

claudiu.cristea’s picture

Status: Needs review » Needs work

PHP 5.4 is yelling:

Strict warning: Only variables should be passed by reference in user_uuid_node_features_export_render_alter() (line 11 of sites/all/modules/uuid_features/includes/modules/user.inc).
+++ b/includes/modules/user.inc
@@ -0,0 +1,34 @@
+  $uuid = reset(entity_get_uuid_by_id('user', array($node->uid)));

Better replace this line with:

  $uuids = entity_get_uuid_by_id('user', array($node->uid));
  $uuid = reset($uuids);

I tested the field collection and looks great. Thank you :)

claudiu.cristea’s picture

There's also a BIG problem with the patch from #23: Nodes (uuid_node) are disappearing from interface. Seed that are no more discovered.

claudiu.cristea’s picture

StatusFileSize
new1.86 KB
new44.17 KB
+++ b/includes/uuid_node.features.inc
@@ -10,18 +10,28 @@
-  $types = node_type_get_names();
+  $types = variable_get('uuid_features_entity_node_types', array_fill_keys(array_keys(node_type_get_names()),0)); // Could just leave this empty.
+  $types = array_filter($types); // Only include types that user has selected (ie. set a non zero value).
+  if (empty($types)) {
+    return $options;
+  }
+
+  $query = db_select('node', 'n');
+  $query->fields('n', array('nid', 'title', 'type', 'uuid'))
+    ->condition('type', array_keys($types))
+    ->orderBy('type')
+    ->orderBy('title');
+  $nodes = $query->execute()->fetchAll();
...
-  $query = 'SELECT n.nid, n.title, n.type, n.uuid
-    FROM {node} n ORDER BY n.type, n.title ASC';
-  $results = db_query($query);
-  foreach ($results as $node) {

This change is bad because every time will end with an empty $type and will exit prematurely in with an empty array.

Returning all node-types nodes is not a bad option while already used nodes are coloured with red.

Here's a patch based on #23 and addressing #24 and this issue.

claudiu.cristea’s picture

Status: Needs work » Needs review
claudiu.cristea’s picture

StatusFileSize
new734 bytes
new44.2 KB

Fixed another PHP 5.4 notice. See interdiff.txt.

claudiu.cristea’s picture

Issue summary: View changes

Cleaned up the original message.

justanothermark’s picture

Issue summary: View changes
StatusFileSize
new44.01 KB

Rerolled patch #28 so that it applies to 7.x-1.x. Functionality only tested for Entity Reference field (that works) and haven't reviewed the code itself to see if anything should change based on changes to 7.x-1.x since #28 was created.

mraichelson’s picture

The exported content for field_collection items is getting mangled a bit. Looks like it's getting URL-encoded, then having escaping slashes applied multiple times (and more and more if you start to update things after trying to move them around).

  $field_collections[] = array(
    'field_name' => 'field_my_demo_field',
    'default_revision' => '1',
    'archived' => '0',
    'uuid' => 'd01cf875-d7ff-4c00-a3a5-868ef9176740',
    'field_collection_sub_title' => array(
      'und' => array(
        0 => array(
          'value' => 'Text field content',
          'format' => NULL,
          'safe_value' => 'Text field content',
        ),
      ),
    ),
    'field_collection_icon' => array(),
    'field_collection_text' => array(
      'und' => array(
        0 => array(
          'value' => '\\u003Cul\\u003E\\u003Cli\\u003EOnline Reviews\\u003C\\/li\\u003E\\u003Cli\\u003E\\u003Ca href=\\u0022\\/small-business\\/learning-center\\/local-visibility\\u0022\\u003ELocal Visibility\\u003C\\/a\\u003E\\u003C\\/li\\u003E\\u003Cli\\u003ESocial Media\\u003C\\/li\\u003E\\u003C\\/ul\\u003E',
          'format' => 'full_html',
          'safe_value' => '\\u003Cul\\u003E\\u003Cli\\u003EOnline Reviews\\u003C\\/li\\u003E\\n\\u003Cli\\u003E\\u003Ca href=\\u0022\\/small-business\\/learning-center\\/local-visibility\\u0022\\u003ELocal Visibility\\u003C\\/a\\u003E\\u003C\\/li\\u003E\\n\\u003Cli\\u003ESocial Media\\u003C\\/li\\u003E\\n\\u003C\\/ul\\u003E',
        ),
      ),
    ),
    'rdf_mapping' => array(),
    'url_alias' => array(),
  );

Going to try seeing if I can figure anything out for this.

mraichelson’s picture

I don't believe this is a solution that really scales out but as a temporary workaround I've posted a gist here that has modified code for uuid_field_collection.features.inc (lines 79-87 are new code, the rest is the resulting state of things after applying patch #29).

I'm in a major time-crunch right now but will try looking for a more robust answer and creating a patch later.

byronveale’s picture

Status: Needs review » Needs work

Applied patch 29 to 7.x-1.x branch. Unfortunately, it does not include the functionality I'm looking for, which is the ability to include taxonomy terms in a feature (as outlined in the original post). As such, I am updating the status to "needs work".

This functionality was present in 7.x-1.0-alpha3, but disappeared in latest version, 7.x-1.0-alpha4.

I am curious as to why exporting taxonomy terms was listed as part of this patch, as it looks as if alpha3 was released before this issue was opened (released 30 January 2013). But that just may be me…

Here's a question from a module-creating-noob: would it be worthwhile to compare the code from alpha3 with the latest version, to try to see where the taxonomy term export code was?

Thanks for everyone's efforts with this.

byronveale’s picture

Status: Needs work » Needs review

Okay, sorry about that: alpha4 introduced a settings page at /admin/config/content/uuid_features that I had never previously discovered. In it are options to include exporting taxonomy terms. So resetting this back to "needs review".

(Whaddaya know, it _was_ useful to compare the code between alpha3 and alpha4, I saw the "hook_menu" function, that told me to go look for a page!)

msmithcti’s picture

The variable being get in uuid_features_file_field_export() doesn't match those set in the settings form in #29. This patch fixes that.

msmithcti’s picture

Now realised that the above exports correctly but on reverting, the images aren't correctly imported. This is because uuid_features_file_field_import() is used instead of uuid_features_file_field_export() in uuid_field_collection_features_rebuild().

This patch fixes the above.

das-peter’s picture

Pretty impressive patch! Thanks for all the hard work.
I just started using it in a new project and stumbled over some issues.
I started overhauling the patch and made lot's of changed. However, the main logic is still the same - I've mostly changed the hooks, coding standards, missing docs, missing removes of legacy code.

  • There's no need to have node/user whatever entity specific alter hooks for dealing with fields. As soon as something is an entity it can has fields and its handling can / should be unified. Added new hooks:
    • hook_uuid_entity_features_export_alter()
    • hook_uuid_entity_features_export_render_alter()
    • hook_uuid_entity_features_rebuild_alter()

    The field handler now use those hooks instead node/user/term specific ones.

  • uuid_node_features_export_render()/ function uuid_node_features_rebuild() had some code hunks that seemed to interfere with the new code (// Export taxonomy_term_reference with its UUID.) - removed
  • The patch introduced unnecessary form elements in uuid_features_settings() - removed
  • Missing API documentation of UUID features - fixed
  • A lot of coding standard violations - fixed

Reviews would be very appreciated. I did testing but definitely didn't cover all scenarios.

Edit: fixed typo

das-peter’s picture

Next patch:

  • Fixed entityreference_uuid_node_features_rebuild_alter(): it's now entityreference_uuid_entity_features_rebuild_alter
  • Run the node rebuild process multiple times if necessary:
    If a node couldn't be saved it's likely due to missing references. Multiple runs will build up the targets of those references and resolve the dependencies. We could make the maximal nesting level configurable - it's set to 5 now.
das-peter’s picture

Next patch:

  • Added hook_uuid_entity_features_export_render() for other entity types: bean, field_collection
  • Fixed hook_uuid_entity_features_export_render() invocation for taxonomy terms
  • Fixed hook_uuid_entity_features_export_render() / hook_uuid_user_features_export_render() invocation for users
  • Ensured the $export object for the hook invocation is actually a clone! Had "cache poisoning" with user and enabled entitycache.
sirclickalot’s picture

@das-peter, I'm a little confused here and could use some guidance because while I completely understand your point about unifying via the fact that users, roles etc. are indeed all entities, the patch in #37 patch (uuid_features-users-etc-integration-1973770-37.patch) appears to relate to in include 'includes/modules/entityreference.inc' which does not appear to be part of 7.x-1.0-alpha4?

Ultimately I'm looking to be able to include the following on my Feature...

Taxonomies - already handled by Features
Taxonomy terms - handled via UUID Features Integration
Nodes - handled via UUID Features Integration
Roles - handled via UUID Features Integration
Users - HOPEFULLY handled by your patch!

Thank you

das-peter’s picture

@SirClickALot Hope you'll find time to give the patch a review :)
The file includes/modules/entityreference.inc is newly created by the patch - you can see that in the patch here:

--- /dev/null
+++ b/includes/modules/entityreference.inc

/dev/null means the file doesn't yet exist.

Users - HOPEFULLY handled by your patch!

This issues doesn't specifically relate to users but many other things - check the issue summary.

which does not appear to be part of 7.x-1.0-alpha4?

Never patch against a release but always against HEAD of the git repo.

das-peter’s picture

Next patch:

  • Handling of node users was buggy. Fixed that.
das-peter’s picture

StatusFileSize
new3.31 KB
new52.22 KB

Next round:

  • There was an issue left with the entity bundle selection - fixed
  • Minor enhancements to avoid override state

Damn I really should stop adding more cleanup :| But there's already a entity translation integration just waiting to be integrated ;)

das-peter’s picture

Next patch:

  • Found some unnecessary adjustments of uuid_node_features_export_options()
  • Added missing hook invocation in uuid_bean_features_export_options()
  • Added missing condition in uuid_field_collection_features_export_options()
das-peter’s picture

StatusFileSize
new641 bytes
new51.94 KB

Fixed wrong function call.

  • Commit 8a8514d on 7.x-1.x authored by k0teg, committed by das-peter:
    Issue #1973770 by das-peter, k0teg, claudiu.cristea, robinvdvleuten,...
das-peter’s picture

Assigned: k0teg » Unassigned
Status: Needs review » Fixed

Bold move on my side: After talking to Jeffrey and he gave me a) committ-permissions and b) a go for the patch here we go:

  • Tested several scenarios today including files export.
  • Did another review of the code - fixed some minor coding standard issues.
  • Committed & pushed the patch!

Credits went to k0teg - as I understand he was the initiator :)
Thanks to all participants!

Status: Fixed » Closed (fixed)

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