mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-12 01:54:26 +02:00
Improved resource id creation
This commit is contained in:
parent
d90b93cfda
commit
a3af6807ac
9 changed files with 23 additions and 37 deletions
|
@ -489,31 +489,6 @@ function item_new_uri($hostname, $uid, $guid = "") {
|
|||
return $uri;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate a guaranteed unique photo ID.
|
||||
* safe from birthday paradox
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function photo_new_resource() {
|
||||
|
||||
do {
|
||||
$found = false;
|
||||
$resource = hash('md5',uniqid(mt_rand(),true));
|
||||
$r = q("SELECT `id` FROM `photo` WHERE `resource-id` = '%s' LIMIT 1",
|
||||
dbesc($resource)
|
||||
);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
$found = true;
|
||||
}
|
||||
} while ($found == true);
|
||||
|
||||
return $resource;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* wrapper to load a view template, checking for alternate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue