diff --git a/core/modules/node/lib/Drupal/node/Plugin/Core/Condition/NodeType.php b/core/modules/node/lib/Drupal/node/Plugin/Core/Condition/NodeType.php index 0712745..2544c5a 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Core/Condition/NodeType.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Condition/NodeType.php @@ -85,8 +85,9 @@ public function summary() { * Implements \Drupal\condition\ConditionInterface::evaluate(). */ public function evaluate() { - $node = $this->getContextValue('node'); - return in_array($node->type, $this->configuration['bundles']); + if ($node = $this->getContextValue('node')) { + return in_array($node->type, $this->configuration['bundles']); + } } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Condition/ConditionFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Condition/ConditionFormTest.php index e191efe..c183c78 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Condition/ConditionFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Condition/ConditionFormTest.php @@ -32,6 +32,10 @@ public static function getInfo() { * Submit the condition_node_type_test_form to test condition forms. */ function testConfigForm() { + // Attempt to test a condition for a node when none exist. + $this->drupalPost('condition_test', array('bundles[page]' => 'page', 'bundles[article]' => 'article'), t('Submit')); + $this->assertNoText('Executed successfully.', 'The form configured condition was invalid, so it was not executed properly.'); + $article = entity_create('node', array('type' => 'article', 'title' => $this->randomName())); $article->save(); $this->drupalGet('condition_test');