diff --git a/eZ/Publish/Core/FieldType/Keyword/KeywordStorage/Gateway/DoctrineStorage.php b/eZ/Publish/Core/FieldType/Keyword/KeywordStorage/Gateway/DoctrineStorage.php index 5bbe969c625..f7ba605af29 100644 --- a/eZ/Publish/Core/FieldType/Keyword/KeywordStorage/Gateway/DoctrineStorage.php +++ b/eZ/Publish/Core/FieldType/Keyword/KeywordStorage/Gateway/DoctrineStorage.php @@ -255,7 +255,7 @@ protected function insertKeywords(array $keywordsToInsert, $contentTypeId) foreach (array_keys($keywordsToInsert) as $keyword) { $insertQuery->setParameter(':keyword', $keyword); $insertQuery->execute(); - $keywordIdMap[$keyword] = $this->connection->lastInsertId( + $keywordIdMap[$keyword] = (int)$this->connection->lastInsertId( $this->getSequenceName(self::KEYWORD_TABLE, 'id') ); } diff --git a/eZ/Publish/Core/FieldType/Url/UrlStorage/Gateway/DoctrineStorage.php b/eZ/Publish/Core/FieldType/Url/UrlStorage/Gateway/DoctrineStorage.php index dc42e8d291f..c2b08896d27 100644 --- a/eZ/Publish/Core/FieldType/Url/UrlStorage/Gateway/DoctrineStorage.php +++ b/eZ/Publish/Core/FieldType/Url/UrlStorage/Gateway/DoctrineStorage.php @@ -124,7 +124,7 @@ public function insertUrl($url) $query->execute(); - return $this->connection->lastInsertId( + return (int)$this->connection->lastInsertId( $this->getSequenceName(self::URL_TABLE, 'id') ); } diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php index a585a5b8745..a6f1467abd0 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php @@ -186,7 +186,7 @@ public function insertContentObject(CreateStruct $struct, $currentVersionNo = 1) $q->prepare()->execute(); - return $this->dbHandler->lastInsertId( + return (int)$this->dbHandler->lastInsertId( $this->dbHandler->getSequenceName('ezcontentobject', 'id') ); } @@ -275,7 +275,7 @@ public function insertVersion(VersionInfo $versionInfo, array $fields) $q->prepare()->execute(); - return $this->dbHandler->lastInsertId( + return (int)$this->dbHandler->lastInsertId( $this->dbHandler->getSequenceName('ezcontentobject_version', 'id') ); } @@ -673,7 +673,7 @@ public function insertNewField(Content $content, Field $field, StorageFieldValue $q->prepare()->execute(); - return $this->dbHandler->lastInsertId( + return (int)$this->dbHandler->lastInsertId( $this->dbHandler->getSequenceName('ezcontentobject_attribute', 'id') ); } @@ -742,7 +742,7 @@ protected function setInsertFieldValues(InsertQuery $q, Content $content, Field $q->bindValue($value->sortKeyInt, null, \PDO::PARAM_INT) )->set( $this->dbHandler->quoteColumn('sort_key_string'), - $q->bindValue(mb_substr($value->sortKeyString, 0, 255)) + $q->bindValue(mb_substr((string)$value->sortKeyString, 0, 255)) )->set( $this->dbHandler->quoteColumn('language_id'), $q->bindValue( @@ -823,7 +823,7 @@ protected function setFieldUpdateValues(UpdateQuery $q, StorageFieldValue $value $q->bindValue($value->sortKeyInt, null, \PDO::PARAM_INT) )->set( $this->dbHandler->quoteColumn('sort_key_string'), - $q->bindValue(mb_substr($value->sortKeyString, 0, 255)) + $q->bindValue(mb_substr((string)$value->sortKeyString, 0, 255)) ); } @@ -1310,7 +1310,7 @@ public function listVersionNumbers($contentId) $statement = $query->prepare(); $statement->execute(); - return $statement->fetchAll(\PDO::FETCH_COLUMN); + return array_map('intval', $statement->fetchAll(\PDO::FETCH_COLUMN)); } /** @@ -2097,7 +2097,7 @@ public function insertRelation(RelationCreateStruct $createStruct) $q->prepare()->execute(); - return $this->dbHandler->lastInsertId( + return (int)$this->dbHandler->lastInsertId( $this->dbHandler->getSequenceName('ezcontentobject_link', 'id') ); } diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php b/eZ/Publish/Core/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php index fe8d94ad6b7..53e19ea3c05 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Location/Gateway/DoctrineDatabase.php @@ -768,7 +768,7 @@ public function create(CreateStruct $createStruct, array $parentNode) ); $query->prepare()->execute(); - $location->id = $this->handler->lastInsertId($this->handler->getSequenceName('ezcontentobject_tree', 'node_id')); + $location->id = (int)$this->handler->lastInsertId($this->handler->getSequenceName('ezcontentobject_tree', 'node_id')); $mainLocationId = $createStruct->mainLocationId === true ? $location->id : $createStruct->mainLocationId; $location->pathString = $parentNode['path_string'] . $location->id . '/'; diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Location/Handler.php b/eZ/Publish/Core/Persistence/Legacy/Content/Location/Handler.php index 8d7cacbff70..955283cb838 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Location/Handler.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Location/Handler.php @@ -251,8 +251,8 @@ public function copySubtree($sourceId, $destinationParentId, $newOwnerId = null) // Copy content if (!isset($contentMap[$child['contentobject_id']])) { $content = $this->contentHandler->copy( - $child['contentobject_id'], - $child['contentobject_version'], + (int)$child['contentobject_id'], + (int)$child['contentobject_version'], $newOwnerId ); diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php b/eZ/Publish/Core/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php index 6384900137a..87cd8ee5385 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Type/Gateway/DoctrineDatabase.php @@ -361,7 +361,8 @@ public function insertType(Type $type, $typeId = null) $this->insertTypeNameData($typeId, $type->status, $type->name); - return $typeId; + // $typeId passed as the argument could still be non-int + return (int)$typeId; } /** @@ -615,9 +616,9 @@ public function insertFieldDefinition( $q->prepare()->execute(); - $fieldDefinitionId = $fieldDefinition->id ?? $this->dbHandler->lastInsertId( + $fieldDefinitionId = (int)($fieldDefinition->id ?? $this->dbHandler->lastInsertId( $this->dbHandler->getSequenceName('ezcontentclass_attribute', 'id') - ); + )); foreach ($storageFieldDef->multilingualData as $multilingualData) { $this->insertFieldDefinitionMultilingualData($fieldDefinitionId, $multilingualData, $status); diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php b/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php index f9e80f54463..88d8251cb22 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Gateway/DoctrineDatabase.php @@ -709,7 +709,7 @@ public function getNextId() } $query->prepare()->execute(); - return $this->dbHandler->lastInsertId($sequence); + return (int)$this->dbHandler->lastInsertId($sequence); } /** diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/UrlWildcard/Gateway/DoctrineDatabase.php b/eZ/Publish/Core/Persistence/Legacy/Content/UrlWildcard/Gateway/DoctrineDatabase.php index 41d4fd859ca..d23d7934898 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/UrlWildcard/Gateway/DoctrineDatabase.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/UrlWildcard/Gateway/DoctrineDatabase.php @@ -83,7 +83,7 @@ public function insertUrlWildcard(UrlWildcard $urlWildcard) $query->prepare()->execute(); - return $this->dbHandler->lastInsertId( + return (int)$this->dbHandler->lastInsertId( $this->dbHandler->getSequenceName('ezurlwildcard', 'id') ); }