|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #69878 Undocumented change in imagejpeg behavior
Submitted: 2015-06-18 17:22 UTC Modified: 2015-06-18 19:23 UTC
From: teo8976 at gmail dot com Assigned: cmb (profile)
Status: Closed Package: GD related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2015-06-18 17:22 UTC] teo8976 at gmail dot com
From manual page:

bool imagejpeg ( resource $image [, string $filename [, int $quality ]] )

"To skip this argument [$filename] in order to provide the quality parameter, use NULL."

At some version between 5.2.17 and 5.4.29, the behavior has changed in the case where $filename equals ''.

In 5.2.17, passing '' would yield the same result as passing NULL. 
In 5.4.29, passing '' results in the error message "filename cannot be empty" (as expected).

Although the documentation says that the value to use is null (dunnow if it has  always been stated as clearly as it is now), and even if the change in behavior is a fix to a bug, the change MUST be documented, including the exact version when the behavior has changed.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-18 17:27 UTC] teo8976 at gmail dot com
I've found 2 unrelated php-based softwares (vBulletin and MyClientBase) that in old versions used
  imagejpeg($someimage, '', $quality);

That seems a strange coincidence, which makes me suspect that either the documentation was less clear in the past about the value to use for skipping the argument, or it explicitly allowed the use of ''.

Either way, this is one more reason for documenting the change in behavior.
 [2015-06-18 18:58 UTC]
-Status: Open +Status: Verified -Package: Documentation problem +Package: GD related -Assigned To: +Assigned To: cmb
 [2015-06-18 18:58 UTC]
The behavior to not accept an empty string for the $filename
parameter has been changed as of PHP 5.4.0 (ZPP s→p). However, the
relevant part of the documentation has already been changed nearly
nine years ago[1] (i.e. long before PHP 5.4.0 has been released).

[1] <>
 [2015-06-18 19:22 UTC]
Automatic comment from SVN on behalf of cmb
Log: added changelog (fixes #69878)
 [2015-06-18 19:23 UTC]
-Status: Verified +Status: Closed
 [2015-06-18 19:23 UTC]
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jun 12 14:01:35 2024 UTC