Loading includes/entity.inc +4 −1 Original line number Diff line number Diff line Loading @@ -254,7 +254,10 @@ protected function cleanIds(&$ids) { * Callback for array_filter that removes non-integer IDs. */ protected function filterId($id) { return is_numeric($id) && $id == (int) $id; // ctype_digit() is used here instead of a strict comparison as sometimes // the id is passed as a string containing '0' which may represent a bug // elsewhere but would fail with a strict comparison. return is_numeric($id) && $id == (int) $id && ctype_digit((string) $id); } /** Loading modules/simpletest/tests/entity_crud.test +12 −0 Original line number Diff line number Diff line Loading @@ -46,4 +46,16 @@ class EntityLoadTestCase extends DrupalWebTestCase { $this->assertIdentical($nodes_loaded[$node_2->nid], $all_nodes[$node_2->nid], 'Loaded node 2 is identical to cached node.'); $this->assertIdentical($nodes_loaded[$node_3->nid], $all_nodes[$node_3->nid], 'Loaded node 3 is identical to cached node.'); } public function testEntityLoadIds() { $this->drupalCreateNode(array('title' => 'Node 1')); $this->drupalCreateNode(array('title' => 'Node 2')); $nodes_loaded = entity_load('node', array('1', '2')); $this->assertEqual(count($nodes_loaded), 2); // Ensure that an id with a trailing decimal place is ignored. $nodes_loaded = entity_load('node', array('1.', '2')); $this->assertEqual(count($nodes_loaded), 1); } } Loading
includes/entity.inc +4 −1 Original line number Diff line number Diff line Loading @@ -254,7 +254,10 @@ protected function cleanIds(&$ids) { * Callback for array_filter that removes non-integer IDs. */ protected function filterId($id) { return is_numeric($id) && $id == (int) $id; // ctype_digit() is used here instead of a strict comparison as sometimes // the id is passed as a string containing '0' which may represent a bug // elsewhere but would fail with a strict comparison. return is_numeric($id) && $id == (int) $id && ctype_digit((string) $id); } /** Loading
modules/simpletest/tests/entity_crud.test +12 −0 Original line number Diff line number Diff line Loading @@ -46,4 +46,16 @@ class EntityLoadTestCase extends DrupalWebTestCase { $this->assertIdentical($nodes_loaded[$node_2->nid], $all_nodes[$node_2->nid], 'Loaded node 2 is identical to cached node.'); $this->assertIdentical($nodes_loaded[$node_3->nid], $all_nodes[$node_3->nid], 'Loaded node 3 is identical to cached node.'); } public function testEntityLoadIds() { $this->drupalCreateNode(array('title' => 'Node 1')); $this->drupalCreateNode(array('title' => 'Node 2')); $nodes_loaded = entity_load('node', array('1', '2')); $this->assertEqual(count($nodes_loaded), 2); // Ensure that an id with a trailing decimal place is ignored. $nodes_loaded = entity_load('node', array('1.', '2')); $this->assertEqual(count($nodes_loaded), 1); } }