Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-25 Thread Pierre Joye
On Fri, Nov 25, 2011 at 10:18 AM, Ford, Mike wrote: > I echo that sentiment. On fuller review, I find a very high FUD > factor in effect here, and on actually checking my codebase I find > only 1 place where an additional is_array() *might* be needed (in > several tens of kLOC!). That's exactly

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-25 Thread Ferenc Kovacs
On Fri, Nov 25, 2011 at 4:07 AM, Daniel Convissor < dani...@analysisandsolutions.com> wrote: > Hi Anthony: > > > isset($foo['bar'][1]['baz']) && is_array($foo['bar'][1]) > > > > You don't need to check each level. Only the one above the key you're > > looking at. > > Excellent thinking. One hitc

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-25 Thread Ferenc Kovacs
On Fri, Nov 25, 2011 at 3:52 AM, Daniel Convissor < dani...@analysisandsolutions.com> wrote: > Hi Rasmus: > > > Yes, no change in any of that. In your usage, the case that behaves > > differently in 5.4 was actually a fatal error in 5.3, so chances are > > pretty good you don't have too many of th

RE: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-25 Thread Ford, Mike
> -Original Message- > From: Larry Garfield [mailto:la...@garfieldtech.com] > Sent: 24 November 2011 22:04 [... BIG SNIP ...] > If that doesn't change, then I rescind my previous panic attack. > > --Larry Garfield I echo that sentiment. On fuller review, I find a very high FUD factor i

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Anthony Ferrara
> Excellent thinking.  One hitch... that goes fatal in 5.3 if $foo is a string. > Here's how to write the test so it works the same way under 5.3 and 5.4: Correct. However, it's worth noting that it only goes fatal if $foo is a string. So as long as you know that the root variable is an array, it

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Daniel Convissor
Hi Anthony: > isset($foo['bar'][1]['baz']) && is_array($foo['bar'][1]) > > You don't need to check each level. Only the one above the key you're > looking at. Excellent thinking. One hitch... that goes fatal in 5.3 if $foo is a string. Here's how to write the test so it works the same way unde

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Daniel Convissor
Hi Rasmus: > Yes, no change in any of that. In your usage, the case that behaves > differently in 5.4 was actually a fatal error in 5.3, so chances are > pretty good you don't have too many of these. Things only go fatal in 5.3 under some circumstances. Doing isset() does not: 5.3.9RC3-dev ST

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Daniel Convissor
Hi Stas: > I have no idea why Drupal would use side effects > of string offset bugs to distinguish between arrays and strings They're not trying to distinguish between strings and arrays. People using this syntax are trying to see if a particular array element is populated. In the past, it happ

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Daniel Convissor
Hi Ferenc: On Thu, Nov 24, 2011 at 10:54:24PM +0100, Ferenc Kovacs wrote: > > I would vote for allowing only numbers in the string index/offset: [0-9]+ > > By "allowing" I meant that we should trigger the notice if the string index > contains anything else than numbers. I agree with this approac

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Alan Knowles
On Friday, November 25, 2011 08:23 AM, de...@lucato.it wrote: On 24 November 2011 21:48, Rasmus Lerdorf wrote: On 11/24/2011 01:44 PM, Yasuo Ohgaki wrote: Hi all, I should think twice before seding mail. "abc" as array index is converted to 0 since it's not a integer. So with current code is

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread devis
On 24 November 2011 21:48, Rasmus Lerdorf wrote: > On 11/24/2011 01:44 PM, Yasuo Ohgaki wrote: >> Hi all, >> >> I should think twice before seding mail. "abc" as array index is >> converted to 0 since it's not a integer. So with current code is >> behave consistently with regards to string to long

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Gustavo Lopes
On Thu, 24 Nov 2011 22:44:46 -, Yasuo Ohgaki wrote: find ../php-src-5.3/Zend/ -name "*.[ch]" | xargs grep -n "Cannot use string offset as an array" | wc -l111 I thought there are much less lines to raise notice for string offset access, but it isn't. It almost everywhere in vm. Now I und

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Yasuo Ohgaki
Hi all, Just FYI find ../php-src-5.3/Zend/ -name "*.[ch]" | xargs grep -n "Cannot use string offset as an array" | wc -l111 I thought there are much less lines to raise notice for string offset access, but it isn't. It almost everywhere in vm. Now I understand the reason why Stats and Rusmus car

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Ferenc Kovacs
On Thu, Nov 24, 2011 at 11:03 PM, Larry Garfield wrote: > On 11/24/2011 02:58 PM, Ferenc Kovacs wrote: > >> On Thu, Nov 24, 2011 at 9:12 PM, Larry >> Garfield >> >wrote: >> >> On 11/23/2011 12:13 PM, Lester Caine wrote: >>> >>> Richard Quadling wrote: I agree with Daniel on this. >>>

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Rasmus Lerdorf
On 11/24/2011 02:03 PM, Larry Garfield wrote: > Generally $foo, bar, and baz will all be arrays, and if they're not it > means someone else had a bug somewhere. Of course, Drupal module > developers never have bugs in their code that accidentally puts a string > where they should have put an array

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Larry Garfield
On 11/24/2011 02:58 PM, Ferenc Kovacs wrote: On Thu, Nov 24, 2011 at 9:12 PM, Larry Garfieldwrote: On 11/23/2011 12:13 PM, Lester Caine wrote: Richard Quadling wrote: I agree with Daniel on this. Just looking for any test relating to isset() to see what tests will now fail. So it's not

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Ferenc Kovacs
> > >> > Isn't it better to raise notice for accessing string by string index? >> > There is no use to allowing string index access to strings. I think >> > raising notice is feasible. Isn't it? >> >> String index access is still required since they are often numeric >> strings. We could add a noti

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Yasuo Ohgaki
2011/11/25 Rasmus Lerdorf : > On 11/24/2011 01:44 PM, Yasuo Ohgaki wrote: >> Hi all, >> >> I should think twice before seding mail. "abc" as array index is >> converted to 0 since it's not a integer. So with current code is >> behave consistently with regards to string to long conversion. >> >> How

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Ferenc Kovacs
On Thu, Nov 24, 2011 at 10:48 PM, Rasmus Lerdorf wrote: > On 11/24/2011 01:44 PM, Yasuo Ohgaki wrote: > > Hi all, > > > > I should think twice before seding mail. "abc" as array index is > > converted to 0 since it's not a integer. So with current code is > > behave consistently with regards to s

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Ferenc Kovacs
On Thu, Nov 24, 2011 at 10:44 PM, Yasuo Ohgaki wrote: > Hi all, > > I should think twice before seding mail. "abc" as array index is > converted to 0 since it's not a integer. So with current code is > behave consistently with regards to string to long conversion. > > However, > > PHP 5.3 > php -

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Rasmus Lerdorf
On 11/24/2011 01:44 PM, Yasuo Ohgaki wrote: > Hi all, > > I should think twice before seding mail. "abc" as array index is > converted to 0 since it's not a integer. So with current code is > behave consistently with regards to string to long conversion. > > However, > > PHP 5.3 > php -r '$s = "

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Yasuo Ohgaki
Hi all, I should think twice before seding mail. "abc" as array index is converted to 0 since it's not a integer. So with current code is behave consistently with regards to string to long conversion. However, PHP 5.3 php -r '$s = "abc"; var_dump($s[0]["bar"]);' PHP Fatal error: Cannot use stri

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Felipe Pena
Hi, 2011/11/24 Rasmus Lerdorf : > On 11/24/2011 01:08 PM, Pierre Joye wrote: >> hi Rasmus, >> >> On Thu, Nov 24, 2011 at 9:35 PM, Rasmus Lerdorf wrote: >> >>> I had a quick look through the Drupal code. I don't see a single place >>> that this is done where a deeply nested array index is applied

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Yasuo Ohgaki
Hi, 2011/11/24 Richard Quadling : > On 23 November 2011 01:50, Daniel Convissor > wrote: >> Hi Folks: >> >> I just stumbled upon a regression in 5.4.  In an array, a sub-sub-key of >> an existing key is now returning a letter of the value indexed by the >> main key.  I'm raising it here so it doe

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Stas Malyshev
Hi! For all the people saying, "Revert". You guys realize that also means we revert all the array dereferencing we added elsewhere, right? That includes function array dereferencing which pretty most everyone has been clamoring for for years. I think you're underestimating it. We'd have to rev

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Lester Caine
Ferenc Kovacs wrote: Did you managed to read the whole thread? I'm asking because there were lot of confusion about the actual impact of this problem, and Lester particularly seemed confused. "There is nothing really wrong with the current code except that the sub keys have yet to be populated."

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Rasmus Lerdorf
On 11/24/2011 01:08 PM, Pierre Joye wrote: > hi Rasmus, > > On Thu, Nov 24, 2011 at 9:35 PM, Rasmus Lerdorf wrote: > >> I had a quick look through the Drupal code. I don't see a single place >> that this is done where a deeply nested array index is applied to a >> string. I think you are misunde

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Pierre Joye
hi Rasmus, On Thu, Nov 24, 2011 at 9:35 PM, Rasmus Lerdorf wrote: > I had a quick look through the Drupal code. I don't see a single place > that this is done where a deeply nested array index is applied to a > string. I think you are misunderstanding what has changed here. We are leading to ye

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Stas Malyshev
Hi! This is going to be a huge problem for Drupal. Drupal uses deep associative array structures a lot, by design. That means we isset() or empty() on arrays a lot. I haven't had a chance to test it yet, but I see this change breaking, um, A LOT. And as Daniel noted, the fix is to turn one l

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Ferenc Kovacs
On Thu, Nov 24, 2011 at 9:12 PM, Larry Garfield wrote: > On 11/23/2011 12:13 PM, Lester Caine wrote: > >> Richard Quadling wrote: >> >>> I agree with Daniel on this. >>> >>> Just looking for any test relating to isset() to see what tests will >>> now fail. >>> >> >> So it's not just me :) >> I am

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Rasmus Lerdorf
On 11/24/2011 12:12 PM, Larry Garfield wrote: > On 11/23/2011 12:13 PM, Lester Caine wrote: >> Richard Quadling wrote: >>> I agree with Daniel on this. >>> >>> Just looking for any test relating to isset() to see what tests will >>> now fail. >> >> So it's not just me :) >> I am seeing this break r

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Larry Garfield
On 11/23/2011 12:13 PM, Lester Caine wrote: Richard Quadling wrote: I agree with Daniel on this. Just looking for any test relating to isset() to see what tests will now fail. So it's not just me :) I am seeing this break real world projects and can't see a easy way to fix the break. There is

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Ferenc Kovacs
On Thu, Nov 24, 2011 at 2:04 PM, wrote: > Thanks Ferenc > > Everything looks ok http://codepad.viper-7.com/JTXsGK > > Devis > > here are the corner cases: 5.3: http://codepad.viper-7.com/nPLorU 5.4: http://codepad.viper-7.com/MUdAlc as you can see from the 4th example, your test will have an une

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread devis
Thanks Ferenc Everything looks ok http://codepad.viper-7.com/JTXsGK Devis On 24 November 2011 10:31, Ferenc Kovacs wrote: >> >> >>> It gives me false in 5.3.6. Using it outside of isset() results in the >>> fatal error. >>> >> >> hm. >> >> tyrael@thor:~$ php -r '$string = >> "foo";isset($stri

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Richard Quadling
On 23 November 2011 01:50, Daniel Convissor wrote: > Hi Folks: > > I just stumbled upon a regression in 5.4.  In an array, a sub-sub-key of > an existing key is now returning a letter of the value indexed by the > main key.  I'm raising it here so it doesn't get lost. > > https://bugs.php.net/bug.

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Yasuo Ohgaki
Just a quick note for this issue. If I remember correctly, PHP is working this way at least from PHP 3.0.x. $a[123] // integer index $a['123'] // integer index $a['123 abc'] // string index $a['123.123'] // string index Automatic string to integer conversion only happened if index string has numer

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Ferenc Kovacs
On Thu, Nov 24, 2011 at 11:31 AM, Ford, Mike wrote: > > -Original Message- > > From: Gustavo Lopes [mailto:glo...@nebm.ist.utl.pt] > > Sent: 23 November 2011 22:31 > > > > On Wed, 23 Nov 2011 21:06:09 -, Pierre Joye > > > > wrote: > > > > > The fact that we have reports here showing

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Ferenc Kovacs
On Thu, Nov 24, 2011 at 11:05 AM, wrote: > On 24 November 2011 01:38, Stas Malyshev wrote: > > Hi! > > > >> But neither is introducing a potential bomb of the kind that the 'date' > >> saga > >> created. The problem this change IS causing is likely to hit many live > >> sites > > > > The claim t

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Yasuo Ohgaki
2011/11/24 : > On 24 November 2011 01:38, Stas Malyshev wrote: > Hi, > > I hadn't the opportunity to install php 5.4 to test this, so I was > wondering if someone could test how would this code behave ? > > ### > if ( > !isset( $widget_options['dashboard_incoming_links'] ) >  || !isset( $

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Alexey Shein
2011/11/24 : > On 24 November 2011 01:38, Stas Malyshev wrote: >> Hi! >> >>> But neither is introducing a potential bomb of the kind that the 'date' >>> saga >>> created. The problem this change IS causing is likely to hit many live >>> sites >> >> The claim that many live sites actually regularl

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Ferenc Kovacs
> > >> It gives me false in 5.3.6. Using it outside of isset() results in the >> fatal error. >> > > hm. > > tyrael@thor:~$ php -r '$string = > "foo";isset($string["foo"]["bar"]["baz"]["0"]);'; > PHP Fatal error: Cannot use string offset as an array in Command line > code on line 1 > tyrael@thor:~

