diff --git a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php index c847004..09ad79c 100644 --- a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php +++ b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php @@ -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.')); diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php index 659777a..48a501c 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -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 { @@ -377,8 +376,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; diff --git a/core/modules/node/lib/Drupal/node/Plugin/Action/DeleteNode.php b/core/modules/node/lib/Drupal/node/Plugin/Action/DeleteNode.php index 9b839d0..47a45f9 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Action/DeleteNode.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Action/DeleteNode.php @@ -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); } /** diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php index 4d62136..6a6bce7 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php @@ -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()); diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc index 03387f8..35bd9ea 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -206,7 +206,7 @@ function node_admin_nodes() { // 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' => 0))->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' => 0))->fetchCol()) { $query->condition(db_or() ->condition('n.status', 1) ->condition('n.nid', $own_unpublished, 'IN') diff --git a/core/modules/node/node.module b/core/modules/node/node.module index a860f3f..3be302b 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -276,10 +276,9 @@ 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])) { @@ -1070,7 +1069,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') @@ -1651,7 +1650,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. @@ -1685,9 +1684,8 @@ 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(). @@ -1713,7 +1711,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