php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21462 set_error_handler not properly executed?
Submitted: 2003-01-06 09:01 UTC Modified: 2003-01-06 21:03 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: duh at dowebwedo dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.0 OS: Linux Slackware
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: duh at dowebwedo dot com
New email:
PHP Version: OS:

 

 [2003-01-06 09:01 UTC] duh at dowebwedo dot com
Today we upgraded from php 4.2.3 (apache 1.3.26) to php 4.3.0.

We use freetype functionality in a set of functions and to keep this very flexible the following code (except for the debugging prints) is used to determine what freetype version was installed in order to use the right functions (imagefttext or imagettftext).

This function (the set_error_handler) stopped working properly after upgrading to 4.3.0

  print freetype_version();

  function freetype_version() {
        // change error handler
        set_error_handler("freetype_version_handler");
                        
        // remove freetype version from session
        unset($_SESSION['freetype_version']);
                 
        // determine check array
        $checkers       = array(
                "imagefttext"   => 2,           // freetype version specific function -> freetype version
                "imagettftext"  => 1
        );              
  
        // run checkers
        while (list($key,$val)=each($checkers)) {
printf("%s:%s<br>\n",$key,$val);
                eval(sprintf("%s();",$key));
        }
         
        // restore old error handler
        restore_error_handler();
        
        // return version (null = no freetype support)
        return $_SESSION['freetype_version'];
  }
   
  function freetype_version_handler($errno,$errstr,$errfile,$errline,$variables) {
print "errorrr!<br>\n";
        if (eregi(sprintf("wrong parameter count for %s",$variables['key']),$errstr)) {
                $_SESSION['freetype_version']   = $variables['val'];
        }
  }

The code outputs the following error:
Fatal error: Call to undefined function: imagefttext() in /sda6/domains/betterbeyourself.com_staging/includes/fnc_lang.inc(651) : eval()'d code on line 1

We allready use a custom error handler so the above handler is nested... this however worked very well in 4.2.3 I also noticed the same problems in some 4.3.0 developmental cvs snapshots (don't know which snapshots they were though) and thought it was a bug to be solved before the stable release but appearantly it's still there.... 

Grtz,

Jeroen

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-06 15:03 UTC] jbernier at dalcom-intl dot com
I am also experimenting this. My function used as error handling now gives me array in all the parameters.

Ex. :

function my_error_handler($errno,$errstr,$errfile,$errline,$variables) 

$errno = array
$errstr = array
etc...
 [2003-01-06 21:03 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You cannot 'capture' fatal errors, your approach to checking function avaliablity is flawed. Instead of trying to execute the function, why not use function_exists(), which will accurately tell you if a function is avaliable or not.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 03 21:01:31 2024 UTC