From 4b4ccf365af37a4ff36a2532e36f58fb5631f2cb Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Fri, 21 Nov 2014 22:32:10 +0100 Subject: [PATCH] Fixed entity IDs being strings This coincidentally fixes editing newly added comments. --- src/Dao/AbstractDao.php | 2 +- src/Dao/EntityConverters/CommentEntityConverter.php | 2 +- src/Dao/EntityConverters/FavoriteEntityConverter.php | 2 +- src/Dao/EntityConverters/GlobalParamEntityConverter.php | 2 +- src/Dao/EntityConverters/PostNoteEntityConverter.php | 2 +- src/Dao/EntityConverters/ScoreEntityConverter.php | 2 +- src/Dao/EntityConverters/TagEntityConverter.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Dao/AbstractDao.php b/src/Dao/AbstractDao.php index 6ee1dce1..4a4a0cf5 100644 --- a/src/Dao/AbstractDao.php +++ b/src/Dao/AbstractDao.php @@ -137,7 +137,7 @@ abstract class AbstractDao implements ICrudDao, IBatchDao $query->execute(); $lastUsedId = $this->pdo->query('SELECT @lastUsedId')->fetchColumn(); - $entity->setId($lastUsedId); + $entity->setId(intval($lastUsedId)); $arrayEntity = $this->entityConverter->toArray($entity); $this->pdo->insertInto($this->tableName)->values($arrayEntity)->execute(); return $entity; diff --git a/src/Dao/EntityConverters/CommentEntityConverter.php b/src/Dao/EntityConverters/CommentEntityConverter.php index d841e424..9e772ec2 100644 --- a/src/Dao/EntityConverters/CommentEntityConverter.php +++ b/src/Dao/EntityConverters/CommentEntityConverter.php @@ -19,7 +19,7 @@ class CommentEntityConverter extends AbstractEntityConverter implements IEntityC public function toBasicEntity(array $array) { - $entity = new Comment($array['id']); + $entity = new Comment(intval($array['id'])); $entity->setUserId($array['userId']); $entity->setPostId($array['postId']); $entity->setText($array['text']); diff --git a/src/Dao/EntityConverters/FavoriteEntityConverter.php b/src/Dao/EntityConverters/FavoriteEntityConverter.php index 73ddb72e..21bdc985 100644 --- a/src/Dao/EntityConverters/FavoriteEntityConverter.php +++ b/src/Dao/EntityConverters/FavoriteEntityConverter.php @@ -17,7 +17,7 @@ class FavoriteEntityConverter extends AbstractEntityConverter implements IEntity public function toBasicEntity(array $array) { - $entity = new Favorite($array['id']); + $entity = new Favorite(intval($array['id'])); $entity->setUserId($array['userId']); $entity->setPostId($array['postId']); $entity->setTime($this->dbTimeToEntityTime($array['time'])); diff --git a/src/Dao/EntityConverters/GlobalParamEntityConverter.php b/src/Dao/EntityConverters/GlobalParamEntityConverter.php index 0ad8f4bb..060d60e6 100644 --- a/src/Dao/EntityConverters/GlobalParamEntityConverter.php +++ b/src/Dao/EntityConverters/GlobalParamEntityConverter.php @@ -16,7 +16,7 @@ class GlobalParamEntityConverter extends AbstractEntityConverter implements IEnt public function toBasicEntity(array $array) { - $entity = new GlobalParam($array['id']); + $entity = new GlobalParam(intval($array['id'])); $entity->setKey($array['dataKey']); $entity->setValue($array['dataValue']); return $entity; diff --git a/src/Dao/EntityConverters/PostNoteEntityConverter.php b/src/Dao/EntityConverters/PostNoteEntityConverter.php index 627aba17..1ae357ba 100644 --- a/src/Dao/EntityConverters/PostNoteEntityConverter.php +++ b/src/Dao/EntityConverters/PostNoteEntityConverter.php @@ -20,7 +20,7 @@ class PostNoteEntityConverter extends AbstractEntityConverter implements IEntity public function toBasicEntity(array $array) { - $entity = new PostNote($array['id']); + $entity = new PostNote(intval($array['id'])); $entity->setPostId($array['postId']); $entity->setLeft(floatval($array['x'])); $entity->setTop(floatval($array['y'])); diff --git a/src/Dao/EntityConverters/ScoreEntityConverter.php b/src/Dao/EntityConverters/ScoreEntityConverter.php index 6332fcda..f860b31f 100644 --- a/src/Dao/EntityConverters/ScoreEntityConverter.php +++ b/src/Dao/EntityConverters/ScoreEntityConverter.php @@ -19,7 +19,7 @@ class ScoreEntityConverter extends AbstractEntityConverter implements IEntityCon public function toBasicEntity(array $array) { - $entity = new Score($array['id']); + $entity = new Score(intval($array['id'])); $entity->setUserId($array['userId']); $entity->setPostId($array['postId']); $entity->setCommentId($array['commentId']); diff --git a/src/Dao/EntityConverters/TagEntityConverter.php b/src/Dao/EntityConverters/TagEntityConverter.php index 0c3726c6..2f012a76 100644 --- a/src/Dao/EntityConverters/TagEntityConverter.php +++ b/src/Dao/EntityConverters/TagEntityConverter.php @@ -18,7 +18,7 @@ class TagEntityConverter extends AbstractEntityConverter implements IEntityConve public function toBasicEntity(array $array) { - $entity = new Tag($array['id']); + $entity = new Tag(intval($array['id'])); $entity->setName($array['name']); $entity->setCreationTime($this->dbTimeToEntityTime($array['creationTime'])); $entity->setMeta(Tag::META_USAGES, intval($array['usages']));