mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Ensure that DataObject IDs are numbers and no string equivalents of numbers - 3 not '3' (from r101939)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112049 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
bbdad4207f
commit
daa50b9d3b
@ -342,7 +342,13 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
// Set $this->record to $record, but ignore NULLs
|
// Set $this->record to $record, but ignore NULLs
|
||||||
$this->record = array();
|
$this->record = array();
|
||||||
foreach($record as $k => $v) {
|
foreach($record as $k => $v) {
|
||||||
if($v !== null) $this->record[$k] = $v;
|
// Ensure that ID is stored as a number and not a string
|
||||||
|
// To do: this kind of clean-up should be done on all numeric fields, in some relatively
|
||||||
|
// performant manner
|
||||||
|
if($v !== null) {
|
||||||
|
if($k == 'ID' && is_numeric($v)) $this->record[$k] = (int)$v;
|
||||||
|
else $this->record[$k] = $v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->original = $this->record;
|
$this->original = $this->record;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user