#9283 [Com]: Serialized data gets corrupted in DBM
| From: | adam at saki dot com dot au | Date: | Wed, 21 May 2003 04:56:44 +0000 |
| Subject: | #9283 [Com]: Serialized data gets corrupted in DBM | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-40112@lists.php.net to get a copy of this message | ||
ID: 9283
Comment by: adam at saki dot com dot au
Reported By: sam at 2bhox dot com
Status: No Feedback
Bug Type: DBM/DBA related
Operating System: Windows 98
PHP Version: 4.0.4pl1
New Comment:
I have seen the exact same problem on a DG Aviion (DG/UX) system using
PHP 4.2.3. Also the file was dba not dbm so I suspect it is the
serializer, not the file access code. Apart from that the symptoms
were the same.
Previous Comments:
------------------------------------------------------------------------
[2002-05-22 00:00:05] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2002-04-19 01:21:06] alan_k@php.net
can you try again to reproduce this using php4.2.0RC4?
http://www.php.net/~derick/
------------------------------------------------------------------------
[2001-02-15 11:53:08] sam at 2bhox dot com
I created a set of programs for maintaining userid and password
information using the DBM functions. (dbmopen, dbminsert, etc).. I keep
userid, password, effective date, expiry dates, etc... Hence I need to
keep more than just name & password pairs... I use the userid as the
name and the value is a serialized variable containing an associative
array of the remaining fields...
My PHP programs to add and display the user records works -
unfortunately it works intermittently... Some time all records are
written correctly and are displayed correctly.. but sometime several
are written but when are displayed, the details of the serialized data
are missing.. it seems to be corrupted...
I attach some code for the dbminsert and dbmfetch here...
Notes: $user is an associative array containing the password, start
dates, etc.
function addUser( $dbName, &$dbStatus, $userid, $user ) {
$dbh = dbmopen( "$dbName", "w" )
or die("Couldn't open $dbName database");
$serial_user = serialize( $user );
print "serial_user is equal to <br> $serial_user <br>";
$dbStatus = dbminsert( $dbh, "$userid", "$serial_user" );
dbmclose( $dbh );
}
function getUser( $dbName, &$dbStatus, $userid ) {
$dbh = dbmopen( "$dbName", "r" ) // --- read db ----
or die("Couldn't open $dbName database");
if ( dbmexists( $dbh, $userid ) )
{
$serial_user = dbmfetch( $dbh, $userid );
print "serial_user is equal to <br> $serial_user <br>";
$user = unserialize( $serial_user );
}
else
{ $dbStatus = -1; }
dbmclose( $dbh );
return $user;
}
I looked at the dbm file itself using a text editor and all the data
are present, even for those records that shows blanks for the details.
I opened 2 Internet Explorer windows side by side and ran the insert
program on one and the display on the other. I displayed the serialized
value (i.e. $serial_user) on both windows...
In the add window, the serialized data always looks like this:
a:5:{s:4:"name;s:1:"a";s:3:"pwd.... ETC ETC...
In the display window, the serialized data also looked as above when
the data is displayed correctly...
However, when the data is 'missing' the serialized data looks like
this
:5:{s:4:"name;s:1:"a";s:3:"pwd.... ETC ETC...
(i.e. the 'a' is missing).
(you can see my debugging print statements in the code that I attached
above).
I am running PHP on Apache Web Server (1.3.14) for Windows. Both the
browser client and the Apache server are running on the same PC.
Thanks in advance for your help!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=9283&edit=1