diff --git a/core/modules/block/block.install b/core/modules/block/block.install index dc7cee5..470d3bc 100644 --- a/core/modules/block/block.install +++ b/core/modules/block/block.install @@ -234,7 +234,7 @@ function block_update_dependencies() { 'user' => 8002, ); // Migrate users.data after User module prepared the tables. - $dependencies['block'][8004] = array( + $dependencies['block'][8005] = array( 'user' => 8011, ); return $dependencies; diff --git a/core/modules/contact/contact.install b/core/modules/contact/contact.install index b5487c9..845aa1f 100644 --- a/core/modules/contact/contact.install +++ b/core/modules/contact/contact.install @@ -26,7 +26,7 @@ function contact_install() { */ function contact_update_dependencies() { // Migrate users.data after User module prepared the tables. - $dependencies['contact'][8001] = array( + $dependencies['contact'][8003] = array( 'user' => 8011, ); return $dependencies; @@ -79,7 +79,6 @@ function contact_update_8002() { db_drop_table('contact'); } - /** * Migrate {users}.data into {users_data}. */ diff --git a/core/modules/user/lib/Drupal/user/UserStorageController.php b/core/modules/user/lib/Drupal/user/UserStorageController.php index 7e26a38..2c92aac 100644 --- a/core/modules/user/lib/Drupal/user/UserStorageController.php +++ b/core/modules/user/lib/Drupal/user/UserStorageController.php @@ -147,6 +147,13 @@ protected function preSave(EntityInterface $entity) { if (isset($entity->roles)) { $entity->roles = array_filter($entity->roles); } + + // Store account cancellation information. + foreach (array('user_cancel_method', 'user_cancel_notify') as $key) { + if (isset($entity->{$key})) { + user_data_set('user', $entity->id(), substr($key, 5), $entity->{$key}); + } + } } /** @@ -185,13 +192,6 @@ protected function postSave(EntityInterface $entity, $update) { $query->execute(); } - // Store account cancellation information. - foreach (array('user_cancel_method', 'user_cancel_notify') as $key) { - if (isset($entity->{$key})) { - user_data_set('user', $entity->uid, substr($key, 5), $entity->{$key}); - } - } - // If the user was blocked, delete the user's sessions to force a logout. if ($entity->original->status != $entity->status && $entity->status == 0) { drupal_session_destroy_uid($entity->uid); diff --git a/core/modules/user/user.module b/core/modules/user/user.module index a5e39f1..2fbbe24 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -3126,7 +3126,7 @@ function user_library_info() { * and $name second. */ function user_data_get($module, $uid = NULL, $name = NULL) { - $query = db_select('users_data', 'ud', array('fetch' => PDO::FETCH_ASSOC)) + $query = db_select('users_data', 'ud') ->fields('ud') ->condition('module', $module); if (isset($uid)) { @@ -3135,11 +3135,12 @@ function user_data_get($module, $uid = NULL, $name = NULL) { if (isset($name)) { $query->condition('name', $name); } - $result = $query->execute()->fetchAllAssoc('uid'); - // If $module, $name, and $uid was passed, return the value. + $result = $query->execute(); + // If $module, $uid, and $name was passed, return the value. if (isset($name) && isset($uid)) { + $result = $result->fetchAllAssoc('uid'); if (isset($result[$uid])) { - return $result[$uid]['serialized'] ? unserialize($result[$uid]['value']) : $result[$uid]['value']; + return $result[$uid]->serialized ? unserialize($result[$uid]->value) : $result[$uid]->value; } return NULL; } @@ -3147,22 +3148,23 @@ function user_data_get($module, $uid = NULL, $name = NULL) { elseif (isset($uid)) { $return = array(); foreach ($result as $record) { - $return[$record['name']] = ($record['serialized'] ? unserialize($record['value']) : $record['value']); + $return[$record->name] = ($record->serialized ? unserialize($record->value) : $record->value); } return $return; } - // If $module and $name was passed, return the values keyed by uid. + // If $module and $name was passed, return the uid/value pairs. elseif (isset($name)) { - foreach ($result as $_uid => $record) { - $result[$_uid] = ($record['serialized'] ? unserialize($record['value']) : $record['value']); + $return = array(); + foreach ($result as $record) { + $return[$record->uid] = ($record->serialized ? unserialize($record->value) : $record->value); } - return $result; + return $return; } // If only $module was passed, return data keyed by uid and name. else { $return = array(); - foreach ($result as $_uid => $record) { - $return[$_uid][$record['name']] = ($record['serialized'] ? unserialize($record['value']) : $record['value']); + foreach ($result as $record) { + $return[$record->uid][$record->name] = ($record->serialized ? unserialize($record->value) : $record->value); } return $return; } diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc index 8ad0cdd..08031c1 100644 --- a/core/modules/user/user.pages.inc +++ b/core/modules/user/user.pages.inc @@ -389,14 +389,14 @@ function user_cancel_confirm($account, $timestamp = 0, $hashed_pass = '') { $current = REQUEST_TIME; // Basic validation of arguments. - $account_data = user_data_get('user', $account->uid); + $account_data = user_data_get('user', $account->id()); if (isset($account_data['cancel_method']) && !empty($timestamp) && !empty($hashed_pass)) { // Validate expiration and hashed password/login. if ($timestamp <= $current && $current - $timestamp < $timeout && $account->uid && $timestamp >= $account->login && $hashed_pass == user_pass_rehash($account->pass, $timestamp, $account->login)) { $edit = array( 'user_cancel_notify' => isset($account_data['cancel_notify']) ? $account_data['cancel_notify'] : config('user.settings')->get('notify.status_canceled'), ); - user_cancel($edit, $account->uid, $account_data['cancel_method']); + user_cancel($edit, $account->id(), $account_data['cancel_method']); // Since user_cancel() is not invoked via Form API, batch processing needs // to be invoked manually and should redirect to the front page after // completion.