Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
2d1adba4
Commit
2d1adba4
authored
Dec 10, 2013
by
webchick
Browse files
Issue
#2061899
by joelpittet, m1r1k: Remove references to global in Comment module.
parent
8c59a993
Changes
4
Hide whitespace changes
Inline
Side-by-side
core/modules/comment/comment.module
View file @
2d1adba4
...
...
@@ -1276,7 +1276,6 @@ function comment_get_display_page($cid, $instance) {
* @param \Drupal\comment\CommentInterface $comment
*/
function
comment_preview
(
CommentInterface
$comment
,
array
&
$form_state
)
{
global
$user
;
$preview_build
=
array
();
$entity
=
entity_load
(
$comment
->
entity_type
->
value
,
$comment
->
entity_id
->
value
);
...
...
@@ -1285,8 +1284,8 @@ function comment_preview(CommentInterface $comment, array &$form_state) {
if
(
!
empty
(
$comment
->
name
->
value
))
{
$account
=
user_load_by_name
(
$comment
->
name
->
value
);
}
elseif
(
$u
ser
->
isAuthenticated
()
&&
empty
(
$comment
->
is_anonymous
))
{
$account
=
$u
ser
;
elseif
(
\
Drupal
::
currentU
ser
()
->
isAuthenticated
()
&&
empty
(
$comment
->
is_anonymous
))
{
$account
=
\
Drupal
::
currentU
ser
()
;
}
if
(
!
empty
(
$account
)
&&
$account
->
isAuthenticated
())
{
...
...
@@ -1514,13 +1513,12 @@ function template_preprocess_comment(&$variables) {
function
theme_comment_post_forbidden
(
$variables
)
{
$entity
=
$variables
[
'commented_entity'
];
$field_name
=
$variables
[
'field_name'
];
global
$user
;
// Since this is expensive to compute, we cache it so that a page with many
// comments only has to query the database once for all the links.
$authenticated_post_comments
=
&
drupal_static
(
__FUNCTION__
,
NULL
);
if
(
$u
ser
->
isAnonymous
())
{
if
(
\
Drupal
::
currentU
ser
()
->
isAnonymous
())
{
if
(
!
isset
(
$authenticated_post_comments
))
{
// We only output a link if we are certain that users will get permission
// to post comments by logging in.
...
...
core/modules/comment/lib/Drupal/comment/Entity/Comment.php
View file @
2d1adba4
...
...
@@ -218,10 +218,8 @@ public function id() {
public
function
preSave
(
EntityStorageControllerInterface
$storage_controller
)
{
parent
::
preSave
(
$storage_controller
);
$user
=
\
Drupal
::
currentUser
();
if
(
!
isset
(
$this
->
status
->
value
))
{
$this
->
status
->
value
=
$u
ser
->
hasPermission
(
'skip comment approval'
)
?
COMMENT_PUBLISHED
:
COMMENT_NOT_PUBLISHED
;
$this
->
status
->
value
=
\
Drupal
::
currentU
ser
()
->
hasPermission
(
'skip comment approval'
)
?
COMMENT_PUBLISHED
:
COMMENT_NOT_PUBLISHED
;
}
if
(
$this
->
isNew
())
{
// Add the comment to database. This next section builds the thread field.
...
...
@@ -290,8 +288,8 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
}
// We test the value with '===' because we need to modify anonymous
// users as well.
if
(
$this
->
uid
->
target_id
===
$u
ser
->
id
()
&&
$u
ser
->
isAuthenticated
())
{
$this
->
name
->
value
=
$u
ser
->
getUsername
();
if
(
$this
->
uid
->
target_id
===
\
Drupal
::
currentU
ser
()
->
id
()
&&
\
Drupal
::
currentU
ser
()
->
isAuthenticated
())
{
$this
->
name
->
value
=
\
Drupal
::
currentU
ser
()
->
getUsername
();
}
// Add the values which aren't passed into the function.
$this
->
thread
->
value
=
$thread
;
...
...
core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php
View file @
2d1adba4
...
...
@@ -100,7 +100,7 @@ public function query() {
}
public
function
preRender
(
&
$values
)
{
global
$u
ser
;
$user
=
\
Drupal
::
currentU
ser
()
;
if
(
$user
->
isAnonymous
()
||
empty
(
$values
))
{
return
;
}
...
...
core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php
View file @
2d1adba4
...
...
@@ -237,7 +237,7 @@ public function entityFormAlter(array &$form, array &$form_state, EntityInterfac
// Default to the anonymous user.
$name
=
''
;
if
(
$new_translation
)
{
$name
=
$GLOBALS
[
'u
ser
'
]
->
getUsername
();
$name
=
\
Drupal
::
currentU
ser
()
->
getUsername
();
}
elseif
(
$entity
->
translation
[
$form_langcode
][
'uid'
])
{
$name
=
user_load
(
$entity
->
translation
[
$form_langcode
][
'uid'
])
->
getUsername
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment