From: Reedy Date: Tue, 24 Nov 2015 22:51:42 +0000 (+0000) Subject: Replace wfBaseConvert with Wikimedia\base_convert X-Git-Tag: 1.31.0-rc.0~8878 X-Git-Url: https://git.cyclocoop.org//%22?a=commitdiff_plain;h=00c426e3c28be0810770f11f9f2736d3cf1eefb7;p=lhc%2Fweb%2Fwiklou.git Replace wfBaseConvert with Wikimedia\base_convert Change-Id: Iadab3d018c3559daf79be90edb23d131729bdb68 --- diff --git a/includes/Import.php b/includes/Import.php index f0576d7419..519f74a81b 100644 --- a/includes/Import.php +++ b/includes/Import.php @@ -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; } diff --git a/includes/Revision.php b/includes/Revision.php index 3b98a65aea..1d7ac72542 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -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 ); } /** diff --git a/includes/api/ApiQueryAllImages.php b/includes/api/ApiQueryAllImages.php index 699cba8629..6c7e69b4f3 100644 --- a/includes/api/ApiQueryAllImages.php +++ b/includes/api/ApiQueryAllImages.php @@ -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 ) ) { diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php index 76f594e277..fe2ec8fca7 100644 --- a/includes/api/ApiQueryDeletedrevs.php +++ b/includes/api/ApiQueryDeletedrevs.php @@ -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'] = ''; } diff --git a/includes/api/ApiQueryFilearchive.php b/includes/api/ApiQueryFilearchive.php index 8156edb901..71be951b61 100644 --- a/includes/api/ApiQueryFilearchive.php +++ b/includes/api/ApiQueryFilearchive.php @@ -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 ); diff --git a/includes/api/ApiQueryImageInfo.php b/includes/api/ApiQueryImageInfo.php index 0a8e2c928d..8dbd812c78 100644 --- a/includes/api/ApiQueryImageInfo.php +++ b/includes/api/ApiQueryImageInfo.php @@ -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 ) { diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 0a11f4b7bb..c99d87cb74 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -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'] = ''; } diff --git a/includes/api/ApiQueryRevisionsBase.php b/includes/api/ApiQueryRevisionsBase.php index 5bc1e795a0..d7fb580da7 100644 --- a/includes/api/ApiQueryRevisionsBase.php +++ b/includes/api/ApiQueryRevisionsBase.php @@ -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'] = ''; } diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index 9c5127f952..4d9891e886 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -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 diff --git a/includes/externalstore/ExternalStoreMwstore.php b/includes/externalstore/ExternalStoreMwstore.php index 89ac734517..c3c5dcb79a 100644 --- a/includes/externalstore/ExternalStoreMwstore.php +++ b/includes/externalstore/ExternalStoreMwstore.php @@ -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 diff --git a/includes/filebackend/FSFile.php b/includes/filebackend/FSFile.php index 213bb87dee..2604c88d65 100644 --- a/includes/filebackend/FSFile.php +++ b/includes/filebackend/FSFile.php @@ -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; diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php index 1432bb95e9..e21aaeab42 100644 --- a/includes/filebackend/FileBackendStore.php +++ b/includes/filebackend/FileBackendStore.php @@ -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 ); } } diff --git a/includes/filebackend/FileOp.php b/includes/filebackend/FileOp.php index 5d4e8e11c2..8359943466 100644 --- a/includes/filebackend/FileOp.php +++ b/includes/filebackend/FileOp.php @@ -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; diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index 72a877d072..93d8d07a98 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -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'] ); diff --git a/includes/filebackend/filejournal/FileJournal.php b/includes/filebackend/filejournal/FileJournal.php index 4ee5222007..2f39dad25f 100644 --- a/includes/filebackend/filejournal/FileJournal.php +++ b/includes/filebackend/filejournal/FileJournal.php @@ -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 ); } /** diff --git a/includes/filebackend/lockmanager/DBLockManager.php b/includes/filebackend/lockmanager/DBLockManager.php index 2c86c378a7..c93b4b4195 100644 --- a/includes/filebackend/lockmanager/DBLockManager.php +++ b/includes/filebackend/lockmanager/DBLockManager.php @@ -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 ) ) ); diff --git a/includes/filebackend/lockmanager/LockManager.php b/includes/filebackend/lockmanager/LockManager.php index 8115fd42a9..7605a9b49e 100644 --- a/includes/filebackend/lockmanager/LockManager.php +++ b/includes/filebackend/lockmanager/LockManager.php @@ -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 ); } /** diff --git a/includes/filerepo/file/ForeignAPIFile.php b/includes/filerepo/file/ForeignAPIFile.php index cad806d6a3..26ea38b223 100644 --- a/includes/filerepo/file/ForeignAPIFile.php +++ b/includes/filerepo/file/ForeignAPIFile.php @@ -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; } diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php index ed2d0fab2e..f10866e55a 100644 --- a/includes/jobqueue/JobQueueDB.php +++ b/includes/jobqueue/JobQueueDB.php @@ -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 ), diff --git a/includes/jobqueue/JobQueueRedis.php b/includes/jobqueue/JobQueueRedis.php index deb5aa5a3a..78d2a360f9 100644 --- a/includes/jobqueue/JobQueueRedis.php +++ b/includes/jobqueue/JobQueueRedis.php @@ -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 ); diff --git a/includes/password/PasswordFactory.php b/includes/password/PasswordFactory.php index e1f272b4c3..6b634cbea7 100644 --- a/includes/password/PasswordFactory.php +++ b/includes/password/PasswordFactory.php @@ -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 ); } /** diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index e241383c0b..53f0cd2823 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -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; diff --git a/includes/utils/IP.php b/includes/utils/IP.php index 9f522495ac..119805e8de 100644 --- a/includes/utils/IP.php +++ b/includes/utils/IP.php @@ -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"; diff --git a/includes/utils/UIDGenerator.php b/includes/utils/UIDGenerator.php index 26eebcd415..f6f3c5fc3d 100644 --- a/includes/utils/UIDGenerator.php +++ b/includes/utils/UIDGenerator.php @@ -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 ); } /** diff --git a/maintenance/benchmarks/bench_wfBaseConvert.php b/maintenance/benchmarks/bench_wfBaseConvert.php index b4be12bc8c..deed389474 100644 --- a/maintenance/benchmarks/bench_wfBaseConvert.php +++ b/maintenance/benchmarks/bench_wfBaseConvert.php @@ -1,6 +1,6 @@ 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' ) ), ) ); diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index 005ade56a9..f29e8b89f5 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -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 { ', - 'sha1' => wfBaseConvert( '', 16, 36, 31 ), + 'sha1' => Wikimedia\base_convert( '', 16, 36, 31 ), 'fileExists' => true ), $this->db->timestamp( '20010115123600' ), $user ); } diff --git a/tests/phpunit/includes/filebackend/FileBackendTest.php b/tests/phpunit/includes/filebackend/FileBackendTest.php index 95c6092b45..9bef8e0577 100644 --- a/tests/phpunit/includes/filebackend/FileBackendTest.php +++ b/tests/phpunit/includes/filebackend/FileBackendTest.php @@ -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" ); } diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index f7c428a66d..6948082079 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -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 { ', - 'sha1' => wfBaseConvert( '', 16, 36, 31 ), + 'sha1' => Wikimedia\base_convert( '', 16, 36, 31 ), 'fileExists' => true ), $this->db->timestamp( '20140115123600' ), $user ); } diff --git a/tests/phpunit/includes/utils/UIDGeneratorTest.php b/tests/phpunit/includes/utils/UIDGeneratorTest.php index fedcc762de..89b2c172b0 100644 --- a/tests/phpunit/includes/utils/UIDGeneratorTest.php +++ b/tests/phpunit/includes/utils/UIDGeneratorTest.php @@ -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 ),