|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39559 Levenstein.c gives spurious additional warning if custom_levdist is called
Submitted: 2006-11-20 15:39 UTC Modified: 2006-11-21 17:43 UTC
From: zoe dot slattery at googlemail dot com Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 5CVS-2006-11-20 (snap) OS: Linux
Private report: No CVE-ID: None
 [2006-11-20 15:39 UTC] zoe dot slattery at googlemail dot com
I started by modifying the levenshtein test function ext/standard/tests/general_functions/003.phpt to cover the case where custom_levdist is called and to add some checks that the behviour is correct if strings > 255 chars are passed to levenshtein.c

A patch to the test case is provided here:

the new test case covers >90% of the code.

Unfortunately the new test case showed that when custom_levdist is called two warnings are issued. The first of these warns correctly that "The general Levenstein support is not there yet", the second warning ("Arguments strings(s) too long") is issued incorrectly.

I have attached a suggested patch to ext/standard/levenshtein.c here ( which corrects this.

Reproduce code:
The way to reproduce is to use the modified testcase - linked above.

Note that I have also modified the tescase to expect a return code of -2 from custom_levdist (rather than -1) 

Expected result:
Warning "The general Levenshtein support is not there yet"

Actual result:
Warning "The general Levenshtein support is not there yet"
Warning "Argument string(s) too long"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-20 16:23 UTC]
Please put the testcase somewhere and paste the URL here.
Applying copy/pasted patches is not trivial.
 [2006-11-21 17:08 UTC] zoe dot slattery at googlemail dot com
Apologies for making this harder than it should be.

Here is a link to the test case that fails when run against the PHP 5.2 snap.

Here is a link to teh version of the test case that matches the suggested fix to levenshtein.c. This test case matches the diff to ext/standard/tests/general_functions/003.phpt that I submitted originally.
 [2006-11-21 17:43 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Nov 27 05:05:53 2022 UTC