Last modified: 2013-08-28 00:12:02 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T40185, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 38185 - Use md5() instead of hash() for hashing
Use md5() instead of hash() for hashing
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: High minor (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-05 05:07 UTC by badon
Modified: 2013-08-28 00:12 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description badon 2012-07-05 05:07:30 UTC
I just tested usage of #suboject in SMW 1.7.0.2 and 1.7.1. Both versions give the follow error on page save, with the action=submit URL parameter:

Fatal error: Call to undefined function hash_init() in /path/to/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php on line 172

The URL does not load, but returning to view the page reveals that the edit was never saved. I tried this with a transcluded template to get around the page save, and the results were the same. This was the minimum required text to trigger the bug:

{{#subobject:}}
Comment 1 badon 2012-07-05 05:19:07 UTC
The trigger does not seem to work on SMW 1.8 Alpha:

http://scratchpad.referata.com/wiki/Main_Page/Bug_38185

I don't know if there's some other factor involved or not, but the release notes do not mention any changes affecting #subobject:

https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/extensions/SemanticMediaWiki.git;a=blob;f=RELEASE-NOTES
Comment 2 MWJames 2012-07-08 23:55:42 UTC
The above message "Call to undefined function hash_init()" shows that the PHP used does not inherent this function (has nothing to do with SMW). 

hash_init is available from (PHP 5 >= 5.1.2, PECL hash >= 1.1) onwards and with [1] stating clear that PHP 5.2 is required therefore this is not a SMW bug.

## Note
[1] http://semantic-mediawiki.org/wiki/Help:Installation
Comment 3 badon 2012-07-09 10:18:20 UTC
I don't think the reason for closing this is correct, so I'm reopening it. This bug was found on a much more recent version of PHP than you described. Here's the output of php --version:

PHP 5.3.14 with Suhosin-Patch (cli) (built: Jun 22 2012 09:31:19)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
Comment 4 Markus Krötzsch 2012-07-30 13:31:51 UTC
Some PHP distributions disable hashing support by default; esp. this is reported for FreeBSD. You could install the according PHP functions. This makes the bug far less critical.

However, there is also a function "md5()" in PHP that we might prefer to use, since it is apparently not causing problems on your site (MW uses it in many places, maybe out of similar considerations). It should also be quite fast. I change this bug to ask for this change now.
Comment 5 Markus Krötzsch 2012-10-17 19:27:17 UTC
Ultimately fixed in https://gerrit.wikimedia.org/r/#/c/28399/

However, the only function that still used the problematic hash methods is not currently called in SMW. Hence, the bug should have disappeared earlier already.
Comment 6 badon 2013-06-18 20:19:32 UTC
I encountered this bug in SMW 1.8.0.5, in SMW_Show:

http://wikimedia.7.x6.nabble.com/SMW-1-8-PHP-Fatal-error-Call-to-undefined-function-hash-td5006421.html#a5006484

I had forgotten that I had already reported this issue here. It is FreeBSD where we encountered the problem. I'm reopening it based on Markus's comments that indicate this should be fixed. I'm not sure, but maybe the problem in 1.8.0.5 is actually a regression, and not really the same bug as this one? If so, it might be better to close this bug as FIXED again, and then open a new one.
Comment 7 Jeroen De Dauw 2013-06-18 20:45:48 UTC
hash_init is no longer present in 1.8.
Comment 8 badon 2013-06-18 21:21:02 UTC
Comment 4 indicates the problem also lies in hash(), which is used in 1.8.0.5 on line 43 in this file:

\path\to\SemanticMediaWiki\includes\parserhooks\SMW_Show.php

This is the line in use:

$queryKey = hash( 'md4', implode( '|', $rawParams ) , false );

Comment 5 indicates that hash() was not being used in SMW 1.7, so this may indeed be a regression. Jeroen, should I open a separate bug for it, or can we keep it all in one place here?
Comment 9 Jeroen De Dauw 2013-06-18 21:25:34 UTC
This bug is fine. Indeed still using hash. For md4... Not sure what a better alternative is, of why this is breaking for you.
Comment 10 badon 2013-06-18 22:31:51 UTC
Markus says in comment #4 that some PHP distributions disable hashing support by default. He mentioned FreeBSD is one of them does that, and that's what my server is using. He also suggests that we could use md5() instead of hash() to eliminate the problem, and ensure wider compatibility. I don't know why hash() is disabled by default in some PHP distributions. I've never heard of this problem for anything except SMW, but the PHP gurus seemed to be familiar with it, and I assume they agree with Markus to just use MD5 instead. 

I did some researching about MD4 versus MD5, and I found out that MD4 has much faster performance. Because of that, simply switching to md5() instead of hash() might not be the ideal solution. Instead, the problem could be solved by checking for hash(), and if it is unavailable, switch to using md5(). If that's what ends up being done, then it should be mentioned in the documentation somewhere that enabling hash() will result in a small performance improvement.
Comment 11 MWJames 2013-08-28 00:12:02 UTC
SMW 1.9 ([1], [2]) relies on \SMW\HashIdGenerator to generate appropriate information.

[1] https://gerrit.wikimedia.org/r/#/c/80502/
[2] https://gerrit.wikimedia.org/r/#/c/75286/

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links