bshaffer / oauth2-server-php

A library for implementing an OAuth2 Server in php
http://bshaffer.github.io/oauth2-server-php-docs
MIT License
3.26k stars 951 forks source link

php7 Deprecated warning for mcrypt_create_iv on \OAuth2\ResponseType\AccessToken::generateAccessToken() #772

Open zzwang opened 8 years ago

zzwang commented 8 years ago

In PHP7, mcryot_create_iv() is deprecated. Due to https://github.com/bshaffer/oauth2-server-php/pull/368/files, using mcrypt_create_iv as the default method to generate random bytes causes a deprecated warning.

        if (function_exists('mcrypt_create_iv')) {
            $randomData = mcrypt_create_iv(20, MCRYPT_DEV_URANDOM);
            if ($randomData !== false && strlen($randomData) === 20) {
                return bin2hex($randomData);
            }
        }

Should we just remove that block or just add version_compare like

        if (function_exists('mcrypt_create_iv') && version_compare(7, phpversion()) == 1) {
            $randomData = mcrypt_create_iv(20, MCRYPT_DEV_URANDOM);
            if ($randomData !== false && strlen($randomData) === 20) {
                return bin2hex($randomData);
            }
        }
pjcdawkins commented 8 years ago

Looks like this would be resolved by #773

mathroc commented 7 years ago

and it's been released so this issue might be closed ( https://github.com/bshaffer/oauth2-server-php/pull/788 )