From: Max Semenik Date: Sun, 17 Mar 2019 07:34:10 +0000 (-0700) Subject: Remove CryptRand and related stuff X-Git-Tag: 1.34.0-rc.0~2050 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=20865b4a6fcfa1c82a1d25d4ab63b40b9268a35d Remove CryptRand and related stuff Deprecated in 1.31 and not used anywhere. Change-Id: Idc2e9cec907e39cacc391fdd7e2718bd880081ae --- diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index 3c471c26db..9fb74dc8aa 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -68,6 +68,11 @@ because of Phabricator reports. === Breaking changes in 1.34 === * Preferences class, deprecated in 1.31, has been removed. +* The following parts of code, deprecated in 1.32, were removed in favor of + built-in PHP functions: + * CryptRand class + * CryptRand service + * Functions of the MWCryptRand class: singleton(), wasStrong() and generate(). * … === Deprecations in 1.34 === diff --git a/autoload.php b/autoload.php index a5ce46bbc2..a74a0b8b34 100644 --- a/autoload.php +++ b/autoload.php @@ -327,7 +327,6 @@ $wgAutoloadLocalClasses = [ 'CreditsAction' => __DIR__ . '/includes/actions/CreditsAction.php', 'CrhConverter' => __DIR__ . '/languages/classes/LanguageCrh.php', 'CryptHKDF' => __DIR__ . '/includes/libs/CryptHKDF.php', - 'CryptRand' => __DIR__ . '/includes/libs/CryptRand.php', 'CssContent' => __DIR__ . '/includes/content/CssContent.php', 'CssContentHandler' => __DIR__ . '/includes/content/CssContentHandler.php', 'CsvStatsOutput' => __DIR__ . '/maintenance/language/StatOutputs.php', diff --git a/includes/MediaWikiServices.php b/includes/MediaWikiServices.php index 22f0c63498..c296a72cf8 100644 --- a/includes/MediaWikiServices.php +++ b/includes/MediaWikiServices.php @@ -6,7 +6,6 @@ use CommentStore; use Config; use ConfigFactory; use CryptHKDF; -use CryptRand; use DateFormatterFactory; use EventRelayerGroup; use GenderCache; @@ -517,16 +516,6 @@ class MediaWikiServices extends ServiceContainer { return $this->getService( 'CryptHKDF' ); } - /** - * @since 1.28 - * @deprecated since 1.32, use random_bytes()/random_int() - * @return CryptRand - */ - public function getCryptRand() { - wfDeprecated( __METHOD__, '1.32' ); - return $this->getService( 'CryptRand' ); - } - /** * @since 1.33 * @return DateFormatterFactory diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 1eb3551558..c55fc689cc 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -134,10 +134,6 @@ return [ return new CryptHKDF( $secret, $config->get( 'HKDFAlgorithm' ), $cache, $context ); }, - 'CryptRand' => function () : CryptRand { - return new CryptRand(); - }, - 'DateFormatterFactory' => function () : DateFormatterFactory { return new DateFormatterFactory; }, diff --git a/includes/libs/CryptRand.php b/includes/libs/CryptRand.php deleted file mode 100644 index da0cae250d..0000000000 --- a/includes/libs/CryptRand.php +++ /dev/null @@ -1,119 +0,0 @@ -getCryptRand(); - } - - /** - * Return a boolean indicating whether or not the source used for cryptographic - * random bytes generation in the previously run generate* call - * was cryptographically strong. - * - * @deprecated since 1.32, always returns true - * - * @return bool Always true - */ - public static function wasStrong() { - wfDeprecated( __METHOD__, '1.32' ); - return true; - } - - /** - * Generate a run of cryptographically random data and return - * it in raw binary form. - * - * @deprecated since 1.32, use random_bytes() - * - * @param int $bytes The number of bytes of random data to generate - * @return string Raw binary random data - */ - public static function generate( $bytes ) { - wfDeprecated( __METHOD__, '1.32' ); - return random_bytes( floor( $bytes ) ); - } /** * Generate a run of cryptographically random data and return diff --git a/tests/phpunit/includes/MediaWikiServicesTest.php b/tests/phpunit/includes/MediaWikiServicesTest.php index 9d6164c959..8fa0cd60ec 100644 --- a/tests/phpunit/includes/MediaWikiServicesTest.php +++ b/tests/phpunit/includes/MediaWikiServicesTest.php @@ -11,7 +11,7 @@ use Wikimedia\Services\ServiceDisabledException; * @group MediaWiki */ class MediaWikiServicesTest extends MediaWikiTestCase { - private $deprecatedServices = [ 'CryptRand' ]; + private $deprecatedServices = []; /** * @return Config