Problem/Motivation

When Drupal generates and queues multiple message lines for display, logging_alerts throws the following PHP error: Warning: levenshtein() [function.levenshtein]: Argument string(s) too long in /█/█/█/█/html/sites/all/modules/logging_alerts/emaillog/emaillog.module on line 84.

Proposed resolution

Change

levenshtein($log['type'] . $log['message'], $last_message['message'])

to

levenshtein(explode(", ",$log['type'] . $log['message']), explode(", ",$last_message['message']))

based on the advice found here. This assumes that the messages are comma-delimited, which I have not checked.

Remaining tasks

  1. Determine in what format Drupal queues messages for display (comma-delimited, or whatever).
  2. Use this information to determine why levenshtein() doesn't like that format.
  3. Modify $log['type'] . $log['message'], $last_message['message'] in line 84 to reflect that insight.

User interface changes

None.

API changes

None.

Comments

mavaddat’s picture

Issue summary: View changes

Fixed ordered list HTML.

mavaddat’s picture

Issue summary: View changes

Clarified remaining tasks.

mavaddat’s picture

Issue summary: View changes

Corrected code citation in Problem/Motivation

Question’s picture

Category: bug » support

Hi,

Any news about this?

FreeFox’s picture

I tried that change but it resulted in this error:

Warning: levenshtein() expects parameter 1 to be string, array given in emaillog_watchdog() (line 85 of .../sites/all/modules/contrib/logging_alerts/emaillog/emaillog.module).

Hope this helps.

mavaddat’s picture

Thank you for that, FreeFox. Do you reckon (as I have that) the problem arises from too many system messages being parsed by levenshtein() at once? I arrived at this conclusion by observing a persistent correlation between this error and multiple messages being printed. Or could problem be elsewhere?

FreeFox’s picture

No, I guess that levenshtein() expects the first parameter to be string and not an array given in emaillog_watchdog()

Your response made me analyze the error message and now it looks simple. When my project is finished (already past deadline) I'll look into this but feel free (anyone) to check it out as I have 50+ projects to finish :(

deanflory’s picture

Will there be an update to this module in 2013 to address this issue?

niccottrell’s picture

Looks like both arguments are strings to me (in the D6 version at least):

  [6] => Array
       (
           [file] => /data/www/cn6/sites/all/modules/logging_alerts/emaillog/emaillog.module
           [line] => 82
           [function] => levenshtein
           [args] => string(317), string(35)
       )

According to the PHP docs at http://www.php.net/manual/en/function.levenshtein.php :

This function returns the Levenshtein-Distance between the two argument strings or -1, if one of the argument strings is longer than the limit of 255 characters.

So maybe a newer version of PHP would help? Although we already have 5.3.3

maciej.zgadzaj’s picture

Category: support » bug
Status: Active » Fixed

levenshtein() has been replaced with similar_text(), just pushed commits to 7.x-2.x and 6.x-2.x branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Reverted my last, confused "correction".