RE: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Ford, Mike
> -Original Message- > From: Gustavo Lopes [mailto:glo...@nebm.ist.utl.pt] > Sent: 23 November 2011 22:31 > > On Wed, 23 Nov 2011 21:06:09 -, Pierre Joye > > wrote: > > > The fact that we have reports here showing code not working > anymore > > because of this change tells me that it

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread devis
On 24 November 2011 01:38, Stas Malyshev wrote: > Hi! > >> But neither is introducing a potential bomb of the kind that the 'date' >> saga >> created. The problem this change IS causing is likely to hit many live >> sites > > The claim that many live sites actually regularly use string multiple st

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Ferenc Kovacs
On Thu, Nov 24, 2011 at 10:32 AM, Lester Caine wrote: > Stas Malyshev wrote: > >> Hi! >> >> That would help a lot ... this is not a problem of "so the developer can >>> fix his >>> code" but rather so we can fix legacy code which other non-developers are >>> currently using happily ... If *I* ha

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Lester Caine
Ferenc Kovacs wrote: I will check this against a vanilla version, as there is a chance that either dotdeb(less likely) or suhosin patched something. I had a look, my SUSE boxes have suhosin on still, but the 5.3 test machine is running windows without it ... 5.4 machine even ... the SUSE bo

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Lester Caine
Ferenc Kovacs wrote: I will check this against a vanilla version, as there is a chance that either dotdeb(less likely) or suhosin patched something. I had a look, my SUSE boxes have suhosin on still, but the 5.3 test machine is running windows without it ... -- Lester Caine - G8HFL -

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Lester Caine
Stas Malyshev wrote: Hi! That would help a lot ... this is not a problem of "so the developer can fix his code" but rather so we can fix legacy code which other non-developers are currently using happily ... If *I* had written the code I would not have done it the way it is currently structured

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Ferenc Kovacs
On Thu, Nov 24, 2011 at 3:41 AM, David Muir wrote: > On 24/11/11 12:44, Ferenc Kovacs wrote: > > > > On Thu, Nov 24, 2011 at 1:38 AM, David Muir wrote: > >> Just to clarify, the changes introduced in 5.4 will result in the >> following: >> >> > >> $string = 'foo'; >> $array = array( >>'foo'

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Stas Malyshev
Hi! That would help a lot ... this is not a problem of "so the developer can fix his code" but rather so we can fix legacy code which other non-developers are currently using happily ... If *I* had written the code I would not have done it the way it is currently structured, but I'm not about to

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-24 Thread Lester Caine
David Muir wrote: Personally I think that the main issue is that we silently convert $foo['bar'] to $foo[0] for strings, which imo rarely the intended behavior and doesn't really makes much sense (except that the offset expects the index to be int, and this is how we type juggle between string an

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread David Muir
On 24/11/11 12:44, Ferenc Kovacs wrote: > > > On Thu, Nov 24, 2011 at 1:38 AM, David Muir > wrote: > > Just to clarify, the changes introduced in 5.4 will result in the > following: > > > $string = 'foo'; > $array = array( >'foo' => array(

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Anthony Ferrara
One thing to note. The good test for what's being talked about would be simple: isset($foo['bar'][1]['baz']) && is_array($foo['bar'][1]) You don't need to check each level. Only the one above the key you're looking at. I think it would be a good idea to raise a notice on string index conversio

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Ferenc Kovacs
On Thu, Nov 24, 2011 at 1:38 AM, David Muir wrote: > On 24/11/11 06:25, Stas Malyshev wrote: > > Hi! > > > >> The only case where the 5.4 branch works differently as before if you > >> reference a string type(int, float, etc. won't trigger this) variable > >> using an associative index and you ex

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Stas Malyshev
Hi! And I believe you're missing the point. I'm not suggesting it for 5.4, but illustrating that until something like it (or better) exists, the "bug fix" should wait until such a solution exists. Again, you seem to miss the major point. The bug fix was fixing the result of string operation,

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Stas Malyshev
Hi! But neither is introducing a potential bomb of the kind that the 'date' saga created. The problem this change IS causing is likely to hit many live sites The claim that many live sites actually regularly use string multiple string offsets to distinguish strings from arrays sounds implausi

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread David Muir
On 24/11/11 11:42, Stas Malyshev wrote: > Hi! > >> If you want this fix to be palatable, we'll need a new language >> construct that effectively runs a series of is_array&& array_key_exists >> with a final !== null check. > > I'm not sure RC time is a good place for introducing new language > cons

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Lester Caine
Stas Malyshev wrote: If you want this fix to be palatable, we'll need a new language construct that effectively runs a series of is_array&& array_key_exists with a final !== null check. I'm not sure RC time is a good place for introducing new language constructs. Actually, I'm pretty sure it's

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Stas Malyshev
Hi! If you want this fix to be palatable, we'll need a new language construct that effectively runs a series of is_array&& array_key_exists with a final !== null check. I'm not sure RC time is a good place for introducing new language constructs. Actually, I'm pretty sure it's not. -- Stan

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread David Muir
On 24/11/11 06:25, Stas Malyshev wrote: > Hi! > >> The only case where the 5.4 branch works differently as before if you >> reference a string type(int, float, etc. won't trigger this) variable >> using an associative index and you expect it that to be undefined >> variable even though that the doc

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Stas Malyshev
Hi! As distasteful as it seems, it absolutely should be reverted IMHO. You seem to misunderstand something here. This behavior is a direct consequence of string offset result being a string. To revert it means to reintroduce broken string-offset pseudo-var-type that led to huge amount of bu

RE: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Mike Robinson
On November-23-11 5:31 PM Gustavo Lopes wrote: > On Wed, 23 Nov 2011 21:06:09 -, Pierre Joye > wrote: > > > The fact that we have reports here showing code not working anymore > > because of this change tells me that it is a BC break. We can call it > > a bug fix but it still breaks code out

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Gustavo Lopes
On Wed, 23 Nov 2011 21:06:09 -, Pierre Joye wrote: The fact that we have reports here showing code not working anymore because of this change tells me that it is a BC break. We can call it a bug fix but it still breaks code out there for no real benefit but edge case usages. We had this s

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Pierre Joye
On Wed, Nov 23, 2011 at 8:47 PM, Daniel Convissor wrote: > This is the first time in ten years I heard about string array keys > being converted to integers (all be it in the context of string > offsets). They are not keys but offset in this case :) Not sure we can change that without breaking

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Pierre Joye
On Wed, Nov 23, 2011 at 7:57 PM, Stas Malyshev wrote: > Hi! > >> Unless I'm mistaken it seems that we have a clear and vicious BC break >> here, the kind of changes that are annoying to catch and does not > > No, we do not have a BC break here, we have a bugfix here that makes string > ops work co

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Daniel Convissor
Hi Stas: > I'm sorry that influences you code, it is unfortunate, but relying > on an obscure bug, however convenient, is not a good practice. Please don't put this on me. It's not about me. It's about many, many developers who have this usage in many places. This change will open up many unex

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Stas Malyshev
Hi! The fix to make $a[0][0] work is good. No argument here. Then the rest of the discussion is moot for 5.4, as that's the only change that happened. The problem arises where programmers wrote code anticipating the incoming variable is an array but another programmer has passed in a stri

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Christopher Jones
On 11/22/2011 06:31 PM, Daniel Convissor wrote: Hi Etienne: AFAIK this is one of the change that was explicitly put in to make it more consistent. But now it breaks code in the wild. I came across this due to an isset() in PEAR now passing when it didn't before. Thanks, --Dan Since we

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Daniel Convissor
Hi Stas: > I am 100% opposed to changing anything there and > re-breaking string offsets because somebody uses string indexes to > operate on strings and expect them to work in weird ways that makes > $a[0][0] work differently from $b = $a[0]; $b[0]. The fix to make $a[0][0] work is good. No arg

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Stas Malyshev
Hi! The only case where the 5.4 branch works differently as before if you reference a string type(int, float, etc. won't trigger this) variable using an associative index and you expect it that to be undefined variable even though that the documentation explicitly states that the Actually, the

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Ferenc Kovacs
On Wed, Nov 23, 2011 at 7:57 PM, Stas Malyshev wrote: > Hi! > > > Unless I'm mistaken it seems that we have a clear and vicious BC break >> here, the kind of changes that are annoying to catch and does not >> > > No, we do not have a BC break here, we have a bugfix here that makes > string ops wo

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Ferenc Kovacs
On Wed, Nov 23, 2011 at 7:52 PM, Stas Malyshev wrote: > Hi! > > > On 11/23/11 6:14 AM, Daniel Convissor wrote: > >> To me, this is the bug. $a['blah'] does not exist. An undefined index >> > > If it's a bug, this bug was in PHP since forever, nothing new here. > > > notice should be raised. Th

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Stas Malyshev
Hi! Unless I'm mistaken it seems that we have a clear and vicious BC break here, the kind of changes that are annoying to catch and does not No, we do not have a BC break here, we have a bugfix here that makes string ops work consistently and only has a problem with completely broken code. I

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Stas Malyshev
Hi! On 11/23/11 6:14 AM, Daniel Convissor wrote: To me, this is the bug. $a['blah'] does not exist. An undefined index If it's a bug, this bug was in PHP since forever, nothing new here. notice should be raised. The key "blah" should not be converted to 0. The following two things should

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Etienne Kneuss
Hi, What people seem to have trouble with here is not that $string[0][0] == $string[0], but rather that $string['index'] === $string[0]... But as many people said, it is just how type juggling want: string index? Get me an int => 0. I believe the change introduced in 5.4 makes sense, the previou

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Pierre Joye
On Wed, Nov 23, 2011 at 6:58 PM, Richard Quadling wrote: > Just looking for any test relating to isset() to see what tests will now fail. > > Neither of the isset() tests ext/standard/tests/general_functions look > at arrays with associative indices. > > The behaviour with regard to unavailable a

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Lester Caine
Richard Quadling wrote: I agree with Daniel on this. Just looking for any test relating to isset() to see what tests will now fail. So it's not just me :) I am seeing this break real world projects and can't see a easy way to fix the break. There is nothing really wrong with the current code

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Richard Quadling
On 23 November 2011 15:31, Daniel Convissor wrote: > Hi Again Folks: > > On Wed, Nov 23, 2011 at 09:14:09AM -0500, Daniel Convissor wrote: >> $a = 'foo'; >> echo $a['blah'] . "\n"; >> >> But that second one echos out "f".  This is a huge WTF. > > Two things for the record on this front.  First, i'

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Ferenc Kovacs
On Wed, Nov 23, 2011 at 4:31 PM, Daniel Convissor < dani...@analysisandsolutions.com> wrote: > Hi Again Folks: > > On Wed, Nov 23, 2011 at 09:14:09AM -0500, Daniel Convissor wrote: > > $a = 'foo'; > > echo $a['blah'] . "\n"; > > > > But that second one echos out "f". This is a huge WTF. > > Two t

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Daniel Convissor
Hi Again Folks: On Wed, Nov 23, 2011 at 09:14:09AM -0500, Daniel Convissor wrote: > $a = 'foo'; > echo $a['blah'] . "\n"; > > But that second one echos out "f". This is a huge WTF. Two things for the record on this front. First, i've been actively using PHP for, what, ten years or so, and have

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Ferenc Kovacs
On Wed, Nov 23, 2011 at 4:04 PM, Daniel Convissor < dani...@analysisandsolutions.com> wrote: > Hi Ferenc: > > [And the manual sys...] > > "Non-integer types are converted to integer." > > So it is a documented behavior, so the current change is just a bugfix > imo. > > Can someone please lend

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Daniel Convissor
Hi Ferenc: [And the manual sys...] > "Non-integer types are converted to integer." > So it is a documented behavior, so the current change is just a bugfix imo. Can someone please lend me their time machine so I can go back and tell folks to just use {} for string offsets and [] for arrays?

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Ferenc Kovacs
On Wed, Nov 23, 2011 at 3:42 PM, Gustavo Lopes wrote: > Em Wed, 23 Nov 2011 14:19:42 -, Ferenc Kovacs > escreveu: > > On Wed, Nov 23, 2011 at 3:14 PM, Daniel Convissor < >> danielc@analysisandsolutions.**com > >> wrote: >> >> > It's actually very simple. Take variable $a which is a string >

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Pierre Joye
On Wed, Nov 23, 2011 at 3:19 PM, Ferenc Kovacs wrote: > if we allow strings to be used as indexes for strings, we have to be > consistent with what we have already. Short notice to avoid confusion: It has nothing to do with allowing string, or double, or whatever else but loosely typing. Loosel

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Gustavo Lopes
Em Wed, 23 Nov 2011 14:19:42 -, Ferenc Kovacs escreveu: On Wed, Nov 23, 2011 at 3:14 PM, Daniel Convissor < dani...@analysisandsolutions.com> wrote: > It's actually very simple. Take variable $a which is a string > ("foo"). Now it you do $a[0] that would produce first letter - "f". > No

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Ferenc Kovacs
On Wed, Nov 23, 2011 at 3:14 PM, Daniel Convissor < dani...@analysisandsolutions.com> wrote: > Hi Stas: > > > It's actually very simple. Take variable $a which is a string > > ("foo"). Now it you do $a[0] that would produce first letter - "f". > > Now here's a tricky part - if you do $a['blah'] it

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Daniel Convissor
Hi Stas: > It's actually very simple. Take variable $a which is a string > ("foo"). Now it you do $a[0] that would produce first letter - "f". > Now here's a tricky part - if you do $a['blah'] it would convert > 'blah' to number, get 0 and return the same letter "f". To me, this is the bug. $a['

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Lester Caine
Ferenc Kovacs wrote: On Wed, Nov 23, 2011 at 10:51 AM, Lester Caine mailto:les...@lsces.co.uk>> wrote: Ferenc Kovacs wrote: some clarification: in the test script, Daniel declared $arr as: $arr = array('exists' => 'foo'); so when he tests $arr['exis

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Ferenc Kovacs
On Wed, Nov 23, 2011 at 10:51 AM, Lester Caine wrote: > Ferenc Kovacs wrote: > >> some clarification: >> in the test script, Daniel declared $arr as: >> $arr = array('exists' => 'foo'); >> so when he tests >> $arr['exists']['non_existent'] >> PHP will see that $arr['exists'] is a string, and it w

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Lester Caine
Ferenc Kovacs wrote: some clarification: in the test script, Daniel declared $arr as: $arr = array('exists' => 'foo'); so when he tests $arr['exists']['non_existent'] PHP will see that $arr['exists'] is a string, and it will convert the 'non_existent' index to int(0) and that will return the same

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Stas Malyshev
Hi! On 11/23/11 12:56 AM, Lester Caine wrote: I'm having a lot of trouble with working out WHAT is going on here at all. It's actually very simple. Take variable $a which is a string ("foo"). Now it you do $a[0] that would produce first letter - "f". Now here's a tricky part - if you do $a[

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Ferenc Kovacs
On Wed, Nov 23, 2011 at 9:56 AM, Lester Caine wrote: > Etienne Kneuss wrote: > >> AFAIK this is one of the change that was explicitly put in to make it >> more consistent. >>> > >>> > But now it breaks code in the wild. I came across this due to an >>> > isset() in PEAR now passing

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Laruence
Hi: I think it is really need make some difference between {} and [] :) thanks On Wed, Nov 23, 2011 at 4:56 PM, Lester Caine wrote: > Etienne Kneuss wrote: AFAIK this is one of the change that was explicitly put in to make it >>  more consistent. >>> >>> > >>> >  But now it brea

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-23 Thread Lester Caine
Etienne Kneuss wrote: AFAIK this is one of the change that was explicitly put in to make it >> more consistent. > > But now it breaks code in the wild. I came across this due to an > isset() in PEAR now passing when it didn't before. PEAR is definitely doing some strange things:) Is it che

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-22 Thread Stas Malyshev
Hi! On 11/22/11 6:36 PM, Etienne Kneuss wrote: PEAR is definitely doing some strange things :) Is it checking indices of a variables without checking first if it's an array? Sounds like the comeback of "Please don't break bad code!" seen with is_a :) I think somebody should start a code cleanu

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-22 Thread Etienne Kneuss
On Wed, Nov 23, 2011 at 03:31, Daniel Convissor wrote: > Hi Etienne: > >> AFAIK this is one of the change that was explicitly put in to make it >> more consistent. > > But now it breaks code in the wild.  I came across this due to an > isset() in PEAR now passing when it didn't before. PEAR is de

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-22 Thread Daniel Convissor
Hi Etienne: > AFAIK this is one of the change that was explicitly put in to make it > more consistent. But now it breaks code in the wild. I came across this due to an isset() in PEAR now passing when it didn't before. Thanks, --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C

Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values

2011-11-22 Thread Etienne Kneuss
Hi, AFAIK this is one of the change that was explicitly put in to make it more consistent. Before, you had: $string = "asd"; $string[0] == "a" but: $string[0][0] == Fatal: cannot use string offset as an array while $string[0] == "a", it makes no sense for $string[0][0] not to return "a" again,