Wierd behaviour in mgd_is_member

Fri 5th November 2004 20:48 EET

For the starters, let see what Midgard manual has to say about this function:

bool mgd_is_member (int group_id, int [user_id])

Alright, that's easy enough, you need a group ID and you may use the user ID in case you're working with another user account (not the one you're logged in with).

So, I had an HTML form on a Midgard page that was sending information to itself in POST. Nothing special here really, what's the catch Henri? I'm glad you asked. The function specifically states that it needs one or two integers - not doubles, arrays or even strings.

I know you already figured out what was going on but I'm going to finish this so that the next time I'm hitting my head through steel-concrete maybe I'll remember this: Array values that I received in POST were considered as strings by the PHP, not integers that they really were.

So, all I needed was this:

mgd_is_member((int) $myGid, (int) $myUid)

Yes, that's right, type juggling saved the day. Why I even bother to blog about this is that all Midgard functions I'm regularily using don't need the type juggling, and they handle similar situations without trouble. So it might well be that this particular function needs some extra love from the developers.

Update 2004-11-12

Piotras just arrived to Midgard gathering, Sweden, and told me that he has fixed this issue. So no worries mate, and excellent work Piotras!

In other news

We were finally able to release the new Nemein Web site two days ago. This is already blogged by Bergie, so I won't use many more words on that. I just want to say that our freelance designer Lasse Larvanko did excellent work on the layout.