PleaseStand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/76739
Change subject: DiffHistoryBlob: don't check for mhash extension
......................................................................
DiffHistoryBlob: don't check for mhash extension
Checking for the mhash extension is pointless in PHP 5.3+ because
it only exists as B/C functions that are part of the hash extension.
From ext/hash/config.m4:
if test "$PHP_MHASH" != "no"; then
if test "$PHP_HASH" = "no"; then
PHP_HASH="yes"
fi
AC_DEFINE(PHP_MHASH_BC, 1, [ ])
fi
So if mhash() is compiled in, hash() must also be compiled in.
Change-Id: Ic376f4c438aaf701ebb4f1394ab6e4c1803fb8b8
---
M includes/HistoryBlob.php
M tests/phpunit/includes/DiffHistoryBlobTest.php
2 files changed, 11 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/39/76739/1
diff --git a/includes/HistoryBlob.php b/includes/HistoryBlob.php
index 46cf238..31aa0f8 100644
--- a/includes/HistoryBlob.php
+++ b/includes/HistoryBlob.php
@@ -530,7 +530,7 @@
$header = unpack( 'Vofp/Vcsize', substr( $diff, 0, 8 ) );
- # Check the checksum if hash/mhash is available
+ # Check the checksum if hash extension is available
$ofp = $this->xdiffAdler32( $base );
if ( $ofp !== false && $ofp !== substr( $diff, 0, 4 ) ) {
wfDebug( __METHOD__ . ": incorrect base checksum\n" );
@@ -577,24 +577,23 @@
* Compute a binary "Adler-32" checksum as defined by LibXDiff, i.e.
with
* the bytes backwards and initialised with 0 instead of 1. See bug
34428.
*
- * Returns false if no hashing library is available
+ * @param string $s
+ * @return string|bool: false if the hash extension is not available
*/
function xdiffAdler32( $s ) {
+ if ( !function_exists( 'hash' ) ) {
+ return false;
+ }
+
static $init;
if ( $init === null ) {
$init = str_repeat( "\xf0", 205 ) . "\xee" .
str_repeat( "\xf0", 67 ) . "\x02";
}
+
// The real Adler-32 checksum of $init is zero, so it
initialises the
// state to zero, as it is at the start of LibXDiff's checksum
// algorithm. Appending the subject string then simulates
LibXDiff.
- if ( function_exists( 'hash' ) ) {
- $hash = hash( 'adler32', $init . $s, true );
- } elseif ( function_exists( 'mhash' ) ) {
- $hash = mhash( MHASH_ADLER32, $init . $s );
- } else {
- return false;
- }
- return strrev( $hash );
+ return strrev( hash( 'adler32', $init . $s, true ) );
}
function uncompress() {
diff --git a/tests/phpunit/includes/DiffHistoryBlobTest.php
b/tests/phpunit/includes/DiffHistoryBlobTest.php
index 53f33d9..d927b7a 100644
--- a/tests/phpunit/includes/DiffHistoryBlobTest.php
+++ b/tests/phpunit/includes/DiffHistoryBlobTest.php
@@ -12,8 +12,8 @@
return;
}
- if ( !extension_loaded( 'hash' ) && !extension_loaded( 'mhash'
) ) {
- $this->markTestSkipped( 'Neither the hash nor mhash
extension is available' );
+ if ( !extension_loaded( 'hash' ) ) {
+ $this->markTestSkipped( 'The hash extension is not
available' );
return;
}
--
To view, visit https://gerrit.wikimedia.org/r/76739
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic376f4c438aaf701ebb4f1394ab6e4c1803fb8b8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: PleaseStand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits