Hard deprecate functionality replaced with random_bytes()
authorMax Semenik <maxsem.wiki@gmail.com>
Thu, 18 Oct 2018 02:19:41 +0000 (19:19 -0700)
committerMax Semenik <maxsem.wiki@gmail.com>
Thu, 18 Oct 2018 02:57:52 +0000 (19:57 -0700)
Deprecated in 1.32, no callers.

Change-Id: Id2d59c303fd60fab2b323af6cab137fdf74b5377

includes/MediaWikiServices.php
includes/libs/CryptRand.php
includes/utils/MWCryptRand.php
tests/phpunit/includes/MediaWikiServicesTest.php

index 0acd55a..f3ca7d4 100644 (file)
@@ -518,6 +518,7 @@ class MediaWikiServices extends ServiceContainer {
         * @return CryptRand
         */
        public function getCryptRand() {
+               wfDeprecated( __METHOD__, '1.32' );
                return $this->getService( 'CryptRand' );
        }
 
index a1bbd09..da0cae2 100644 (file)
@@ -46,6 +46,7 @@ class CryptRand {
         * @return string
         */
        protected function initialRandomState() {
+               wfDeprecated( __METHOD__, '1.32' );
                return '';
        }
 
@@ -59,6 +60,7 @@ class CryptRand {
         * @author Tim Starling
         */
        protected function driftHash( $data ) {
+               wfDeprecated( __METHOD__, '1.32' );
                return '';
        }
 
@@ -70,6 +72,7 @@ class CryptRand {
         * @return string A new weak random state
         */
        protected function randomState() {
+               wfDeprecated( __METHOD__, '1.32' );
                return '';
        }
 
@@ -83,6 +86,7 @@ class CryptRand {
         * @return bool Always true
         */
        public function wasStrong() {
+               wfDeprecated( __METHOD__, '1.32' );
                return true;
        }
 
@@ -96,6 +100,7 @@ class CryptRand {
         * @return string Raw binary random data
         */
        public function generate( $bytes ) {
+               wfDeprecated( __METHOD__, '1.32' );
                $bytes = floor( $bytes );
                return random_bytes( $bytes );
        }
@@ -108,6 +113,7 @@ class CryptRand {
         * @return string Hexadecimal random data
         */
        public function generateHex( $chars ) {
+               wfDeprecated( __METHOD__, '1.32' );
                return MWCryptRand::generateHex( $chars );
        }
 }
index 0fc45f7..ec8bf5c 100644 (file)
@@ -32,6 +32,7 @@ class MWCryptRand {
         * @return CryptRand
         */
        protected static function singleton() {
+               wfDeprecated( __METHOD__, '1.32' );
                return MediaWikiServices::getInstance()->getCryptRand();
        }
 
@@ -45,6 +46,7 @@ class MWCryptRand {
         * @return bool Always true
         */
        public static function wasStrong() {
+               wfDeprecated( __METHOD__, '1.32' );
                return true;
        }
 
@@ -58,6 +60,7 @@ class MWCryptRand {
         * @return string Raw binary random data
         */
        public static function generate( $bytes ) {
+               wfDeprecated( __METHOD__, '1.32' );
                return random_bytes( floor( $bytes ) );
        }
 
index c838fc3..ab9a472 100644 (file)
@@ -11,6 +11,7 @@ use MediaWiki\Services\ServiceDisabledException;
  * @group MediaWiki
  */
 class MediaWikiServicesTest extends MediaWikiTestCase {
+       private $deprecatedServices = [ 'CryptRand' ];
 
        /**
         * @return Config
@@ -276,6 +277,7 @@ class MediaWikiServicesTest extends MediaWikiTestCase {
                        $getterCases[$name] = [
                                'get' . $service,
                                $class,
+                               in_array( $service, $this->deprecatedServices )
                        ];
                }
 
@@ -285,7 +287,11 @@ class MediaWikiServicesTest extends MediaWikiTestCase {
        /**
         * @dataProvider provideGetters
         */
-       public function testGetters( $getter, $type ) {
+       public function testGetters( $getter, $type, $isDeprecated = false ) {
+               if ( $isDeprecated ) {
+                       $this->hideDeprecated( MediaWikiServices::class . "::$getter" );
+               }
+
                // Test against the default instance, since the dummy will not know the default services.
                $services = MediaWikiServices::getInstance();
                $service = $services->$getter();