Home » Database » DB_DataObject » Bug #9573
Improper handling of 'Null' string value
Details
| Submitted | 2006-12-07 15:29 UTC |
|---|---|
| From | cj at sitemajic dot com |
| Assigned | alan_k |
| Status | Closed |
| Package | DB_DataObject |
| PHP Version | 5.1.6 |
| OS | Red Hat Linux Enterprise |
| Roadmaps | (Not assigned) |
Comments
[2006-12-07 15:29 UTC] cj at sitemajic dot com
Description:
------------
From DB_Dataobject.php
if (is_string($this->$k) && (strtolower($this->$k) === 'null') && !($v & DB_DATAOBJECT_NOTNULL)) {
$rightq .= " NULL ";
continue;
}
When attempting to add a real person to a database with the last name 'Null' I found that DB_Dataobject was deciding for me that my string value was actually null instead of it's real value 'Null'
If a field is null it should be null, if it's a string with the word 'null' or 'Null' or 'NUll' in it there should be no conversion -- this was a bad assumption!
Test script:
---------------
Just take any dataobject and try to save the string value 'Null'
Expected result:
----------------
The dataobject will write the value null to the database instead of the intended 'Null'
Actual result:
--------------
Data was improperly saved and lost
[2006-12-12 02:52 UTC] cj at sitemajic dot com
Amazingly this error was brought to light by the fact that there is a real person with the name "Ralph Null" and the client kept getting frustrated that the last name would disappear every time they edited it anywhere :)