Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.1.3

Request #10594 $bSendToBrowser - "Only variable references should be returned by reference"
Submitted: 2007-04-02 20:16 UTC
From: permafour Assigned:
Status: Wont fix Package: Image_Barcode (version 1.1.0)
PHP Version: 5.2.1 OS: SuSE 10.0
Roadmaps: (Not assigned)    
Subscription  


 [2007-04-02 20:16 UTC] permafour (Vincent Rivellino)
Description: ------------ When the $bSendToBrowser option is enabled in Image::Barcode->draw(), PHP Notice messages are generated at each draw. A patch to fix this: --- Barcode.php 2007-04-02 11:25:26.000000000 -0400 +++ Barcode.new.php 2007-04-02 16:00:34.000000000 -0400 @@ -106,9 +106,8 @@ imagedestroy($img); break; } - } else { - return $img; - } + } + return $img; } } ?> Test script: --------------- <?php require_once('Image/Barcode.php'); $BarCodeObj = new Image_Barcode(); $BarCodeObj->draw(1234,'code128','gif'); ?> Expected result: ---------------- Barcode printed to browser without error messages. Actual result: -------------- Barcode is printed to browser, but a PHP Notice is printed to the error log: [Mon Apr 02 16:04:57 2007] [error] [client x.x.x.x] PHP Notice: Only variable references should be returned by reference in /usr/local/php/lib/php/Image/Barcode.php on line 112

Comments

 [2008-04-06 08:57 UTC] doconnor (Daniel O'Connor)
Swapping this to a feature request to 'become e_strict compliant'
 [2010-01-23 03:23 UTC] adrian_m (Adrian Mugica)
 [2010-01-25 22:01 UTC] cweiske (Christian Weiske)
Adrian, your patch breaks the package on PHP4. Remember that we have to keep backwards compatibility. The correct way would be to set $img to "null" in ifsendtobrowser and then return $img at the bottom of the method.
 [2010-01-25 23:25 UTC] adrian_m (Adrian Mugica)
 [2010-01-25 23:31 UTC] adrian_m (Adrian Mugica)
I've attached a revised the patch that should work. I'll make sure to test any other future fixes against PHP4 as well.
 [2010-01-26 12:01 UTC] cweiske (Christian Weiske)
Adam, that patch will not work, because you never return the image when it is needed. Did you really test it? I meant you should set $img to null when the image is being sent to the browser, not when it shall be returned.
 [2010-02-05 23:31 UTC] adrian_m (Adrian Mugica)
Christian, Yes, I tested it. My patch does set $img to null when the image is being sent to the browser, and it does not when it is being returned.
 [2011-12-10 18:15 UTC] doconnor (Daniel O'Connor)
-Status: Open +Status: Wont fix
This won't be fixed in this package - Image_Barcode2 however, sure.