diff --git a/include/text.php b/include/text.php index db911169c..ad5408778 100644 --- a/include/text.php +++ b/include/text.php @@ -557,24 +557,13 @@ function alt_pager($i, $more = '', $less = '') { */ function item_message_id() { + try { + $hash = Uuid::uuid4()->toString(); + } catch (UnsatisfiedDependencyException $e) { + $hash = random_string(48); + } - do { - $dups = false; - - try { - $hash = Uuid::uuid4(Uuid::NAMESPACE_DNS, App::get_hostname())->toString(); - } catch (UnsatisfiedDependencyException $e) { - $hash = random_string(48); - } - - $mid = z_root() . '/item/' . $hash; - - $r = q("SELECT id FROM item WHERE mid = '%s' LIMIT 1", - dbesc($mid)); - if ($r) { - $dups = true; - } - } while ($dups === true); + $mid = z_root() . '/item/' . $hash; return $mid; } @@ -587,22 +576,12 @@ function item_message_id() { * @return string a unique hash */ function photo_new_resource() { - do { - $found = false; - try { - $hash = Uuid::uuid4(Uuid::NAMESPACE_DNS, App::get_hostname())->toString(); - } catch (UnsatisfiedDependencyException $e) { - $hash = random_string(48); - } - - $r = q("SELECT id FROM photo WHERE resource_id = '%s' LIMIT 1", - dbesc($hash) - ); - if ($r) { - $found = true; - } - } while ($found === true); + try { + $hash = Uuid::uuid4()->toString(); + } catch (UnsatisfiedDependencyException $e) { + $hash = random_string(48); + } return $hash; }