[PHP-BUG] Bug #55132 [NEW]: String access to an expression gives parse error
From: Operating system: Windows 7 PHP version: 5.3.6 Package: Scripting Engine problem Bug Type: Bug Bug description:String access to an expression gives parse error Description: As documented, accessing variables of other types [...] using [] or {} silently returns NULL. Because of this it is necessary to cast an integer to string before string access can be done. However, this results in a parse error. Test script: --- $i = 123; echo $i{1}; // - empty (expected) echo ((string)$i){1}; // - parse error -- Edit bug report at https://bugs.php.net/bug.php?id=55132edit=1 -- Try a snapshot (PHP 5.2): https://bugs.php.net/fix.php?id=55132r=trysnapshot52 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55132r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55132r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55132r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55132r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55132r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55132r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55132r=needscript Try newer version: https://bugs.php.net/fix.php?id=55132r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55132r=support Expected behavior: https://bugs.php.net/fix.php?id=55132r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55132r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55132r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55132r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55132r=php4 Daylight Savings:https://bugs.php.net/fix.php?id=55132r=dst IIS Stability: https://bugs.php.net/fix.php?id=55132r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55132r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55132r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55132r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55132r=mysqlcfg Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55132r=trysnapshot54
Bug #55132 [Bgs]: String access to an expression gives parse error
Edit report at https://bugs.php.net/bug.php?id=55132edit=1 ID: 55132 User updated by:andre at webkr dot de Reported by:andre at webkr dot de Summary:String access to an expression gives parse error Status: Bogus Type: Bug Package:Scripting Engine problem Operating System: Windows 7 PHP Version:5.3.6 Block user comment: N Private report: N New Comment: I double-checked the manual, there it says: Characters within strings may be accessed and modified by specifying the zero-based offset of the desired character after the string using square array brackets, as in $str[42]. [...] Strings may also be accessed using braces, as in $str{42}, for the same purpose. The expression ((string)$i) obviously is a string, as confirmed by var_dump(): string(3) 123 So I don't see which part of the manual you are referring to. Previous Comments: [2011-07-04 19:01:44] fel...@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 The syntax (...){..} is not intended to work. [2011-07-04 18:53:24] andre at webkr dot de Description: As documented, accessing variables of other types [...] using [] or {} silently returns NULL. Because of this it is necessary to cast an integer to string before string access can be done. However, this results in a parse error. Test script: --- $i = 123; echo $i{1}; // - empty (expected) echo ((string)$i){1}; // - parse error -- Edit this bug report at https://bugs.php.net/bug.php?id=55132edit=1
Bug #53848 [Opn]: fgetcsv ignores spaces at beginnings of fields
Edit report at http://bugs.php.net/bug.php?id=53848edit=1 ID: 53848 User updated by:andre at webkr dot de Reported by:andre at webkr dot de -Summary:fgetcsv ignores spaces on beginning of line +Summary:fgetcsv ignores spaces at beginnings of fields Status: Open Type: Bug Package:Filesystem function related Operating System: Windows 7 PHP Version:5.3.5 Block user comment: N Private report: N New Comment: Indeed, I overlooked that. I added your data to my test (without the quotes and line break, of course) and I can confirm that issue. I changed the summary accordingly. Previous Comments: [2011-04-15 19:49:51] mark dot mccray at tbwachiat dot com Same issue on Mac OS X 10.6.7 running PHP ver 5.3.4. [2011-04-15 19:40:41] mark dot mccray at tbwachiat dot com Forgot to add that we are on hp-ux 11.11i. Php ver 5.2.4. [2011-04-15 19:40:08] mark dot mccray at tbwachiat dot com I'm posting a comment here instead of a bug because I feel we may be encountering the same issue. My problem is that fgetcsv seems to trim whitespace at the beginning of any field -- not just at the beginning of a record. In a record (our files are separated by a pipe symbol): 001|5964_154|OGLCV|003| 174699|USD|0326049|Corporation||00|11/03/27||11/04/14|1|MPY||CP The field 174699 gets inserted into the array as 174699. We are expecting the leading whitespace to not be trimmed. [2011-02-11 14:50:52] phillip at grueter-online dot de Same problem in version 5.2.10 shell php --version PHP 5.2.10-2ubuntu6.5 php var_dump(file(csvtest.csv)); array(3) { [0]= string(4) a,b [1]= string(5) c,d [2]= string(1) } php $handle = fopen(csvtest.csv, r); php $a = fgetcsv($handle); php var_dump($a); array(2) { [0]= string(1) a [1]= string(1) b } php $a = fgetcsv($handle); php var_dump($a); array(2) { [0]= string(1) c [1]= string(1) d } [2011-01-26 13:49:48] andre at webkr dot de Description: RFC4180 says: Spaces are considered part of a field and should not be ignored. However (despite being the only CSV parsing function that fulfils all other requirements), fgetcsv ignores spaces at the very beginning of a record. Test script: --- /* Put this in a file: a,b c,d */ $fd = fopen('the_file','r'); $a = fgetcsv($fd); Expected result: array( array('a', 'b'), array(' c','d') ) Actual result: -- array( array('a', 'b'), array('c','d') ) -- Edit this bug report at http://bugs.php.net/bug.php?id=53848edit=1
[PHP-BUG] Bug #53848 [NEW]: fgetcsv ignores spaces on beginning of line
From: Operating system: Windows 7 PHP version: 5.3.5 Package: Filesystem function related Bug Type: Bug Bug description:fgetcsv ignores spaces on beginning of line Description: RFC4180 says: Spaces are considered part of a field and should not be ignored. However (despite being the only CSV parsing function that fulfils all other requirements), fgetcsv ignores spaces at the very beginning of a record. Test script: --- /* Put this in a file: a,b c,d */ $fd = fopen('the_file','r'); $a = fgetcsv($fd); Expected result: array( array('a', 'b'), array(' c','d') ) Actual result: -- array( array('a', 'b'), array('c','d') ) -- Edit bug report at http://bugs.php.net/bug.php?id=53848edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53848r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53848r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53848r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53848r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53848r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53848r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53848r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53848r=needscript Try newer version: http://bugs.php.net/fix.php?id=53848r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53848r=support Expected behavior: http://bugs.php.net/fix.php?id=53848r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53848r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53848r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53848r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53848r=php4 Daylight Savings:http://bugs.php.net/fix.php?id=53848r=dst IIS Stability: http://bugs.php.net/fix.php?id=53848r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53848r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53848r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53848r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53848r=mysqlcfg
#23815 [Com]: imagecopymerge doesn't respect alpha-channel in PNG-24 file
ID: 23815 Comment by: andre at webkr dot de Reported By: bjorn at smokingmedia dot com Status: Assigned Bug Type: Feature/Change Request Operating System: Linux pluto 2.4.18lvm-r1 PHP Version: 5.2.9 Assigned To: pajoye New Comment: So what does the it implements alpha transparency for true colour images in When pct = 0, no action is taken, when 100 this function behaves identically to imagecopy() for pallete images, while it implements alpha transparency for true colour images. mean anyway? Previous Comments: [2009-07-20 12:10:43] steve at redmonkey dot org Thanks, understood. Although, I do think it would be a useful feature, perhaps there's scope for an 'imagecopymergealpha' type function in the future? [2009-07-20 08:43:04] paj...@php.net imagecopymerge was not meant to support the alpha channel but to emulate it via pct. It was also not meant to use both the alpha or the pct value to blend an image over another. [2009-07-20 05:44:49] steve at redmonkey dot org To make life a little easier I've put the notes and examples together on a simple web page at http://www.redmonkey.org/php-bug-23815/ After investigating the code base a little further I've realised my patch solution can be made more efficient as there is no need to make a copy of the source or pass the image over to gdImageCopy once the new alpha level has been set as we've already done the all the work and can simply set the pixels RGBA index within the second image scan. The revised patch (which is also available from a link on the web page) is as follows --- php-5.3.0/ext/gd/libgd/gd.c 2009-05-27 08:17:54.0 +0100 +++ php-5.3.0-build/ext/gd/libgd/gd.c 2009-07-20 05:54:21.709936176 +0100 @@ -2255,6 +2255,67 @@ int ncR, ncG, ncB; toy = dstY; + if (pct == 100) { + /* no opacity adjustment required pass through to gdImageCopy() */ + gdImageCopy(dst, src, dstX, dstY, srcX, srcY, w, h); + return; + } + + if (pct == 0) { + /* 0% opacity? nothing needs to be done */ + return; + } + + if (src-trueColor dst-trueColor) { + /* support for maintaining the alpha (transparency) of both source and +* destination images (assuming they are true colour) while opacity blending. +*/ + int ca, cr, cg, cb; + float na; + float ac; + + /* we need to loop through the src image to get the max transparency level */ + int mt = 0; + + for (y = 0; y h; y++) { + for (x = 0; x w; x++) { + c = gdImageGetTrueColorPixel (src, srcX + x, srcY + y); + ca = gdImageAlpha(src, c); + + mt = ca mt ? ca : mt; + } + } + + /* src has no transparency? set to use full alpha range */ + mt = mt == gdAlphaOpaque ? gdAlphaMax : mt; + + /* alpha correction factor */ + ac = (float)mt / gdAlphaMax; + + /* loop through the image again and set/adjust alpha channel level */ + for (y = 0; y h; y++) { + for (x = 0; x w; x++) { + c = gdImageGetTrueColorPixel (src, srcX + x, srcY + y); + ca = gdImageAlpha(src, c); + cr = gdImageRed(src, c); + cg = gdImageGreen(src, c); + cb = gdImageBlue(src, c); + + na = (ca + gdAlphaMax - (gdAlphaMax * ((float)pct / 100))) * ac; + na = (na gdAlphaMax)? gdAlphaMax : ((na gdAlphaOpaque)? gdAlphaOpaque: na); + + int nc = gdImageColorAllocateAlpha(src, cr, cg, cb, (int)na); + if (nc == -1) { + gdImageColorClosestAlpha(src, cr, cg, cb, (int)na); + } + + gdImageSetPixel (dst, dstX + x, dstY + y, nc); + } + } + + return; + } + for (y = srcY; y (srcY + h); y++) { tox = dstX; for (x = srcX; x (srcX + w); x++) { [2009-07-20 01:52:43] steve dot denim at redmonkey dot org I have run into the same problem and can reproduce the example from checat at yandex dot ru. I have also provided additional examples
#23815 [Com]: imagecopymerge doesn't respect alpha-channel in PNG-24 file
ID: 23815 Comment by: andre at webkr dot de Reported By: bjorn at smokingmedia dot com Status: Assigned Bug Type: Feature/Change Request Operating System: Linux pluto 2.4.18lvm-r1 PHP Version: 5.2.9 Assigned To: pajoye New Comment: Ah, I see. It's imagecopy() which implements alpha transparency while imagecopymerge() does not. Previous Comments: [2009-12-10 18:23:20] andre at webkr dot de So what does the it implements alpha transparency for true colour images in When pct = 0, no action is taken, when 100 this function behaves identically to imagecopy() for pallete images, while it implements alpha transparency for true colour images. mean anyway? [2009-07-20 12:10:43] steve at redmonkey dot org Thanks, understood. Although, I do think it would be a useful feature, perhaps there's scope for an 'imagecopymergealpha' type function in the future? [2009-07-20 08:43:04] paj...@php.net imagecopymerge was not meant to support the alpha channel but to emulate it via pct. It was also not meant to use both the alpha or the pct value to blend an image over another. [2009-07-20 05:44:49] steve at redmonkey dot org To make life a little easier I've put the notes and examples together on a simple web page at http://www.redmonkey.org/php-bug-23815/ After investigating the code base a little further I've realised my patch solution can be made more efficient as there is no need to make a copy of the source or pass the image over to gdImageCopy once the new alpha level has been set as we've already done the all the work and can simply set the pixels RGBA index within the second image scan. The revised patch (which is also available from a link on the web page) is as follows --- php-5.3.0/ext/gd/libgd/gd.c 2009-05-27 08:17:54.0 +0100 +++ php-5.3.0-build/ext/gd/libgd/gd.c 2009-07-20 05:54:21.709936176 +0100 @@ -2255,6 +2255,67 @@ int ncR, ncG, ncB; toy = dstY; + if (pct == 100) { + /* no opacity adjustment required pass through to gdImageCopy() */ + gdImageCopy(dst, src, dstX, dstY, srcX, srcY, w, h); + return; + } + + if (pct == 0) { + /* 0% opacity? nothing needs to be done */ + return; + } + + if (src-trueColor dst-trueColor) { + /* support for maintaining the alpha (transparency) of both source and +* destination images (assuming they are true colour) while opacity blending. +*/ + int ca, cr, cg, cb; + float na; + float ac; + + /* we need to loop through the src image to get the max transparency level */ + int mt = 0; + + for (y = 0; y h; y++) { + for (x = 0; x w; x++) { + c = gdImageGetTrueColorPixel (src, srcX + x, srcY + y); + ca = gdImageAlpha(src, c); + + mt = ca mt ? ca : mt; + } + } + + /* src has no transparency? set to use full alpha range */ + mt = mt == gdAlphaOpaque ? gdAlphaMax : mt; + + /* alpha correction factor */ + ac = (float)mt / gdAlphaMax; + + /* loop through the image again and set/adjust alpha channel level */ + for (y = 0; y h; y++) { + for (x = 0; x w; x++) { + c = gdImageGetTrueColorPixel (src, srcX + x, srcY + y); + ca = gdImageAlpha(src, c); + cr = gdImageRed(src, c); + cg = gdImageGreen(src, c); + cb = gdImageBlue(src, c); + + na = (ca + gdAlphaMax - (gdAlphaMax * ((float)pct / 100))) * ac; + na = (na gdAlphaMax)? gdAlphaMax : ((na gdAlphaOpaque)? gdAlphaOpaque: na); + + int nc = gdImageColorAllocateAlpha(src, cr, cg, cb, (int)na); + if (nc == -1) { + gdImageColorClosestAlpha(src, cr, cg, cb, (int)na); + } + + gdImageSetPixel (dst, dstX + x, dstY + y, nc); + } + } + + return; + } + for (y = srcY; y (srcY + h); y++) { tox = dstX; for (x = srcX; x (srcX + w); x
#47785 [Com]: get_included_files resolves symlinks
ID: 47785 Comment by: andre at webkr dot de Reported By: andre at webkr dot de Status: Open Bug Type: Feature/Change Request Operating System: Linux PHP Version: 5.2.9 New Comment: It's even worse: When an included file includes another file using a relative path, that is looked up in the target directory of the symlink! It should be relative to the path where the symlink resides. The only access types that should treat the symlink in a special way are unlink (it should remove the symlink, not the target file) and chmod (it should do nothing). All other access types (especially the read involved here) should see the symlink as if it were a file with the content and attributes of the target file. Previous Comments: [2009-03-26 04:04:41] andre at webkr dot de Description: When a symlink is included/required, get_included_files shows the target of the symlink. Together with Bug #46260 this makes it completely impossible to determine how the file was really called when it was included. Reproduce code: --- include('path_to/a_symlink.php'); var_dump(get_included_files()); Expected result: An array containing a string [...]/path_to/a_symlink.php. Actual result: -- An array containing a string [...]/some_file.php. -- Edit this bug report at http://bugs.php.net/?id=47785edit=1
#47785 [NEW]: get_included_files resolves symlinks
From: andre at webkr dot de Operating system: Linux PHP version: 5.2.9 PHP Bug Type: Feature/Change Request Bug description: get_included_files resolves symlinks Description: When a symlink is included/required, get_included_files shows the target of the symlink. Together with Bug #46260 this makes it completely impossible to determine how the file was really called when it was included. Reproduce code: --- include('path_to/a_symlink.php'); var_dump(get_included_files()); Expected result: An array containing a string [...]/path_to/a_symlink.php. Actual result: -- An array containing a string [...]/some_file.php. -- Edit bug report at http://bugs.php.net/?id=47785edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47785r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47785r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47785r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47785r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47785r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47785r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47785r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47785r=needscript Try newer version: http://bugs.php.net/fix.php?id=47785r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47785r=support Expected behavior: http://bugs.php.net/fix.php?id=47785r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47785r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47785r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47785r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47785r=php4 Daylight Savings:http://bugs.php.net/fix.php?id=47785r=dst IIS Stability: http://bugs.php.net/fix.php?id=47785r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47785r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47785r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47785r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47785r=mysqlcfg
#44552 [NEW]: $this can be overwritten by setting a reference
From: andre at webkr dot de Operating system: Tested on Windows and Linux PHP version: 5.2.5 PHP Bug Type: Feature/Change Request Bug description: $this can be overwritten by setting a reference Description: Usually $this cannot be set. But by creating a reference to $this it can. In the example the reference is created by the = operator. The problem is also valid when passing $this to a function by reference. I think an error should be generated because both $this = 1 and $this = $x do generate an error. Reproduce code: --- class testclass { function foo() { var_dump($this); // object(testclass)#1 (0) { } $this-bar(); var_dump($this); // object(testclass)#1 (0) { } } function bar() { $a = $this; $a = 1; var_dump($this); // int(1) } } $b = new testclass; $b-foo(); Expected result: Fatal error: Cannot re-assign $this in eval()'d code on line 12 Actual result: -- object(testclass)#1 (0) { } int(1) object(testclass)#1 (0) { } -- Edit bug report at http://bugs.php.net/?id=44552edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44552r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44552r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44552r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44552r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44552r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44552r=needtrace Need Reproduce Script:http://bugs.php.net/fix.php?id=44552r=needscript Try newer version:http://bugs.php.net/fix.php?id=44552r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44552r=support Expected behavior:http://bugs.php.net/fix.php?id=44552r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44552r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44552r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44552r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44552r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44552r=dst IIS Stability:http://bugs.php.net/fix.php?id=44552r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44552r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44552r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44552r=nozend MySQL Configuration Error:http://bugs.php.net/fix.php?id=44552r=mysqlcfg