commit b0314d76a4ebf152962c206db6e2b4d17f735a23 Author: Joel Pittet Date: Fri Oct 4 15:58:48 2013 -0700 12 diff --git a/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php b/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php index c44e1f6..ddd4176 100644 --- a/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php +++ b/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php @@ -126,7 +126,7 @@ public function checkAccess(NodeInterface $node, $op = 'view', AccountInterface } if (!isset($account)) { - $account = $GLOBALS['user']; + $account = \Drupal::currentUser(); } // If no language code was provided, default to the node revision's langcode. diff --git a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php index 3d94f52..d045ecc 100644 --- a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php +++ b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php @@ -95,7 +95,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))); } @@ -119,7 +119,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 a787175..d6f3b05 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -46,8 +46,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 { @@ -375,8 +374,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/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 eb05061..e6e8093 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -590,8 +590,7 @@ function node_show(EntityInterface $node, $message = FALSE) { } // Update the history table, stating that this user viewed this node. - global $user; - if (\Drupal::moduleHandler()->moduleExists('history') && $user->isAuthenticated()) { + if (\Drupal::moduleHandler()->moduleExists('history') && \Drupal::currentUser()->isAuthenticated()) { $page['#attached'] = array( 'js' => array( // When the window's "load" event is triggered, mark the node as read. @@ -1149,7 +1148,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') diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index 8518383..9783ed8 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -86,7 +86,7 @@ function theme_node_add_list($variables) { * @deprecated Use \Drupal\node\Controller\NodeController::add() */ function node_add($node_type) { - global $user; + $user = \Drupal::currentUser(); $type = $node_type->type; $langcode = module_invoke('language', 'get_default_langcode', 'node', $type);