From 9cca14d6881277d4eea1f8ebf2859ce4a3233b67 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Tue, 3 Aug 2010 11:58:03 -0400 Subject: [PATCH] Clean up uid/randomid/guid changes. Use Horde_Support_Randomid:: for local object ids when we need a smaller value, Use Horde_Support_Guid:: for object uids (not Horde_Support_Uuid:: since these need to be globally unique). Use Horde_Support_Uuid for share ids and other cases where we can use a larger value. I still question the need for even the Randomid in places like internal object ids, when integer autoincrement fields would suffice. --- kronolith/lib/Driver/Sql.php | 2 +- nag/lib/Driver.php | 2 +- nag/lib/Driver/Kolab.php | 4 ++-- nag/lib/Driver/Sql.php | 6 +++--- turba/lib/Driver.php | 2 +- turba/lib/Driver/Sql.php | 2 +- turba/scripts/upgrades/public_to_horde_share.php | 2 +- turba/search.php | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/kronolith/lib/Driver/Sql.php b/kronolith/lib/Driver/Sql.php index ead9b6a9e..c1c9ce612 100644 --- a/kronolith/lib/Driver/Sql.php +++ b/kronolith/lib/Driver/Sql.php @@ -607,7 +607,7 @@ class Kronolith_Driver_Sql extends Kronolith_Driver if ($event->id) { $id = $event->id; } else { - $id = strval(new Horde_Support_Uuid); + $id = strval(new Horde_Support_Randomid); $event->id = $id; } diff --git a/nag/lib/Driver.php b/nag/lib/Driver.php index 5e773111b..13f87a516 100644 --- a/nag/lib/Driver.php +++ b/nag/lib/Driver.php @@ -197,7 +197,7 @@ class Nag_Driver $owner = null, $assignee = null) { if (is_null($uid)) { - $uid = strval(new Horde_Support_Uuid()); + $uid = strval(new Horde_Support_Guid()); } if (is_null($owner)) { $owner = $GLOBALS['registry']->getAuth(); diff --git a/nag/lib/Driver/Kolab.php b/nag/lib/Driver/Kolab.php index 035419bfd..6c8202e65 100644 --- a/nag/lib/Driver/Kolab.php +++ b/nag/lib/Driver/Kolab.php @@ -436,7 +436,7 @@ class Nag_Driver_kolab_wrapper_old extends Nag_Driver_kolab_wrapper { { // Usually provided by the generic Driver class if ($uid !== null) { - $uid = strval(new Horde_Support_Uuid()); + $uid = strval(new Horde_Support_Guid()); } // Load the object into the kolab driver @@ -785,7 +785,7 @@ class Nag_Driver_kolab_wrapper_new extends Nag_Driver_kolab_wrapper { $completed_date = null) { if (empty($uid)) { - $task_uid = strval(new Horde_Support_Uuid()); + $task_uid = strval(new Horde_Support_Guid()); $old_uid = null; } else { list($task_uid, $tasklist) = $this->_splitId($uid); diff --git a/nag/lib/Driver/Sql.php b/nag/lib/Driver/Sql.php index b0f11853d..5fa9e77ce 100644 --- a/nag/lib/Driver/Sql.php +++ b/nag/lib/Driver/Sql.php @@ -162,9 +162,9 @@ class Nag_Driver_Sql extends Nag_Driver { $methods = null, $uid = null, $parent = '', $private = false, $owner = null, $assignee = null) { - $taskId = strval(new Horde_Support_Uuid()); + $taskId = strval(new Horde_Support_Randomid()); if ($uid === null) { - $uid = strval(new Horde_Support_Uuid()); + $uid = strval(new Horde_Support_Guid()); } $query = sprintf( @@ -528,7 +528,7 @@ class Nag_Driver_Sql extends Nag_Driver { { /* Make sure tasks always have a UID. */ if (empty($row['task_uid'])) { - $row['task_uid'] = strval(new Horde_Support_Uuid()); + $row['task_uid'] = strval(new Horde_Support_Guid()); $query = 'UPDATE ' . $this->_params['table'] . ' SET task_uid = ?' . diff --git a/turba/lib/Driver.php b/turba/lib/Driver.php index ce912ca47..b6c198149 100644 --- a/turba/lib/Driver.php +++ b/turba/lib/Driver.php @@ -789,7 +789,7 @@ class Turba_Driver } if (!isset($attributes['__uid'])) { - $attributes['__uid'] = strval(new Horde_Support_Uuid()); + $attributes['__uid'] = strval(new Horde_Support_Randomid()); } $key = $attributes['__key'] = $this->_makeKey($this->toDriverKeys($attributes)); diff --git a/turba/lib/Driver/Sql.php b/turba/lib/Driver/Sql.php index b23bdfc3a..113ec13bb 100644 --- a/turba/lib/Driver/Sql.php +++ b/turba/lib/Driver/Sql.php @@ -587,7 +587,7 @@ class Turba_Driver_Sql extends Turba_Driver */ function _makeKey($attributes) { - return strval(new Horde_Support_Uuid()); + return strval(new Horde_Support_Randomid()); } /** diff --git a/turba/scripts/upgrades/public_to_horde_share.php b/turba/scripts/upgrades/public_to_horde_share.php index 917ed1ebc..7771b3feb 100755 --- a/turba/scripts/upgrades/public_to_horde_share.php +++ b/turba/scripts/upgrades/public_to_horde_share.php @@ -58,7 +58,7 @@ if (!$sourceKey) { } // Create the new share. -$owner_uid = strval(new Horde_Support_Uuid()); +$owner_uid = strval(new Horde_Support_Randomid()); $share = &$turba_shares->newShare($sourceKey . ':' . $owner_uid); if ($share instanceof Horde_Share_Exception) { var_dump($share); diff --git a/turba/search.php b/turba/search.php index 9b5384b5b..cf1b60d49 100644 --- a/turba/search.php +++ b/turba/search.php @@ -27,7 +27,7 @@ function _createVBook($params) 'criteria' => $params['criteria']))); try { - $share = Turba::createShare(strval(new Horde_Support_Uuid()), $params); + $share = Turba::createShare(strval(new Horde_Support_RandomId()), $params); } catch (Horde_Share_Exception $e) { throw new Turba_Exception($e); } -- 2.11.0