From eb3c8b1e5297895e4872efb8a70dfa59a11a6bd8 Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Fri, 20 Jun 2014 13:18:36 +0100
Subject: [PATCH] Revert "Issue #1003788 by stefan.r, Alan D., Josh Waihi,
 JimmyAx, robhardwick, wiifm, twistor, pwolanin, bzrudi71, bellHead,
 john_brown: Fixed PostgreSQL: PDOException:Invalid text representation when
 attempting to load an entity with a string or non-scalar ID."

This reverts commit 4086829bbe01648c79c06ad7ecb0b36b3ce3aa8a.
---
 .../Entity/ContentEntityDatabaseStorage.php   | 37 -------------------
 .../Tests/Entity/EntityViewControllerTest.php |  5 ---
 2 files changed, 42 deletions(-)

diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
index 2a8bb1436da9..a60122fb77e5 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityDatabaseStorage.php
@@ -342,10 +342,6 @@ public function getTableMapping() {
    * {@inheritdoc}
    */
   protected function doLoadMultiple(array $ids = NULL) {
-    if (!empty($ids)) {
-      $ids = $this->cleanIds($ids);
-    }
-
     // Build and execute the query.
     $records = $this
       ->buildQuery($ids)
@@ -355,39 +351,6 @@ protected function doLoadMultiple(array $ids = NULL) {
     return $this->mapFromStorageRecords($records);
   }
 
-  /**
-   * Sanitizes the entity IDs to the correct data type.
-   *
-   * The identifier sanitization provided by this method has been introduced
-   * as Drupal used to rely on the database to facilitate this, which worked
-   * correctly with MySQL but led to errors with other DBMS such as PostgeSQL.
-   *
-   * @param array $ids
-   *   The entity IDs to verify.
-   * @return array
-   *   The sanitized list of entity IDs.
-   */
-  protected function cleanIds(array $ids) {
-    $keys = $this->entityType->getKeys();
-    $bundle = $keys['bundle'] ? $keys['bundle'] : $this->entityTypeId;
-
-    $definitions = $this->entityManager->getFieldDefinitions($this->entityTypeId, $bundle);
-    $info = $this->entityManager->getDefinition($this->entityTypeId);
-    $id_definition = $definitions[$info->getKey('id')];
-
-    switch ($id_definition->getType()) {
-      case 'integer':
-        $ids = array_filter($ids, 'is_numeric');
-        $ids = array_map('intval', $ids);
-        break;
-      case 'string':
-        $ids = array_filter($ids, 'is_string');
-        $ids = array_map('strval', $ids);
-        break;
-    }
-    return $ids;
-  }
-
   /**
    * Maps from storage records to entity objects.
    *
diff --git a/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php b/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php
index 19515d03c0b3..4faec44b5673 100644
--- a/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityViewControllerTest.php
@@ -76,11 +76,6 @@ function testEntityViewController() {
       $this->assertRaw($entity->label());
       $this->assertRaw('full');
     }
-
-    // As entity_test IDs must be integers, make sure requests for non-integer
-    // IDs return a page not found error.
-    $this->drupalGet('entity_test/invalid');
-    $this->assertResponse(404);
   }
 
   /**
-- 
GitLab