DbObject: Don't confuse ids and object_names

fixes #992
This commit is contained in:
Peter Backes 2017-07-10 20:43:03 +02:00 committed by Thomas Gelf
parent 4a0e8df2f2
commit bec8ef1ac2

View File

@ -1047,6 +1047,14 @@ abstract class DbObject
public static function loadWithAutoIncId($id, DbConnection $connection)
{
/* Need to cast to int, otherwise the id will be matched against
* object_name, which may wreak havoc if an object has a
* object_name matching some id. Note that DbObject::set() and
* DbObject::setDbProperties() will convert any property to
* string, including ids.
*/
$id = (int) $id;
if ($prefetched = static::getPrefetched($id)) {
return $prefetched;
}