> -----Original Message-----
> From: Gustavo Lopes [mailto:[email protected]]
> Sent: 23 November 2011 22:31
>
> On Wed, 23 Nov 2011 21:06:09 -0000, Pierre Joye
> <[email protected]>
> 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 situation before, that does not help
> us.
> >
>
> I'd say for no benefit at all. Why would anyone ever want to take a
> string
> offset from a string that certainly has length 1? Except for taking
> satisfaction in this "improved consistency", I see absolutely no
> benefit.
>
> Up until now, it was deemed a useless but innocuous change. Now that
> we
> found it has pernicious side effects, we ought to revert it.
That's exactly my take on it. As far as I can see, if 5.4 is released
with this "fix" in, it will effectively be rendered a non-upgradable-to
version for most big projects.
For what it's worth (not much!), my two pennorth on this is that
whilst, like some others, I can see the marginal benefit of making the
behaviour consistent, I really don't think the change can be done in
one go. Given that this WILL break existing code (some of it mine :( ),
there needs to be a release where the usage generates an error message
- probably an E_WARNING, or maybe an E_STRICT - and an easy alternative
is provided. Since the simplest alternative way of performing the
necessary chained checks would seem to be:
if (is_array($arr) && array_key_exists('key1', $arr)
&& is_array($arr['key1'] && array_key_exists('key2', $arr['key2'])
...
)
which substitutes 2 function calls and 2 array accesses per dimension
for a single function call and 1 multi-dimensional array access, there has
to be scope for a function called something like array_offset_exists with
a signature like
array_offset_exists(array $array, mixed $offset, ...)
(Yes, I know, inconsistent argument order and all that, but....)
so that people can have a chance to transform
isset($arr['key1']['key2']['key3'])
into
array_offset_exists($arr, 'key1', 'key2, 'key3')
before the full fix is put into place in a subsequent version.
Cheers!
Mike
--
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS, LS1 3HE, United Kingdom
E: [email protected] T: +44 113 812 4730
To view the terms under which this email is distributed, please go to
http://disclaimer.leedsmet.ac.uk/email.htm