[TikiWiki-commits] [Git][tikiwiki/tiki][master] [REF] Move UUIDs to Tiki\Utilities\Identifiers
Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6892344a592ff_2cd5cc893316@gitlab-sidekiq-low-urgency-cpu-bound-v2-5b648c79b-frkb8.mail> |
Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki
Commits:
f8497d20 by Marcellin Wabo at 2025-08-05T16:12:38+00:00
[REF] Move UUIDs to Tiki\Utilities\Identifiers
---
* [REF] Move UUIDs to Tiki\Utilities\Identifiers
* Context: https://avan.tech/item111209
See merge request tikiwiki/tiki!8191
- - - - -
3 changed files:
- lib/core/Services/IotApps/Controller.php
- lib/core/Services/Webauthn/WebauthnController.php
- lib/core/Tiki/Utilities/Identifiers.php
Changes:
=====================================
lib/core/Services/IotApps/Controller.php
=====================================
@@ -28,8 +28,7 @@ class Services_IotApps_Controller
global $access;
$access->check_permission('tiki_p_manage_iot_apps');
$payload = $input->payload->json();
- $uuid = Uuid::uuid4();
- $app_uuid = $uuid->toString();
+ $app_uuid = \Tiki\Utilities\Identifiers::generateUUID();
$trackerId = intval($payload['tracker-id']);
$name = $payload['app-name'];
try {
=====================================
lib/core/Services/Webauthn/WebauthnController.php
=====================================
@@ -62,7 +62,7 @@ class WebauthnController
$url_host
);
- $uuid = Uuid::v4();
+ $uuid = \Tiki\Utilities\Identifiers::generateUUID();
$userEntity = PublicKeyCredentialUserEntity::create(
$userName,
$uuid,
=====================================
lib/core/Tiki/Utilities/Identifiers.php
=====================================
@@ -6,6 +6,9 @@
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
namespace Tiki\Utilities;
+use Exception;
+use Ramsey\Uuid\Uuid;
+
class Identifiers
{
/**
@@ -30,4 +33,24 @@ class Identifiers
$uniqueid = hash('crc32b', implode('', $values));
return $uniqueid;
}
+
+ /**
+ * This will return a universally unique identifiers (UUIDs)
+ * leveraging ramsey/uuid library.
+ *
+ * @param string $version The UUIDs version to generate
+ * @return string A UUIDs string of $version version (4 or 7)
+ * @throws Exception When the given version is not 4 or 7
+ */
+ public static function generateUUID(int $version = 4): string
+ {
+ switch ($version) {
+ case 4:
+ return Uuid::uuid4()->toString();
+ case 7:
+ return Uuid::uuid7()->toString();
+ default:
+ throw new Exception(tr("UUID version %0 not supported by Tiki.\n Supported versions are 4 and 7.", $version));
+ }
+ }
}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/f8497d20752520432ef01c61c7790aa6005d52c7
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/f8497d20752520432ef01c61c7790aa6005d52c7
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs