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() {
|
function item_message_id() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
$hash = Uuid::uuid4()->toString();
|
||||||
|
} catch (UnsatisfiedDependencyException $e) {
|
||||||
|
$hash = random_string(48);
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
$mid = z_root() . '/item/' . $hash;
|
||||||
$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);
|
|
||||||
|
|
||||||
return $mid;
|
return $mid;
|
||||||
}
|
}
|
||||||
|
@ -587,22 +576,12 @@ function item_message_id() {
|
||||||
* @return string a unique hash
|
* @return string a unique hash
|
||||||
*/
|
*/
|
||||||
function photo_new_resource() {
|
function photo_new_resource() {
|
||||||
do {
|
|
||||||
$found = false;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$hash = Uuid::uuid4(Uuid::NAMESPACE_DNS, App::get_hostname())->toString();
|
$hash = Uuid::uuid4()->toString();
|
||||||
} catch (UnsatisfiedDependencyException $e) {
|
} catch (UnsatisfiedDependencyException $e) {
|
||||||
$hash = random_string(48);
|
$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);
|
|
||||||
|
|
||||||
return $hash;
|
return $hash;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue