[pmwiki-users] Irreproducible behavior - maybe a bug

Patrick R. Michaud pmichaud at pobox.com
Wed May 11 15:49:57 CDT 2005


On Wed, May 11, 2005 at 10:27:10PM +0200, Joachim Durchholz wrote:
> Oh, and looking on http://www.php.net/language.types.type-juggling I 
> found this:
> "Note:  The behaviour of an automatic conversion to array is currently 
> undefined."
> In the light of this remark, I find the stability of PmWiki remarkable - 
> after all, there are 64 occurrences of (array) in the PmWiki code. Seems 
> like the conversion isn't *that* undefined, just long-standingly buggy 
> and nobody ever cared to fix it...

Well, except that this isn't an example of an automatic conversion
to an array.  Because of the (array) in front, it's *not* automatic,
it's a type cast, and typecasting is very well defined -- see
http://us3.php.net/manual/en/language.types.array.php#language.types.array.casting

An "automatic conversion" would be where someone sends a
non-array value to a function or operator that can only work
on arrays, but doesn't use a cast.

I'm thinking it must be something in the code other than
the (array) itself that is causing the problem.  It might be
an operator precedence issue -- try changing the line to read:

      foreach((array)(@$MarkupTable[$id]['dep']) as $i=>$m)

and see if that resolves the problem or gives a useful
error message.  It would explain a lot.

Pm



More information about the pmwiki-users mailing list