Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
entity system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
22 Nov 2012 at 14:34 UTC
Updated:
16 Oct 2014 at 12:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
skwashd commentedComment #2
skwashd commentedUpdating status.
Comment #3
klausiThis should use late static binding per default, so use "static" instead of "self".
Why are the start and end characters "^" and "$" not part of the pattern? They are part of the regex, right?
Also: the "/" delimiter should be escaped in case the pattern contains slashes as well.
Comment #4
skwashd commentedI thought about this, but given UUIDs are defined in RFC 4122 the value shouldn't be overridden by sub classes.
Because then the pattern can only be used for matching a complete UUID and nothing else. The whole idea of this is to allow contrib to use the pattern for matching UUIDs in larger strings. If I include the '^' and '$', then you can't do something like this:
if (preg_match('#^uuid/node/(' . Uuid::VALID_PATTERN . ')$#', $url, $m)) { /* do stuff */ }.Escaping the "/" will break the regex. If the pattern did contain slashes, which is shouldn't as per the RFC, then the slashes in the pattern should be escaped not the delimiter.
Personally I prefer using "#" over "/" as a delimiter for web stuff these days as it is less likely to require escaping in patterns. The existing code uses slashes as the delimiters, so I'm leaving them as they are.
Setting back to needs review. Hopefully the test bot can clone properly this time.
Comment #5
skwashd commented#1: drupal-1847932-uuid-pattern-class-const.patch queued for re-testing.
Comment #6
skwashd commentedThe tests passed, but the status hasn't updated here. http://qa.drupal.org/pifr/test/390413
Comment #9
skwashd commentedRerolled patch and attached interdiff.
Comment #10
klausiOk, the constant seems to be a better idea anyway. Looks good!
Comment #11
alexpottCommitted 393fccc and pushed to 8.0.x. Thanks!