From d3b1eb51fb68fc84f63d37a409f251ebb1948d8a Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Mon, 19 Apr 2021 13:17:20 +0200 Subject: [PATCH] Revert "chg: [internal] Install random_compat by Composer" This reverts commit fe7d0a46 --- .gitmodules | 4 ++++ app/Lib/Tools/RandomTool.php | 10 ++++++++++ app/Lib/random_compat | 1 + app/composer.json | 1 - 4 files changed, 15 insertions(+), 1 deletion(-) create mode 160000 app/Lib/random_compat diff --git a/.gitmodules b/.gitmodules index bc74489b3..8abe35ca0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,6 +7,10 @@ [submodule "app/files/warninglists"] path = app/files/warninglists url = https://github.com/MISP/misp-warninglists.git +[submodule "app/Lib/random_compat"] + path = app/Lib/random_compat + url = https://github.com/paragonie/random_compat + branch = master [submodule "app/files/misp-galaxy"] path = app/files/misp-galaxy url = https://github.com/MISP/misp-galaxy diff --git a/app/Lib/Tools/RandomTool.php b/app/Lib/Tools/RandomTool.php index 367ae45e3..4d50b8a50 100644 --- a/app/Lib/Tools/RandomTool.php +++ b/app/Lib/Tools/RandomTool.php @@ -2,6 +2,16 @@ class RandomTool { + public function __construct() + { + // import compatibility library for PHP < 7.0 + if (!function_exists('random_int')) { + if (file_exists(APP . 'Lib' . DS . 'random_compat' . DS . 'lib' . DS . 'random.php')) { + require_once(APP . 'Lib' . DS . 'random_compat' . DS . 'lib' . DS . 'random.php'); + } + } + } + /** * Generate a random string * diff --git a/app/Lib/random_compat b/app/Lib/random_compat new file mode 160000 index 000000000..088c04e2f --- /dev/null +++ b/app/Lib/random_compat @@ -0,0 +1 @@ +Subproject commit 088c04e2f261c33bed6ca5245491cfca69195ccf diff --git a/app/composer.json b/app/composer.json index b1233f0d2..27544c43b 100644 --- a/app/composer.json +++ b/app/composer.json @@ -10,7 +10,6 @@ "ext-simplexml": "*", "ext-pcre": "*", "cakephp/cakephp": "2.10.24", - "paragonie/random_compat": ">=2", "kamisama/cake-resque": "4.1.2", "pear/crypt_gpg": "1.6.3", "monolog/monolog": "1.24.0"