I get the following error when trying to use sparkline in a post:

Fatal error: Cannot redeclare error_handler() (previously declared in /home/mpcollab/public_html/MPbeta/includes/common.inc:540) in /home/mpcollab/public_html/MPbeta/modules/sparkline/sparkline-php-0.2/lib/Object.php on line 22

Comments

Chris Johnson’s picture

This is a known limitation with the library the sparkline module uses, and a known problem with Drupal core polluting the namespace.

You will need to rename the duplicate function in the Sparkline library, for now. Sorry.

Chris Johnson’s picture

mcurry’s picture

*subscribe*

Chris Johnson’s picture

Assigned: Unassigned » Chris Johnson
Status: Active » Closed (won't fix)

It appears that Drupal 5 core will not be changed to fix this conflict. So until then, sparkline users will have to hand edit their sparkline library file to rename the error_handler function.

This is fixed in core in Drupal 6.

fm’s picture

You will need to rename the duplicate function in the Sparkline library, for now. Sorry.

I am only a novice at programming. Would you mind specifying the exact items to be renamed including the file names and line numbers? What should the new names be?

I performed a search and replace on all four lib files, changing "error_handler" to "sparkline_error_handler." Unfortunately, using the sparkline filter now just produces a blank page with no error recorded in the logs.

fm’s picture

Status: Closed (won't fix) » Active
Chris Johnson’s picture

Category: bug » support
Status: Active » Closed (fixed)

At approximately line 22 in file lib/Object.php, change "function error_handler" to function sparkline_error_handler".

At approximately line 93 in the same file, change "set_error_handler('error_handler')" to "set_error_handler('sparkline_error_handler')".

fm’s picture

Thanks, that got it working.