1
1
Fork 0

Improved resource id creation

This commit is contained in:
Michael 2018-02-20 10:02:07 +00:00
commit a3af6807ac
9 changed files with 23 additions and 37 deletions

View file

@ -4614,7 +4614,7 @@ function save_media_to_database($mediatype, $media, $type, $album, $allow_cid, $
$height = $Image->getHeight();
// create a new resource-id if not already provided
$hash = ($photo_id == null) ? photo_new_resource() : $photo_id;
$hash = ($photo_id == null) ? Photo::newResource() : $photo_id;
if ($mediatype == "photo") {
// upload normal image (scales 0, 1, 2)

View file

@ -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