Commit 93c57498 authored by catch's avatar catch

Issue #2062791 by joelpittet, natemow, sergeypavlenko, m1r1k, jlindsey15:...

Issue #2062791 by joelpittet, natemow, sergeypavlenko, m1r1k, jlindsey15: Remove calls to deprecated global $user and $GLOBALS['user'] in node module.
parent 7fa9c2e1
......@@ -96,7 +96,7 @@ public function getConfirmText() {
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state) {
$this->nodes = $this->tempStoreFactory->get('node_multiple_delete_confirm')->get($GLOBALS['user']->id());
$this->nodes = $this->tempStoreFactory->get('node_multiple_delete_confirm')->get(\Drupal::currentUser()->id());
if (empty($this->nodes)) {
return new RedirectResponse(url('admin/content', array('absolute' => TRUE)));
}
......@@ -120,7 +120,7 @@ public function buildForm(array $form, array &$form_state) {
public function submitForm(array &$form, array &$form_state) {
if ($form_state['values']['confirm'] && !empty($this->nodes)) {
$this->storageController->delete($this->nodes);
$this->tempStoreFactory->get('node_multiple_delete_confirm')->delete($GLOBALS['user']->id());
$this->tempStoreFactory->get('node_multiple_delete_confirm')->delete(\Drupal::currentUser()->id());
$count = count($this->nodes);
watchdog('content', 'Deleted @count posts.', array('@count' => $count));
drupal_set_message(format_plural($count, 'Deleted 1 post.', 'Deleted @count posts.'));
......
......@@ -47,8 +47,7 @@ protected function prepareEntity() {
$node->$key = (int) in_array($key, $this->settings['options']);
}
}
global $user;
$node->setAuthorId($user->id());
$node->setAuthorId(\Drupal::currentUser()->id());
$node->setCreatedTime(REQUEST_TIME);
}
else {
......@@ -365,8 +364,7 @@ public function submit(array $form, array &$form_state) {
$node->setNewRevision();
// If a new revision is created, save the current user as revision author.
$node->setRevisionCreationTime(REQUEST_TIME);
global $user;
$node->setRevisionAuthorId($user->id());
$node->setRevisionAuthorId(\Drupal::currentUser()->id());
}
$node->validated = TRUE;
......
......@@ -62,7 +62,7 @@ public static function create(ContainerInterface $container, array $configuratio
* {@inheritdoc}
*/
public function executeMultiple(array $entities) {
$this->tempStore->set($GLOBALS['user']->id(), $entities);
$this->tempStore->set(\Drupal::currentUser()->id(), $entities);
}
/**
......
......@@ -166,7 +166,7 @@ function testNodeQueryAlterOverride() {
// Have node_test_node_grants return a node_access_all privilege,
// to grant the noAccessUser 'view' access. To verify that
// node_access_view_all_nodes is properly checking the specified
// $account instead of the global $user, we will log in as
// $account instead of the current user, we will log in as
// noAccessUser2.
$this->drupalLogin($this->noAccessUser2);
\Drupal::state()->set('node_access_test.no_access_uid', $this->noAccessUser->id());
......
......@@ -308,10 +308,10 @@ function node_title_list($result, $title = NULL) {
* One of the MARK constants.
*/
function node_mark($nid, $timestamp) {
global $user;
$cache = &drupal_static(__FUNCTION__, array());
if ($user->isAnonymous() || !\Drupal::moduleHandler()->moduleExists('history')) {
if (\Drupal::currentUser()->isAnonymous() || !\Drupal::moduleHandler()->moduleExists('history')) {
return MARK_READ;
}
if (!isset($cache[$nid])) {
......@@ -1112,7 +1112,7 @@ function node_get_recent($number = 10) {
// If the user is able to view their own unpublished nodes, allow them
// to see these in addition to published nodes. Check that they actually
// have some unpublished nodes to view before adding the condition.
if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT DISTINCT nid FROM {node_field_data} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->id(), ':status' => NODE_NOT_PUBLISHED))->fetchCol()) {
if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT DISTINCT nid FROM {node_field_data} WHERE uid = :uid AND status = :status', array(':uid' => \Drupal::currentUser()->id(), ':status' => NODE_NOT_PUBLISHED))->fetchCol()) {
$query->condition(db_or()
->condition('n.status', NODE_PUBLISHED)
->condition('n.nid', $own_unpublished, 'IN')
......@@ -1645,7 +1645,7 @@ function node_permissions_get_configured_types() {
function node_access_grants($op, $account = NULL) {
if (!isset($account)) {
$account = $GLOBALS['user'];
$account = \Drupal::currentUser();
}
// Fetch node access grants from other modules.
......@@ -1679,9 +1679,9 @@ function node_access_grants($op, $account = NULL) {
* @see node_query_node_access_alter()
*/
function node_access_view_all_nodes($account = NULL) {
global $user;
if (!$account) {
$account = $user;
$account = \Drupal::currentUser();
}
// Statically cache results in an array keyed by $account->id().
......@@ -1707,7 +1707,7 @@ function node_access_view_all_nodes($account = NULL) {
*
* This is the hook_query_alter() for queries tagged with 'node_access'. It adds
* node access checks for the user account given by the 'account' meta-data (or
* global $user if not provided), for an operation given by the 'op' meta-data
* current user if not provided), for an operation given by the 'op' meta-data
* (or 'view' if not provided; other possible values are 'update' and 'delete').
*
* Queries tagged with 'node_access' that are not against the {node} table
......
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