469,954 Members | 1,820 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,954 developers. It's quick & easy.

Any possible reason why "$line.serialize($rs2)" refuses to execute?

I'm running this on a Linux/CentOs/cPanel server, trying to add caching
to my PHP5 code, using ADOdb. I have two Linux servers, one of them is
running perfect, the second one, just crashes without any error, and
just gives a blank screen.

I narrowed down the problem to: $line.serialize($rs2)
Am I missing something maybe in the PHP5 configuration?

Jan 12 '06 #1
10 1596
Rafi B. wrote:
I narrowed down the problem to: $line.serialize($rs2)
Am I missing something maybe in the PHP5 configuration?


This is probably too obvious, but when $line is an object and serialize() a
method of this object, the call should be:

$line->serialize($rs2);
JW
Jan 13 '06 #2
This is the context in which it is executed:
$line = "====1,$tt,$sql\n";
$rs2->sql = $rs->sql;
$rs2->oldProvider = $rs->dataProvider;
$rs2->InitArrayFields($rows,$flds);
$rs2->fetchMode = $savefetch;
return $line.serialize($rs2);

$rs2 is a Recordset, this code is part of ADOdb caching function, which
tries to serialize a recordset from database, and saves it into a file.
When I do print_r($rs2) it seems that all the data is there, the last
line, even without the concating of $line, just crashes. Without any
message.

What I've been through the past days because of this is insane.
Upgraded cPanel, upgraded Apache, all my apps and modules are identical
to a friends' server which this code runs so smoothly on it makes me
want to cry.

Any help why serialize() will just crash like this?

Janwillem Borleffs wrote:
Rafi B. wrote:
I narrowed down the problem to: $line.serialize($rs2)
Am I missing something maybe in the PHP5 configuration?


This is probably too obvious, but when $line is an object and serialize() a
method of this object, the call should be:

$line->serialize($rs2);
JW


Jan 13 '06 #3
Rafi B. wrote:
This is the context in which it is executed:
$line = "====1,$tt,$sql\n";
$rs2->sql = $rs->sql;
$rs2->oldProvider = $rs->dataProvider;
$rs2->InitArrayFields($rows,$flds);
$rs2->fetchMode = $savefetch;
return $line.serialize($rs2);
[...] Any help why serialize() will just crash like this?


Well, for one thing, $line.serialize() isn't valid PHP syntax for a method
call, because of the dot. That it executes on your friend's system probably
has to do with his error_reporting and display_errors settings. Ask him if
queries ever get cached and the answer probably will be negative.

When the $rs2 object contains the serialize method, you probably should do
something like:

return $rs2->serialize();

When, however, you goal is to apply the native PHP serialize function, the
call probably should be:

return serialize($rs2);
JW
Jan 13 '06 #4

Janwillem Borleffs wrote:

Well, for one thing, $line.serialize() isn't valid PHP syntax for a method
call, because of the dot. That it executes on your friend's system probably
has to do with his error_reporting and display_errors settings. Ask him if
queries ever get cached and the answer probably will be negative.
It does. I coded his site, and the caching works like a charm.From a 8 second heavy queried home page, to 0.5 second serverside loadtime,
its cached every hour.

What the guys in the ADOdb code are doing is concating the $line with
the
result of serialize($rs2). So: return $line.serialize($rs2); IS valid
in PHP,
maybe more clear would be: return $line . serialize($rs2);
When the $rs2 object contains the serialize method, you probably should do
something like:


Their just serializing the $rs object. That's it. When I try to execute
the query
without caching, I receive a return into "$myresult" lets say for
example, this
will contain an array of all the fields that my query returned, and
when I do IN MY CODE:
$sdata = serialize($myresult);

CRASHES. Fatal. Doesn't spit anything in the logs, or screen. Just dies
so brutally.

I'm pulling out hairs here.

Jan 14 '06 #5
My title for this thread should be: Why serialize($rs) crashes
brutally?
I've narrowed it down to this. Why does it happen? On the same code,
same ADOdb library version, both on my Friend's Linux Server, and
another Windows Server, it SHOULD work according to ADOdb and hundreds
of their fans. And it works for me, but on servers other than mine.
Only I'm screwed. Dunno why.

PHP version 5.0.5 by the way.

Jan 14 '06 #6
Rafi B. wrote:
result of serialize($rs2). So: return $line.serialize($rs2); IS
valid in PHP,
maybe more clear would be: return $line . serialize($rs2);


Yep, you're right. My bad, I was sleeping.

Regarding the version you are using (5.0.5), which version is used on the
environments which do not have problems?

Perhaps it would be an idea to simply update your environment to the latest
stable release (5.1.2). What you also can do is set up a test to see at
which point the serialize() function crashes.

Just comment out portings of the class instantiated through the $rs2 object
and de-comment portions up untill the moment serialize() crashes.
JW
Jan 14 '06 #7
Problem is, I'm very new to Linux, and I have a Linux/CentOs/cPanel
server
and the cPanel support PHP until version 5.0.5

Janwillem Borleffs wrote:
Rafi B. wrote:
result of serialize($rs2). So: return $line.serialize($rs2); IS
valid in PHP,
maybe more clear would be: return $line . serialize($rs2);


Yep, you're right. My bad, I was sleeping.

Regarding the version you are using (5.0.5), which version is used on the
environments which do not have problems?

Perhaps it would be an idea to simply update your environment to the latest
stable release (5.1.2). What you also can do is set up a test to see at
which point the serialize() function crashes.

Just comment out portings of the class instantiated through the $rs2 object
and de-comment portions up untill the moment serialize() crashes.
JW


Jan 14 '06 #8
Rafi B. wrote:
Problem is, I'm very new to Linux, and I have a Linux/CentOs/cPanel
server
and the cPanel support PHP until version 5.0.5


Well, then try the debugging routine I suggested. It might give you a clue
on what's going on.
JW
Jan 15 '06 #9
Rafi B. wrote:
<snip>
when I do IN MY CODE:
$sdata = serialize($myresult);

CRASHES. Fatal. Doesn't spit anything in the logs, or screen. Just dies
so brutally.


What's in $myresult?
Do a var_dump($myresult)

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jan 15 '06 #10
FIXED !!!
It was apprently a PHP 5.0.5 overflow bug, or something like it.
Looking through the BUG FIXES of PHP 5.1.2 I saw some fixes for
serialize/deserialize, thanks for Dimitry and Ilia, the bug fixers, and
the fact that I've upgraded PHP to 5.1.2, everything works like a charm.

Jan 18 '06 #11

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.