php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15288 Image*-functions being avail even if they're not implemented by gd
Submitted: 2002-01-29 20:53 UTC Modified: 2002-03-02 07:33 UTC
Votes:3
Avg. Score:3.7 ± 1.9
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: matslin at orakel dot ntnu dot no Assigned:
Status: Closed Package: GD related
PHP Version: 4.1.1 OS: All
Private report: No CVE-ID: None
 [2002-01-29 20:53 UTC] matslin at orakel dot ntnu dot no
The Image*-functions specific for different formats are available even if they're not supported in GD. Even though this is understandable, a better practice would probably be to disable these functions, since they're not available.(so they can be checked for existance in runtime, instead of relying on errors passed back from gd)

It shouldnt be much of a change, since i was able to create the desired effect using a few #ifdef's - and i've only got spare knowledge of c.

http://software.e-mats.org/patches/gd_4.1.1.diff contains the diff for the gd.c-file from 4.1.1. that i used for testing.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-29 23:06 UTC] cardinal@php.net
There is already a clean way to check which image formats are supported:

http://www.php.net/manual/en/function.imagetypes.php
 [2002-01-30 07:39 UTC] matslin at orakel dot ntnu dot no
.. this does however not cover the TTF*-functions.
 [2002-01-30 08:13 UTC] mfischer@php.net
This one seems really a mess to me (declaring function which output "not implemented") when we have 'function_exists()'.

Reopening for discussion.
 [2002-01-30 08:47 UTC] matslin at orakel dot ntnu dot no
This is excactly the point i'm trying to make. To me it seems like the most logical thing would be to not implement the function at all, since this would make function_exists() work as expected. Implementing the function (to give an error message) - even though its not available seems kinda useless, since this also makes it harder to make a general solution.
 [2002-01-30 08:51 UTC] derick@php.net
I'm +1 on your patch as well, can you make it against the latest CVS version?

I'll make sure it gets committed then.

regards,
Derick
 [2002-01-30 10:41 UTC] matslin at orakel dot ntnu dot no
I've made a small patch based on the CVS-version that remove functions that are not available. I'm not sure if i caught them all, but i made a try :-) I've not removed the original error-messages ("gd was compiled without support.."), so they're still in there (maybe a define or ./configure-option to select what way error-reporting should be done).

the diff:
http://software.e-mats.org/patches/gd.c-diff-2002-01-30

the source:
http://software.e-mats.org/patches/gd.c-cvs-2002-01-30

 [2002-02-02 18:36 UTC] matslin at orakel dot ntnu dot no
I've also created a patch that remove the functions from the binary/module (if they're not available);

http://software.e-mats.org/patches/gd.c-diff-2002-02-02

(i also moved this to 'GD related'.)
 [2002-03-01 22:09 UTC] matslin at orakel dot ntnu dot no
Did anything happen in this case? Did it just disappear into the magic night? 4.1.2 still has the same old code in, a small CVS-change for the TrueColor-functions .. but this (in my mind) broken approach is still there.

Any reason why it wasnt included?
 [2002-03-02 00:28 UTC] rasmus@php.net
I worry about backward compatibility issues here.  I agree that non-implemented functions should be be defined, but the gd extension I think was the first ever PHP extension I originally wrote years and years ago now and it hasn't changed all that much over the years.

I guess the BC issues wouldn't be too bad since the error message was fatal before so people couldn't really write code to check if the function was there or not.
 [2002-03-02 06:20 UTC] derick@php.net
4.1.2 was only a security fix, and new code only goes to the HEAD branch. I'll now add your patch to the CVS, the changes will be in PHP 4.2.0.

Derick
 [2002-03-02 07:33 UTC] derick@php.net
Applied to CVS. Thx!

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC