MediaWiki REL1_28
Go to the documentation of this file.
6class FileContentsHasherTest extends PHPUnit_Framework_TestCase {
8 public function provideSingleFile() {
9 return array_map( function ( $file ) {
10 return [ $file, file_get_contents( $file ) ];
11 }, glob( __DIR__ . '/../../data/filecontentshasher/*.*' ) );
12 }
14 public function provideMultipleFiles() {
15 return [
16 [ $this->provideSingleFile() ]
17 ];
18 }
25 public function testSingleFileHash( $fileName, $contents ) {
26 foreach ( [ 'md4', 'md5' ] as $algo ) {
27 $expectedHash = hash( $algo, $contents );
28 $actualHash = FileContentsHasher::getFileContentsHash( $fileName, $algo );
29 $this->assertEquals( $expectedHash, $actualHash );
30 $actualHashRepeat = FileContentsHasher::getFileContentsHash( $fileName, $algo );
31 $this->assertEquals( $expectedHash, $actualHashRepeat );
32 }
33 }
40 public function testMultipleFileHash( $files ) {
41 $fileNames = [];
42 $hashes = [];
43 foreach ( $files as $fileInfo ) {
44 list( $fileName, $contents ) = $fileInfo;
45 $fileNames[] = $fileName;
46 $hashes[] = md5( $contents );
47 }
49 $expectedHash = md5( implode( '', $hashes ) );
50 $actualHash = FileContentsHasher::getFileContentsHash( $fileNames, 'md5' );
51 $this->assertEquals( $expectedHash, $actualHash );
52 $actualHashRepeat = FileContentsHasher::getFileContentsHash( $fileNames, 'md5' );
53 $this->assertEquals( $expectedHash, $actualHashRepeat );
54 }
testMultipleFileHash( $files)
FileContentsHasher::getFileContentsHash FileContentsHasher::getFileContentsHashInternal provideMultip...
testSingleFileHash( $fileName, $contents)
FileContentsHasher::getFileContentsHash FileContentsHasher::getFileContentsHashInternal provideSingle...
static getFileContentsHash( $filePaths, $algo='md4')
Get a hash of the combined contents of one or more files, either by retrieving a previously-computed ...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37