Commit 604072f0 authored by fago's avatar fago

Issue #2476821 by znerol, ladybug_3777, jmouse888: Array flip errors when...

Issue #2476821 by znerol, ladybug_3777, jmouse888: Array flip errors when books are not part of a book hierarchy. --author="znerol <znerol@63999.no-reply.drupal.org>
parent 4d76c5c2
......@@ -1466,6 +1466,7 @@ class EntityMetadataIntegrationTestCase extends EntityWebTestCase {
$book = array('bid' => $node->nid, 'plid' => $node->book['mlid']);
$node2 = $this->drupalCreateNode(array('type' => 'book', 'book' => $book));
$node3 = $this->drupalCreateNode(array('type' => 'page'));
$node4 = $this->drupalCreateNode(array('type' => 'book', 'book' => array('bid' => 0, 'plid' => -1)));
// Test whether the properties work.
$wrapper = entity_metadata_wrapper('node', $node2);
......@@ -1477,6 +1478,10 @@ class EntityMetadataIntegrationTestCase extends EntityWebTestCase {
$wrapper = entity_metadata_wrapper('node', $node3);
$this->assertEmpty($wrapper, 'book');
$this->assertEmptyArray($wrapper, 'book_ancestors');
// Test a book node which is not contained in a hierarchy.
$wrapper = entity_metadata_wrapper('node', $node4);
$this->assertEmptyArray($wrapper, 'book_ancestors');
}
/**
......
......@@ -29,7 +29,7 @@ function entity_metadata_book_get_properties($node, array $options, $name, $enti
case 'book_ancestors':
$ancestors = array();
while (!empty($node->book['plid'])) {
while (!empty($node->book['plid']) && $node->book['plid'] != -1) {
$link = book_link_load($node->book['plid']);
array_unshift($ancestors, $link['nid']);
$node = node_load($link['nid']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment