diff --git a/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php b/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php
index 691868d..a61af67 100644
--- a/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php
+++ b/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php
@@ -67,7 +67,8 @@ public function __construct(array $definition, $name = NULL, ContextAwareInterfa
   public function getValue() {
     $source = $this->getIdSource();
     $id = $source ? $source->getValue() : $this->id;
-    return $id ? entity_load($this->entityType, $id) : NULL;
+    // If $id is numeric, trust that it is correct.
+    return $id || is_numeric($id) ? entity_load($this->entityType, $id) : NULL;
   }
 
   /**
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Core/Condition/UserRole.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Condition/UserRole.php
new file mode 100644
index 0000000..180eab2
--- /dev/null
+++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Condition/UserRole.php
@@ -0,0 +1,101 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Plugin\Core\Condition\UserRole.
+ */
+
+namespace Drupal\user\Plugin\Core\Condition;
+
+use Drupal\Core\Condition\ConditionPluginBase;
+use Drupal\Core\Annotation\Plugin;
+use Drupal\Core\Annotation\Translation;
+
+/**
+ * Provides a 'User Role' condition.
+ *
+ * @Plugin(
+ *   id = "user_role",
+ *   label = @Translation("User Role"),
+ *   module = "user",
+ *   context = {
+ *     "user" = {
+ *       "type" = "entity",
+ *       "constraints" = {
+ *         "EntityType" = "user"
+ *       }
+ *     }
+ *   }
+ * )
+ */
+class UserRole extends ConditionPluginBase {
+
+  /**
+   * Overrides \Drupal\Core\Condition\ConditionPluginBase::buildForm().
+   */
+  public function buildForm(array $form, array &$form_state) {
+    $form['roles'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Show block for specific roles'),
+      '#default_value' => !empty($this->configuration['roles']) ? $this->configuration['roles'] : array(),
+      '#options' => array_map('check_plain', user_role_names()),
+      '#description' => t('Show this block only for the selected role(s). If you select no roles, the block will be visible to all users.'),
+      '#required' => TRUE,
+    );
+    return parent::buildForm($form, $form_state);
+  }
+
+  /**
+   * Overrides \Drupal\Core\Condition\ConditionPluginBase::validateForm().
+   */
+  public function validateForm(array &$form, array &$form_state) {
+    foreach ($form_state['values']['roles'] as $role) {
+      if (!in_array($role, array_keys(array_map('check_plain', user_role_names())))) {
+        form_set_error('roles', t('You have chosen an invalid user role, please check your selection and try again.'));
+      }
+    }
+    parent::validateForm($form, $form_state);
+  }
+
+  /**
+   * Overrides \Drupal\Core\Condition\ConditionPluginBase::submitForm().
+   */
+  public function submitForm(array &$form, array &$form_state) {
+    $this->configuration['roles'] = array_filter($form_state['values']['roles']);
+    parent::submitForm($form, $form_state);
+  }
+
+  /**
+   * Implements \Drupal\Core\Executable\ExecutableInterface::summary().
+   */
+  public function summary() {
+    if (count($this->configuration['roles']) > 1) {
+      $roles = $this->configuration['roles'];
+      $last = array_pop($roles);
+      $roles = implode(', ', $roles);
+      return t('The user is @not a member of @roles or @last',
+        array(
+          '@roles' => $roles,
+          '@last' => $last,
+          '@not' => !empty($this->configuration['negate']) ? 'not' : ''
+        )
+      );
+    }
+    $roles = array_pop($this->configuration['roles']);
+    return t('The user is @not a member of @roles',
+      array(
+        '@roles' => $roles,
+        '@not' => !empty($this->configuration['negate']) ? 'not' : ''
+      )
+    );
+  }
+
+  /**
+   * Implements \Drupal\condition\ConditionInterface::evaluate().
+   */
+  public function evaluate() {
+    $user = $this->getContextValue('user');
+    return (bool) (array_intersect(array_filter($this->configuration['roles']), array_keys($user->roles))) ? TRUE : FALSE;
+  }
+
+}
diff --git a/core/modules/user/lib/Drupal/user/Tests/Condition/UserRoleConditionTest.php b/core/modules/user/lib/Drupal/user/Tests/Condition/UserRoleConditionTest.php
new file mode 100644
index 0000000..4521588
--- /dev/null
+++ b/core/modules/user/lib/Drupal/user/Tests/Condition/UserRoleConditionTest.php
@@ -0,0 +1,121 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Tests\Condition\UserRoleConditionTest.
+ */
+
+namespace Drupal\user\Tests\Condition;
+
+use Drupal\simpletest\DrupalUnitTestBase;
+use Drupal\Core\Condition\ConditionManager;
+use Drupal\user\Plugin\Core\Entity\User;
+
+/**
+ * Tests the user role condition.
+ */
+class UserRoleConditionTest extends DrupalUnitTestBase {
+
+  /**
+   * The condition plugin manager.
+   *
+   * @var \Drupal\Core\Condition\ConditionManager
+   */
+  protected $manager;
+
+  /**
+   * An anonymous user for testing purposes.
+   *
+   * @var \Drupal\user\Plugin\Core\Entity\User
+   */
+  protected $anonymous;
+
+  /**
+   * An authenticated user for testing purposes.
+   *
+   * @var \Drupal\user\Plugin\Core\Entity\User
+   */
+  protected $authenticated;
+
+  public static $modules = array('system', 'user', 'field');
+
+  public static function getInfo() {
+    return array(
+      'name' => 'User Role Condition Plugin',
+      'description' => 'Tests that the User Role Condition, provided by the user module, is working properly.',
+      'group' => 'Condition API',
+    );
+  }
+
+  protected function setUp() {
+    parent::setUp();
+
+    $this->installSchema('system', 'sequences');
+    $this->installSchema('user', 'users');
+    $this->installSchema('user', 'users_roles');
+    $this->installSchema('field', 'field_config');
+    $this->installSchema('field', 'field_config_instance');
+
+    $this->manager = new ConditionManager();
+
+    // Setup an anonymous user for our tests.
+    $anonymous = new User((array) drupal_anonymous_user(), 'user');
+    $anonymous->save();
+    // Users with a non-0 uid will not get the anonymous role, so we have to
+    // change the uid of the $this->anonymous user after saving.
+    db_update('users')->fields(array('uid' => 0))->condition('uid', $anonymous->id())->execute();
+    $this->anonymous = entity_load('user', 0);
+
+    // Setup an authenticated user for our tests.
+    $this->authenticated = new User(array('name' => $this->randomName(), 'bundle' => 'user', 'roles' => array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID)), 'user');
+    $this->authenticated->save();
+  }
+
+  /**
+   * Tests conditions.
+   */
+  function testConditions() {
+    // Grab the user role condition and configure it to check against
+    // authenticated user roles.
+    $condition = $this->manager->createInstance('user_role')
+      ->setConfig('roles', array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID))
+      ->setContextValue('user', $this->anonymous);
+    $this->assertFalse($condition->execute(), 'Anonymous users fail role checks for authenticated.');
+    // Check for the proper summary.
+    // Summaries require an extra space due to negate handling in summary().
+    $this->assertEqual('The user is  a member of authenticated', $condition->summary());
+
+    // Set the user role to anonymous.
+    $condition->setConfig('roles', array(DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID));
+    $this->assertTrue($condition->execute(), 'Anonymous users pass role checks for anonymous.');
+    // Check for the proper summary.
+    $this->assertEqual('The user is  a member of anonymous', $condition->summary());
+
+    // Set the user role to check anonymous or authenticated.
+    $condition->setConfig('roles', array(DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID));
+    $this->assertTrue($condition->execute(), 'Anonymous users pass role checks for anonymous or authenticated.');
+    // Check for the proper summary.
+    $this->assertEqual('The user is  a member of anonymous or authenticated', $condition->summary());
+
+    // Set the context to the authenticated user and check that they also pass
+    // against anonymous or authenticated roles.
+    $condition->setContextValue('user', $this->authenticated);
+    $this->assertTrue($condition->execute(), 'Authenticated users pass role checks for anonymous or authenticated.');
+
+    // Set the role to just authenticated and recheck.
+    $condition->setConfig('roles', array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID));
+    $this->assertTrue($condition->execute(), 'Authenticated users pass role checks for authenticated.');
+
+    // Test Constructor injection.
+    $condition = $this->manager->createInstance('user_role', array('roles' => array(DRUPAL_AUTHENTICATED_RID), 'context' => array('user' => $this->authenticated)));
+    $this->assertTrue($condition->execute(), 'Constructor injection of context and configuration working as anticipated.');
+
+    // Check the negated summary.
+    $condition->setConfig('negate', TRUE);
+    $this->assertEqual('The user is not a member of authenticated', $condition->summary());
+
+    // Check the complex negated summary.
+    $condition->setConfig('roles', array(DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID));
+    $this->assertEqual('The user is not a member of anonymous or authenticated', $condition->summary());
+  }
+}
