[wp-trac] [WordPress Trac] #6492: Guids No Longer Have Permalink Format

WordPress Trac wp-trac at lists.automattic.com
Thu Sep 2 22:20:42 UTC 2010


#6492: Guids No Longer Have Permalink Format
-------------------------------------+--------------------------------------
 Reporter:  brianwhite               |        Owner:  anonymous      
     Type:  enhancement              |       Status:  reopened       
 Priority:  normal                   |    Milestone:  Awaiting Review
Component:  General                  |      Version:  2.5            
 Severity:  trivial                  |   Resolution:                 
 Keywords:  has-patch guid featured  |  
-------------------------------------+--------------------------------------

Comment(by Otto42):

 Might be worth using a v3 UUID in the URL Namespace, as defined by RFC
 4122. Here's some easy code to do that, just pass it a valid URL (like the
 permalink):

 {{{
 function uuid_v3_url($url) {
         $nhex = '6ba7b8119dad11d180b400c04fd430c8'; // Namespace_URL as
 defined in RFC 4122 (6ba7b811-9dad-11d1-80b4-00c04fd430c8)
         $nstr = '';
         for($i = 0; $i < strlen($nhex); $i+=2) {
                 $nstr .= chr(hexdec($nhex[$i].$nhex[$i+1]));
         }
         var_dump($nstr);
         $hash = md5($nstr . $name);
         $uuid = sprintf('%08s-%04s-%04x-%04x-%12s',
                 substr($hash, 0, 8),
                 substr($hash, 8, 4),
                 (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000,
                 (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000,
                 substr($hash, 20, 12)
         );
         return $uuid;
 }
 }}}

 Example usage:
 echo uuid_v3_url('http://example.com');

 This form of UUID is based on the uniqueness of the URL. Giving it the
 same URL will give you the same result every time.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/6492#comment:48>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list