mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 01:15:13 +00:00
optimise
This commit is contained in:
parent
75ecacd88c
commit
017f1a3c79
1 changed files with 11 additions and 32 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue