-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use extension_loaded() instead of checking for a constant #8
Comments
The concern I'd have with that is mcrypt_compat being loaded twice. phpseclib used to have issues with it being included twice: random_compat works similarly to mcrypt_compat: https://github.com/paragonie/random_compat/blob/master/lib/random.php Mind you, whereas mcrypt_compat just does one |
Hello all, I want to add check in legacy app, something like:
I can also use This way mcrypt_compat can detect if it's already loaded, it can use Just a suggestion, thx for great polyfill !! |
phpseclib does three different tests in different places: if (!defined('MCRYPT_MODE_ECB')) {
...
if (!function_exists('phpseclib_mcrypt_list_algorithms')) {
...
if (!function_exists('mcrypt_list_algorithms')) { The only one that For your own check you could do |
I agree with @terrafrost here, that you should anyway test the feature (function exists, constant exists), not implementation details (extension_loaded, polyfill loaded). however, the loaded twice is not a real concern, why extension_loaded should not be used. |
https://github.com/phpseclib/mcrypt_compat/blob/master/lib/mcrypt.php#L44 should be
if (!extension_loaded('mcrypt')) {
The text was updated successfully, but these errors were encountered: