Replace wfBaseConvert with Wikimedia\base_convert
authorReedy <reedy@wikimedia.org>
Tue, 24 Nov 2015 22:51:42 +0000 (22:51 +0000)
committerReedy <reedy@wikimedia.org>
Tue, 24 Nov 2015 22:51:42 +0000 (22:51 +0000)
Change-Id: Iadab3d018c3559daf79be90edb23d131729bdb68

29 files changed:
includes/Import.php
includes/Revision.php
includes/api/ApiQueryAllImages.php
includes/api/ApiQueryDeletedrevs.php
includes/api/ApiQueryFilearchive.php
includes/api/ApiQueryImageInfo.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryRevisionsBase.php
includes/db/DatabasePostgres.php
includes/externalstore/ExternalStoreMwstore.php
includes/filebackend/FSFile.php
includes/filebackend/FileBackendStore.php
includes/filebackend/FileOp.php
includes/filebackend/SwiftFileBackend.php
includes/filebackend/filejournal/FileJournal.php
includes/filebackend/lockmanager/DBLockManager.php
includes/filebackend/lockmanager/LockManager.php
includes/filerepo/file/ForeignAPIFile.php
includes/jobqueue/JobQueueDB.php
includes/jobqueue/JobQueueRedis.php
includes/password/PasswordFactory.php
includes/upload/UploadStash.php
includes/utils/IP.php
includes/utils/UIDGenerator.php
maintenance/benchmarks/bench_wfBaseConvert.php
tests/parser/parserTest.inc
tests/phpunit/includes/filebackend/FileBackendTest.php
tests/phpunit/includes/parser/NewParserTest.php
tests/phpunit/includes/utils/UIDGeneratorTest.php

