1
succhi
XOBJ_DTYPE_ARRAY issues
  • 2005/2/18 2:18

  • succhi

  • Just popping in

  • Posts: 20

  • Since: 2004/3/20


Hi I have written a XoopsObject called kbActivity. One of my variables is initialised as type XOBJ_DTYPE_ARRAY. I have a problem retrieving it after assigning. I get the error:

Notice [PHP]: unserialize(): Argument is not a string in file e:\apache\htdocs\getupandgo\kernel\object.php line 343

Here is the portion in the handler where "activities" (my array) is assigned.


function &get($id) {
if (intval($id) > 0) {
$sql = "SELECT * FROM " . $this->db->prefix('kb_locations') . " WHERE lid = " . $id;
if (!$result = $this->db->query($sql)) {
return false;
}
$numrows = $this->db->getRowsNum($result);
if ($numrows == 1) {
$location = new kbLocation();
$location->assignVars($this->db->fetchArray($result));
$sql = "SELECT aid FROM " . $this->db->prefix('kb_activities') . " WHERE lid = " . $id;
if ($result = $this->db->query($sql)) {
$acts = array();
while($row = $this->db->fetchArray($result)){
$activity = serialize(new kbActivity($row['aid']));
$acts[] = $activity;
}
$location->assignVar("activities", $acts);
}
return $location;
}
}
return false;
}


My first problem is that when I call back 'activities' from my object with $this->getVar("activities") I get the error listed above. Do I need to serialize the whole array first manually?

Secondly when I work this problem out do I need to serialize my objects to store them in my array? I'd probably work this one out if I was able to retrieve my inital array first.

Ta,
Stu

2
succhi
Re: XOBJ_DTYPE_ARRAY issues
  • 2005/2/18 2:30

  • succhi

  • Just popping in

  • Posts: 20

  • Since: 2004/3/20


Yes I have to serialize my array manually. This should be transparent. The unserializing happens transparently which would normally indicate that serializing of arrays should do so too.

Stuart.

3
mboyden
Re: XOBJ_DTYPE_ARRAY issues
  • 2005/7/20 17:36

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


I was having the same problem. I finally tried XOBJ_DTYPE_OTHER and it worked just fine. So, I searched through the XoopsObject code and found the serialization issue. Then I searched these forums for an answer.

I'd have to agree with succhi that this should be transparent for symmetry purposes just as in the other data types. I should be able to just send the array when I use the assignVar or setVar instead of manually serializing it in my code first. I spent over an hour on this little bitty issue.

It would be easy to add a switch to the setVar and assignVar areas (I'd be happy to write and submit the code). But, I wonder how much usage is made of this because the "fix" would (could?) break others code. I did a quick search on the core and the modules that I regularly use. Not a lot of usage generally and NONE in the core (interesting, eh?). CBB (and likely NewBB2) and Liase are the only module usages I see (of the ones I use regularly).

I'll post it as a bug since I couldn't find it listed on SourceForge. I guess it's always possible this is by design, but there aren't any notes to that effect. How many modules will it break if we were to "fix" this?

I think for now, I'll just use the OTHER object type and examine my arrays myself. That way if it ever is dealt with, then I'll only have to change the object type in the class rather than remove a bunch of serialize() statements and worry about compatibility.

Any comments on this issue from Core developers?
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

4
Mithrandir
Re: XOBJ_DTYPE_ARRAY issues

We have gone to great lengths trying to resolve this in XOOPS 2.2
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

Login

Who's Online

446 user(s) are online (357 user(s) are browsing Support Forums)


Members: 0


Guests: 446


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits