Updated: Comment #N
Problem/Motivation
Modules depending on CTools, like Panels, need UUIDs. Those modules should not each provide their own implementation.
Proposed resolution
Add UUID generation directly to CTools, as it is common library for many modules.
Remaining tasks
Decide if this should be a full-fledged CTools subsystem using ctools_include()
Decide if this should replicate the PECL/COM fallback code
User interface changes
N/A
API changes
API addition only
Original report by @japerry
From Comment #118 in https://drupal.org/node/1277908#comment-7216356
The following patch adds support for creating UUIDs so panels can utilize the UUIDs generated from the i18n work being done.
This patch is already RTBC in #1277908: Introduce UUIDs onto panes & displays for better exportability & features compatibility and used in production for many of those using distributions.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 2155825-ctools-uuid-support-7.patch | 3.77 KB | japerry |
Comments
Comment #1
tim.plunkettWhy wouldn't the uuid.module be used instead?
Comment #2
tim.plunkettAlso, 7216356 is not a node ID. Where is this RTBC? Patch authors shouldn't RTBC their own patches.
Comment #3
japerrySorry, updated the URL to reflect the issue ID. they both go the same place, I dunno why its linking as a comment.
I'm posting this patch as a proxy from that issue, because its already been reviewed and is in wide use by those using panels and i18n.
The UUID functionality this provides is not the same as the UUID.module. The UUID module puts UUIDs into all entities. This patch provides an alternative to the PID method of exporting features, which is needed for i18n panels support.
Comment #4
japerryComment #5
japerryComment #6
tim.plunkettMy question about uuid.module was not about the entity functionality, but uuid's uuid.inc.
It has a wrapper function uuid_generate(), which detemines if PECL or COM can be used, and otherwise falls back to PHP.
It also borrowed from the same code, except it was found to be buggy. See #1596350: _uuid_generate_php() does not create valid UUID v4 UUIDs., if we decide to duplicate this code, we should duplicate the right code.
We don't need to include this.
Comment #7
japerryI think you're right about the uuid.inc file. I've stripped out what we don't need and included the basic functionality. This patch also checks to see not only if UUID is enabled but if PECL is enabled as well. In testing it worked with both use cases of each enabled or disabled combinations.
I like the idea of checking to see if UUID is enabled, and if so, use its code. By using an include file, we can lessen the chances of modules incorrectly calling UUID helper functions when they aren't using ctools.
Comment #8
tim.plunkettLooks pretty good to me, but we should use ctools_include() for our files.
Comment #9
jweowu commentedAll the different generators do make me slightly uneasy. In theory they're all interchangeable, but I'm somewhat inclined to suggest checking something like
variable_get('ctools_uuid_generator')first and foremost, so that people can hard-code the one they want to use in their settings file if necessary.For the PECL generator, do we want UUID_TYPE_RANDOM rather than UUID_TYPE_DEFAULT, for consistency with
_uuid_generate_php()? (I'm assuming the RANDOM type is UUID v4)I also see that you're checking for the incompatible php5-uuid package with the test for uuid_make() (https://answers.launchpad.net/ubuntu/+source/ossp-uuid/+question/87216), but we should add a comment to explain that.
(Edit: Or are my compatibility & version concerns unfounded? I suppose if all 'versions' of UUID are validated by the same function, perhaps it doesn't actually matter which version is being generated? I haven't looked into this at all. Comments, anyone? The hard-coded version bits would certainly negate the possibility of collisions between UUIDs of different versions, so perhaps there isn't a problem...)
(Edit 2: deleted comment about static caching, as that was already in the patch; apparently I'm blind.)
Comment #10
jweowu commentedCross-referencing with #2179475: Clean up _uuid_generate_php().
(I wanted to clean it up for ctools, but it seemed best to post in the uuid queue).
Comment #11
japerryHi there! thanks for the comments.
For now, I want to release the UUID version of ctools that is code-consistent with the UUID module. If the patch in #2179475: Clean up _uuid_generate_php() gets pushed upstream to UUID, then we could include it here at a later date.
Revised the code to include ctools_include per #8
Comment #12
japerryFixed! If the UUID module changes, we'll have to come revisit this in the future.. but for now, enjoy UUIDs in ctools!
http://drupalcode.org/project/ctools.git/commit/d760d02
Comment #13
barrapontoSince CTools is everywhere thanks to Views depending on it, can't we have UUID depend on CTools and leave the UUID only in CTools? Duplicating efforts suck.
Comment #14
tim.plunkett#13, you'd have to open an issue against the UUID module for that...
Comment #15
dsnopekThe committed patch breaks Panopoly install:
What I think is happening, is that CTools is installed (and includes uuid.inc because
module_exists('uuid') == FALSE) and then UUID is installed, which redeclares _uuid_generate_com().I'm not sure where the fix should be yet, if it should be in Panopoly or Ctools. Once I do, I'll make a new issue in the appropriate queue.
Comment #16
dsnopekFYI, we ended up addressing this in Panopoly by reordering the dependencies in the .info file:
#2186405: Revert: Installing 'ctools' (1.4) before 'uuid' during Panopoly install causes fatal error
But this incompatibility between 'ctools' and 'uuid' inside of install profiles should probably be documented somewhere!
Comment #17
barrapontoIt should be fixed, methinks.
Comment #18
jweowu commentedI feel there's no good reason for Ctools' copies of those private functions to still use the UUID name-spacing. That's not good practice.
Let's change them, and thus guarantee there won't be conflicts.
Comment #19
dsnopekFYI, @japerry did just that in this commit: http://drupalcode.org/project/ctools.git/commitdiff/f16fce929bc0dec36797...
Problem solved!