index f0576d7..519f74a 100644 (file)
@@ -1499,7 +1499,7 @@ class WikiRevision {
         */
        function getSha1() {
                if ( $this->sha1base36 ) {
-                       return wfBaseConvert( $this->sha1base36, 36, 16 );
+                       return Wikimedia\base_convert( $this->sha1base36, 36, 16 );
                }
                return false;
        }
index 3b98a65..1d7ac72 100644 (file)
@@ -1526,7 +1526,7 @@ class Revision implements IDBAccessObject {
         * @return string
         */
        public static function base36Sha1( $text ) {
-               return wfBaseConvert( sha1( $text ), 16, 36, 31 );
+               return Wikimedia\base_convert( sha1( $text ), 16, 36, 31 );
        }
 
        /**
index 699cba8..6c7e69b 100644 (file)
@@ -216,7 +216,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
                        if ( !$this->validateSha1Hash( $sha1 ) ) {
                                $this->dieUsage( 'The SHA1 hash provided is not valid', 'invalidsha1hash' );
                        }
-                       $sha1 = wfBaseConvert( $sha1, 16, 36, 31 );
+                       $sha1 = Wikimedia\base_convert( $sha1, 16, 36, 31 );
                } elseif ( isset( $params['sha1base36'] ) ) {
                        $sha1 = strtolower( $params['sha1base36'] );
                        if ( !$this->validateSha1Base36Hash( $sha1 ) ) {
index 76f594e..fe2ec8f 100644 (file)
@@ -362,7 +362,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                                }
                                if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_TEXT, $user ) ) {
                                        if ( $row->ar_sha1 != '' ) {
-                                               $rev['sha1'] = wfBaseConvert( $row->ar_sha1, 36, 16, 40 );
+                                               $rev['sha1'] = Wikimedia\base_convert( $row->ar_sha1, 36, 16, 40 );
                                        } else {
                                                $rev['sha1'] = '';
                                        }
index 8156edb..71be951 100644 (file)
@@ -114,7 +114,7 @@ class ApiQueryFilearchive extends ApiQueryBase {
                                if ( !$this->validateSha1Hash( $sha1 ) ) {
                                        $this->dieUsage( 'The SHA1 hash provided is not valid', 'invalidsha1hash' );
                                }
-                               $sha1 = wfBaseConvert( $sha1, 16, 36, 31 );
+                               $sha1 = Wikimedia\base_convert( $sha1, 16, 36, 31 );
                        } elseif ( $sha1base36Set ) {
                                $sha1 = strtolower( $params['sha1base36'] );
                                if ( !$this->validateSha1Base36Hash( $sha1 ) ) {
@@ -183,7 +183,7 @@ class ApiQueryFilearchive extends ApiQueryBase {
                                $file['user'] = $row->fa_user_text;
                        }
                        if ( $fld_sha1 ) {
-                               $file['sha1'] = wfBaseConvert( $row->fa_sha1, 36, 16, 40 );
+                               $file['sha1'] = Wikimedia\base_convert( $row->fa_sha1, 36, 16, 40 );
                        }
                        if ( $fld_timestamp ) {
                                $file['timestamp'] = wfTimestamp( TS_ISO_8601, $row->fa_timestamp );
index 0a8e2c9..8dbd812 100644 (file)
@@ -518,7 +518,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                }
 
                if ( $sha1 ) {
-                       $vals['sha1'] = wfBaseConvert( $file->getSha1(), 36, 16, 40 );
+                       $vals['sha1'] = Wikimedia\base_convert( $file->getSha1(), 36, 16, 40 );
                }
 
                if ( $meta ) {
index 0a11f4b..c99d87c 100644 (file)
@@ -552,7 +552,7 @@ class ApiQueryRecentChanges extends ApiQueryGeneratorBase {
                        }
                        if ( Revision::userCanBitfield( $row->rev_deleted, Revision::DELETED_TEXT, $user ) ) {
                                if ( $row->rev_sha1 !== '' ) {
-                                       $vals['sha1'] = wfBaseConvert( $row->rev_sha1, 36, 16, 40 );
+                                       $vals['sha1'] = Wikimedia\base_convert( $row->rev_sha1, 36, 16, 40 );
                                } else {
                                        $vals['sha1'] = '';
                                }
index 5bc1e79..d7fb580 100644 (file)
@@ -213,7 +213,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase {
                        }
                        if ( $revision->userCan( Revision::DELETED_TEXT, $user ) ) {
                                if ( $revision->getSha1() != '' ) {
-                                       $vals['sha1'] = wfBaseConvert( $revision->getSha1(), 36, 16, 40 );
+                                       $vals['sha1'] = Wikimedia\base_convert( $revision->getSha1(), 36, 16, 40 );
                                } else {
                                        $vals['sha1'] = '';
                                }
index 9c5127f..4d9891e 100644 (file)
@@ -1611,7 +1611,7 @@ SQL;
         * @return string Integer
         */
        private function bigintFromLockName( $lockName ) {
-               return wfBaseConvert( substr( sha1( $lockName ), 0, 15 ), 16, 10 );
+               return Wikimedia\base_convert( substr( sha1( $lockName ), 0, 15 ), 16, 10 );
        }
 } // end DatabasePostgres class
 
index 89ac734..c3c5dcb 100644 (file)
@@ -78,7 +78,7 @@ class ExternalStoreMwstore extends ExternalStoreMedium {
                $be = FileBackendGroup::singleton()->get( $backend );
                if ( $be instanceof FileBackend ) {
                        // Get three random base 36 characters to act as shard directories
-                       $rand = wfBaseConvert( mt_rand( 0, 46655 ), 10, 36, 3 );
+                       $rand = Wikimedia\base_convert( mt_rand( 0, 46655 ), 10, 36, 3 );
                        // Make sure ID is roughly lexicographically increasing for performance
                        $id = str_pad( UIDGenerator::newTimestampedUID128( 32 ), 26, '0', STR_PAD_LEFT );
                        // Segregate items by wiki ID for the sake of bookkeeping
index 213bb87..2604c88 100644 (file)
@@ -208,7 +208,7 @@ class FSFile {
                MediaWiki\restoreWarnings();
 
                if ( $this->sha1Base36 !== false ) {
-                       $this->sha1Base36 = wfBaseConvert( $this->sha1Base36, 16, 36, 31 );
+                       $this->sha1Base36 = Wikimedia\base_convert( $this->sha1Base36, 16, 36, 31 );
                }
 
                return $this->sha1Base36;
index 1432bb9..e21aaea 100644 (file)
@@ -1551,7 +1551,7 @@ abstract class FileBackendStore extends FileBackend {
                if ( $digits > 0 ) {
                        $numShards = pow( $base, $digits );
                        for ( $index = 0; $index < $numShards; $index++ ) {
-                               $shards[] = '.' . wfBaseConvert( $index, 10, $base, $digits );
+                               $shards[] = '.' . Wikimedia\base_convert( $index, 10, $base, $digits );
                        }
                }
 
index 5d4e8e1..8359943 100644 (file)
@@ -513,7 +513,7 @@ class CreateFileOp extends FileOp {
        }
 
        protected function getSourceSha1Base36() {
-               return wfBaseConvert( sha1( $this->params['content'] ), 16, 36, 31 );
+               return Wikimedia\base_convert( sha1( $this->params['content'] ), 16, 36, 31 );
        }
 
        public function storagePathsChanged() {
@@ -581,7 +581,7 @@ class StoreFileOp extends FileOp {
                $hash = sha1_file( $this->params['src'] );
                MediaWiki\restoreWarnings();
                if ( $hash !== false ) {
-                       $hash = wfBaseConvert( $hash, 16, 36, 31 );
+                       $hash = Wikimedia\base_convert( $hash, 16, 36, 31 );
                }
 
                return $hash;
index 72a877d..93d8d07 100644 (file)
@@ -261,7 +261,7 @@ class SwiftFileBackend extends FileBackendStore {
                        return $status;
                }
 
-               $sha1Hash = wfBaseConvert( sha1( $params['content'] ), 16, 36, 31 );
+               $sha1Hash = Wikimedia\base_convert( sha1( $params['content'] ), 16, 36, 31 );
                $contentType = isset( $params['headers']['content-type'] )
                        ? $params['headers']['content-type']
                        : $this->getContentType( $params['dst'], $params['content'], null );
@@ -319,7 +319,7 @@ class SwiftFileBackend extends FileBackendStore {
 
                        return $status;
                }
-               $sha1Hash = wfBaseConvert( $sha1Hash, 16, 36, 31 );
+               $sha1Hash = Wikimedia\base_convert( $sha1Hash, 16, 36, 31 );
                $contentType = isset( $params['headers']['content-type'] )
                        ? $params['headers']['content-type']
                        : $this->getContentType( $params['dst'], null, $params['src'] );
index 4ee5222..2f39dad 100644 (file)
@@ -81,9 +81,9 @@ abstract class FileJournal {
                for ( $i = 0; $i < 5; $i++ ) {
                        $s .= mt_rand( 0, 2147483647 );
                }
-               $s = wfBaseConvert( sha1( $s ), 16, 36, 31 );
+               $s = Wikimedia\base_convert( sha1( $s ), 16, 36, 31 );
 
-               return substr( wfBaseConvert( wfTimestamp( TS_MW ), 10, 36, 9 ) . $s, 0, 31 );
+               return substr( Wikimedia\base_convert( wfTimestamp( TS_MW ), 10, 36, 9 ) . $s, 0, 31 );
        }
 
        /**
index 2c86c37..c93b4b4 100644 (file)
@@ -376,7 +376,7 @@ class PostgreSqlLockManager extends DBLockManager {
                $db = $this->getConnection( $lockSrv ); // checked in isServerUp()
                $bigints = array_unique( array_map(
                        function ( $key ) {
-                               return wfBaseConvert( substr( $key, 0, 15 ), 16, 10 );
+                               return Wikimedia\base_convert( substr( $key, 0, 15 ), 16, 10 );
                        },
                        array_map( array( $this, 'sha1Base16Absolute' ), $paths )
                ) );
index 8115fd4..7605a9b 100644 (file)
@@ -152,7 +152,7 @@ abstract class LockManager {
         * @return string
         */
        final protected function sha1Base36Absolute( $path ) {
-               return wfBaseConvert( sha1( "{$this->domain}:{$path}" ), 16, 36, 31 );
+               return Wikimedia\base_convert( sha1( "{$this->domain}:{$path}" ), 16, 36, 31 );
        }
 
        /**
index cad806d..26ea38b 100644 (file)
@@ -244,7 +244,7 @@ class ForeignAPIFile extends File {
         */
        function getSha1() {
                return isset( $this->mInfo['sha1'] )
-                       ? wfBaseConvert( strval( $this->mInfo['sha1'] ), 16, 36, 31 )
+                       ? Wikimedia\base_convert( strval( $this->mInfo['sha1'] ), 16, 36, 31 )
                        : null;
        }
 
index ed2d0fa..f10866e 100644 (file)
@@ -727,7 +727,7 @@ class JobQueueDB extends JobQueue {
                        // Additional job metadata
                        'job_id' => $dbw->nextSequenceValue( 'job_job_id_seq' ),
                        'job_timestamp' => $dbw->timestamp(),
-                       'job_sha1' => wfBaseConvert(
+                       'job_sha1' => Wikimedia\base_convert(
                                sha1( serialize( $job->getDeduplicationInfo() ) ),
                                16, 36, 31
                        ),
index deb5aa5..78d2a36 100644 (file)
@@ -639,7 +639,7 @@ LUA;
                        // Additional job metadata
                        'uuid' => UIDGenerator::newRawUUIDv4( UIDGenerator::QUICK_RAND ),
                        'sha1' => $job->ignoreDuplicates()
-                               ? wfBaseConvert( sha1( serialize( $job->getDeduplicationInfo() ) ), 16, 36, 31 )
+                               ? Wikimedia\base_convert( sha1( serialize( $job->getDeduplicationInfo() ) ), 16, 36, 31 )
                                : '',
                        'timestamp' => time() // UNIX timestamp
                );
index e1f272b..6b634cb 100644 (file)
@@ -204,7 +204,7 @@ final class PasswordFactory {
                // Generate random hex chars
                $hex = MWCryptRand::generateHex( $length );
                // Convert from base 16 to base 32 to get a proper password like string
-               return wfBaseConvert( $hex, 16, 32 );
+               return Wikimedia\base_convert( $hex, 16, 32 );
        }
 
        /**
index e241383..53f0cd2 100644 (file)
@@ -226,8 +226,8 @@ class UploadStash {
                // see: http://www.jwz.org/doc/mid.html
                list( $usec, $sec ) = explode( ' ', microtime() );
                $usec = substr( $usec, 2 );
-               $key = wfBaseConvert( $sec . $usec, 10, 36 ) . '.' .
-                       wfBaseConvert( mt_rand(), 10, 36 ) . '.' .
+               $key = Wikimedia\base_convert( $sec . $usec, 10, 36 ) . '.' .
+                       Wikimedia\base_convert( mt_rand(), 10, 36 ) . '.' .
                        $this->userId . '.' .
                        $extension;
 
index 9f52249..119805e 100644 (file)
@@ -411,7 +411,7 @@ class IP {
                                }
                        }
                        if ( $n !== false ) {
-                               # Floating points can handle the conversion; faster than wfBaseConvert()
+                               # Floating points can handle the conversion; faster than Wikimedia\base_convert()
                                $n = strtoupper( str_pad( base_convert( $n, 10, 16 ), 8, '0', STR_PAD_LEFT ) );
                        }
                } else {
@@ -551,11 +551,11 @@ class IP {
                        } else {
                                # Native 32 bit functions WONT work here!!!
                                # Convert to a padded binary number
-                               $network = wfBaseConvert( $network, 16, 2, 128 );
+                               $network = Wikimedia\base_convert( $network, 16, 2, 128 );
                                # Truncate the last (128-$bits) bits and replace them with zeros
                                $network = str_pad( substr( $network, 0, $bits ), 128, 0, STR_PAD_RIGHT );
                                # Convert back to an integer
-                               $network = wfBaseConvert( $network, 2, 10 );
+                               $network = Wikimedia\base_convert( $network, 2, 10 );
                        }
                } else {
                        $network = false;
@@ -587,13 +587,13 @@ class IP {
                        if ( $network === false ) {
                                $start = $end = false;
                        } else {
-                               $start = wfBaseConvert( $network, 10, 16, 32, false );
+                               $start = Wikimedia\base_convert( $network, 10, 16, 32, false );
                                # Turn network to binary (again)
-                               $end = wfBaseConvert( $network, 10, 2, 128 );
+                               $end = Wikimedia\base_convert( $network, 10, 2, 128 );
                                # Truncate the last (128-$bits) bits and replace them with ones
                                $end = str_pad( substr( $end, 0, $bits ), 128, 1, STR_PAD_RIGHT );
                                # Convert to hex
-                               $end = wfBaseConvert( $end, 2, 16, 32, false );
+                               $end = Wikimedia\base_convert( $end, 2, 16, 32, false );
                                # see toHex() comment
                                $start = "v6-$start";
                                $end = "v6-$end";
index 26eebcd..f6f3c5f 100644 (file)
@@ -73,8 +73,8 @@ class UIDGenerator {
                        }
                        file_put_contents( $this->nodeIdFile, $nodeId ); // cache
                }
-               $this->nodeId32 = wfBaseConvert( substr( sha1( $nodeId ), 0, 8 ), 16, 2, 32 );
-               $this->nodeId48 = wfBaseConvert( $nodeId, 16, 2, 48 );
+               $this->nodeId32 = Wikimedia\base_convert( substr( sha1( $nodeId ), 0, 8 ), 16, 2, 32 );
+               $this->nodeId48 = Wikimedia\base_convert( $nodeId, 16, 2, 48 );
                // If different processes run as different users, they may have different temp dirs.
                // This is dealt with by initializing the clock sequence number and counters randomly.
                $this->lockFile88 = wfTempDir() . '/mw-' . __CLASS__ . '-UID-88';
@@ -115,7 +115,7 @@ class UIDGenerator {
                $gen = self::singleton();
                $time = $gen->getTimestampAndDelay( 'lockFile88', 1, 1024 );
 
-               return wfBaseConvert( $gen->getTimestampedID88( $time ), 2, $base );
+               return Wikimedia\base_convert( $gen->getTimestampedID88( $time ), 2, $base );
        }
 
        /**
@@ -161,7 +161,7 @@ class UIDGenerator {
                $gen = self::singleton();
                $time = $gen->getTimestampAndDelay( 'lockFile128', 16384, 1048576 );
 
-               return wfBaseConvert( $gen->getTimestampedID128( $time ), 2, $base );
+               return Wikimedia\base_convert( $gen->getTimestampedID128( $time ), 2, $base );
        }
 
        /**
@@ -448,7 +448,7 @@ class UIDGenerator {
                                ': sorry, this function doesn\'t work after the year 144680' );
                }
 
-               return substr( wfBaseConvert( $ts, 10, 2, 46 ), -46 );
+               return substr( Wikimedia\base_convert( $ts, 10, 2, 46 ), -46 );
        }
 
        /**
index b4be12b..deed389 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Benchmark for wfBaseConvert
+ * Benchmark for Wikimedia\base_convert
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 require_once __DIR__ . '/Benchmarker.php';
 
 /**
- * Maintenance script that benchmarks wfBaseConvert().
+ * Maintenance script that benchmarks Wikimedia\base_convert().
  *
  * @ingroup Benchmark
  */
 class BenchWfBaseConvert extends Benchmarker {
        public function __construct() {
                parent::__construct();
-               $this->mDescription = "Benchmark for wfBaseConvert.";
+               $this->mDescription = "Benchmark for Wikimedia\base_convert.";
                $this->addOption( "inbase", "Input base", false, true );
                $this->addOption( "outbase", "Output base", false, true );
                $this->addOption( "length", "Size in digits to generate for input", false, true );
@@ -46,15 +46,15 @@ class BenchWfBaseConvert extends Benchmarker {
 
                $this->bench( array(
                        array(
-                               'function' => 'wfBaseConvert',
+                               'function' => 'Wikimedia\base_convert',
                                'args' => array( $number, $inbase, $outbase, 0, true, 'php' )
                        ),
                        array(
-                               'function' => 'wfBaseConvert',
+                               'function' => 'Wikimedia\base_convert',
                                'args' => array( $number, $inbase, $outbase, 0, true, 'bcmath' )
                        ),
                        array(
-                               'function' => 'wfBaseConvert',
+                               'function' => 'Wikimedia\base_convert',
                                'args' => array( $number, $inbase, $outbase, 0, true, 'gmp' )
                        ),
                ) );
index 005ade5..f29e8b8 100644 (file)
@@ -1054,7 +1054,7 @@ class ParserTest {
                        'media_type' => MEDIATYPE_BITMAP,
                        'mime' => 'image/jpeg',
                        'metadata' => serialize( array() ),
-                       'sha1' => wfBaseConvert( '1', 16, 36, 31 ),
+                       'sha1' => Wikimedia\base_convert( '1', 16, 36, 31 ),
                        'fileExists' => true
                ), $this->db->timestamp( '20010115123500' ), $user );
 
@@ -1068,7 +1068,7 @@ class ParserTest {
                        'media_type' => MEDIATYPE_BITMAP,
                        'mime' => 'image/png',
                        'metadata' => serialize( array() ),
-                       'sha1' => wfBaseConvert( '2', 16, 36, 31 ),
+                       'sha1' => Wikimedia\base_convert( '2', 16, 36, 31 ),
                        'fileExists' => true
                ), $this->db->timestamp( '20130225203040' ), $user );
 
@@ -1081,7 +1081,7 @@ class ParserTest {
                                'media_type'  => MEDIATYPE_DRAWING,
                                'mime'        => 'image/svg+xml',
                                'metadata'    => serialize( array() ),
-                               'sha1'        => wfBaseConvert( '', 16, 36, 31 ),
+                               'sha1'        => Wikimedia\base_convert( '', 16, 36, 31 ),
                                'fileExists'  => true
                ), $this->db->timestamp( '20010115123500' ), $user );
 
@@ -1095,7 +1095,7 @@ class ParserTest {
                        'media_type' => MEDIATYPE_BITMAP,
                        'mime' => 'image/jpeg',
                        'metadata' => serialize( array() ),
-                       'sha1' => wfBaseConvert( '3', 16, 36, 31 ),
+                       'sha1' => Wikimedia\base_convert( '3', 16, 36, 31 ),
                        'fileExists' => true
                ), $this->db->timestamp( '20010115123500' ), $user );
 
@@ -1134,7 +1134,7 @@ class ParserTest {
 </OBJECT>
 </BODY>
 </DjVuXML>',
-                       'sha1' => wfBaseConvert( '', 16, 36, 31 ),
+                       'sha1' => Wikimedia\base_convert( '', 16, 36, 31 ),
                        'fileExists' => true
                ), $this->db->timestamp( '20010115123600' ), $user );
        }
index 95c6092..9bef8e0 100644 (file)
@@ -1716,7 +1716,7 @@ class FileBackendTest extends MediaWikiTestCase {
                $this->assertEquals( strlen( $fileBContents ),
                        $this->backend->getFileSize( array( 'src' => $fileC ) ),
                        "Correct file size of $fileC" );
-               $this->assertEquals( wfBaseConvert( sha1( $fileBContents ), 16, 36, 31 ),
+               $this->assertEquals( Wikimedia\base_convert( sha1( $fileBContents ), 16, 36, 31 ),
                        $this->backend->getFileSha1Base36( array( 'src' => $fileC ) ),
                        "Correct file SHA-1 of $fileC" );
        }
@@ -1815,7 +1815,7 @@ class FileBackendTest extends MediaWikiTestCase {
                $this->assertEquals( strlen( $fileBContents ),
                        $this->backend->getFileSize( array( 'src' => $fileC ) ),
                        "Correct file size of $fileC" );
-               $this->assertEquals( wfBaseConvert( sha1( $fileBContents ), 16, 36, 31 ),
+               $this->assertEquals( Wikimedia\base_convert( sha1( $fileBContents ), 16, 36, 31 ),
                        $this->backend->getFileSha1Base36( array( 'src' => $fileC ) ),
                        "Correct file SHA-1 of $fileC" );
        }
@@ -1892,7 +1892,7 @@ class FileBackendTest extends MediaWikiTestCase {
                $this->assertEquals( strlen( $fileBContents ),
                        $this->backend->getFileSize( array( 'src' => $fileA ) ),
                        "Correct file size of $fileA" );
-               $this->assertEquals( wfBaseConvert( sha1( $fileBContents ), 16, 36, 31 ),
+               $this->assertEquals( Wikimedia\base_convert( sha1( $fileBContents ), 16, 36, 31 ),
                        $this->backend->getFileSha1Base36( array( 'src' => $fileA ) ),
                        "Correct file SHA-1 of $fileA" );
        }
index f7c428a..6948082 100644 (file)
@@ -243,7 +243,7 @@ class NewParserTest extends MediaWikiTestCase {
                                        'media_type' => MEDIATYPE_BITMAP,
                                        'mime' => 'image/jpeg',
                                        'metadata' => serialize( array() ),
-                                       'sha1' => wfBaseConvert( '1', 16, 36, 31 ),
+                                       'sha1' => Wikimedia\base_convert( '1', 16, 36, 31 ),
                                        'fileExists' => true ),
                                $this->db->timestamp( '20010115123500' ), $user
                        );
@@ -263,7 +263,7 @@ class NewParserTest extends MediaWikiTestCase {
                                        'media_type' => MEDIATYPE_BITMAP,
                                        'mime' => 'image/png',
                                        'metadata' => serialize( array() ),
-                                       'sha1' => wfBaseConvert( '2', 16, 36, 31 ),
+                                       'sha1' => Wikimedia\base_convert( '2', 16, 36, 31 ),
                                        'fileExists' => true ),
                                $this->db->timestamp( '20130225203040' ), $user
                        );
@@ -284,7 +284,7 @@ class NewParserTest extends MediaWikiTestCase {
                                        'media_type' => MEDIATYPE_BITMAP,
                                        'mime' => 'image/jpeg',
                                        'metadata' => serialize( array() ),
-                                       'sha1' => wfBaseConvert( '3', 16, 36, 31 ),
+                                       'sha1' => Wikimedia\base_convert( '3', 16, 36, 31 ),
                                        'fileExists' => true ),
                                $this->db->timestamp( '20010115123500' ), $user
                        );
@@ -299,7 +299,7 @@ class NewParserTest extends MediaWikiTestCase {
                                        'media_type'  => MEDIATYPE_DRAWING,
                                        'mime'        => 'image/svg+xml',
                                        'metadata'    => serialize( array() ),
-                                       'sha1'        => wfBaseConvert( '', 16, 36, 31 ),
+                                       'sha1'        => Wikimedia\base_convert( '', 16, 36, 31 ),
                                        'fileExists'  => true
                        ), $this->db->timestamp( '20010115123500' ), $user );
                }
@@ -340,7 +340,7 @@ class NewParserTest extends MediaWikiTestCase {
 </OBJECT>
 </BODY>
 </DjVuXML>',
-                               'sha1' => wfBaseConvert( '', 16, 36, 31 ),
+                               'sha1' => Wikimedia\base_convert( '', 16, 36, 31 ),
                                'fileExists' => true
                        ), $this->db->timestamp( '20140115123600' ), $user );
                }
index fedcc76..89b2c17 100644 (file)
@@ -18,7 +18,7 @@ class UIDGeneratorTest extends PHPUnit_Framework_TestCase {
                $this->assertEquals( true, ctype_digit( $id ), "UID made of digit characters" );
                $this->assertLessThanOrEqual( $digitlen, strlen( $id ),
                        "UID has the right number of digits" );
-               $this->assertLessThanOrEqual( $bits, strlen( wfBaseConvert( $id, 10, 2 ) ),
+               $this->assertLessThanOrEqual( $bits, strlen( Wikimedia\base_convert( $id, 10, 2 ) ),
                        "UID has the right number of bits" );
 
                $ids = array();
@@ -31,8 +31,8 @@ class UIDGeneratorTest extends PHPUnit_Framework_TestCase {
                $this->assertSame( array_unique( $ids ), $ids, "All generated IDs are unique." );
 
                foreach ( $ids as $id ) {
-                       $id_bin = wfBaseConvert( $id, 10, 2 );
-                       $lastId_bin = wfBaseConvert( $lastId, 10, 2 );
+                       $id_bin = Wikimedia\base_convert( $id, 10, 2 );
+                       $lastId_bin = Wikimedia\base_convert( $lastId, 10, 2 );
 
                        $this->assertGreaterThanOrEqual(
                                substr( $lastId_bin, 0, $tbits ),