[pmwiki-users] Irreproducible behavior - maybe a bug
Joachim Durchholz
jo at durchholz.org
Wed May 11 15:27:10 CDT 2005
Joachim Durchholz wrote:
> I've got a tentative prime suspect: the array cast. (In Markup(), it's
> even error-suppressed using @, but that doesn't seem to enter into the
> picture - I don't particularly like that use of @ though. It can mask
> errors other than the expected ones, and then ugly things start to happen.)
>
> I'll test that hypothesis shortly.
Yup, that's it.
Defined this function:
function to_array($a) {
if (is_array($a))
return $a;
else
return array();
}
and used it in Markup() like this:
...
foreach(to_array(@$MarkupTable[$id]['dep']) as $i=>$m) {
...
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...
Regards,
Jo
More information about the pmwiki-users
mailing list