Remove calls to deprecated global $user in module as part of the meta #2047951: [META] Remove calls to deprecated global $user and $GLOBALS['user']
Let's expand the scope of this issue to convert all the trivial references outside bootstrap and session handling, and then work on those tougher issues separately.
Before RTBCing a patch for this issue, confirm that no more references to the global remain outside #2061953: Remove calls to deprecated global $user in core/lib/Drupal/Core/Authentication/AuthenticationManager.php , #2062771: #2062771: Remove calls to deprecated global $user in \Drupal\Core\Session\SessionManager, #2062069: Remove calls to deprecated global $user in core/includes/bootstrap.inc . Edit: Fixing TestBase and its child base classes might also merit a separate issue, but uses in normal test classes themselves should be (edit) either in this patch or in that patch, depending on which makes more sense. But not separately.
Comment | File | Size | Author |
---|---|---|---|
#87 | interdiff-2163203.txt | 988 bytes | longwave |
#87 | 2163203-global-user-87.patch | 22.11 KB | longwave |
#39 | global-user-bootstrap.patch | 1.67 KB | joelpittet |
#39 | global-user-common.patch | 875 bytes | joelpittet |
#39 | global-user-session.patch | 4.84 KB | joelpittet |
Comments
Comment #1
joelpittetComment #2
joelpittetComment #3
joelpittettestbot activate?
Comment #4
joelpittetComment #5
xjmThanks for your work on this! See #2047951-40: [META] Remove calls to deprecated global $user and $GLOBALS['user']. Let's expand the scope of this issue to convert all the trivial references outside bootstrap and session handling, and then work on those tougher issues separately.
Before RTBCing a patch for this issue, confirm that no more references to the global remain outside #2061953: Remove calls to deprecated global $user in core/lib/Drupal/Core/Authentication/AuthenticationManager.php , #2062771: #2062771: Remove calls to deprecated global $user in \Drupal\Core\Session\SessionManager, #2062069: Remove calls to deprecated global $user in core/includes/bootstrap.inc . Edit: Fixing TestBase and its child base classes might also merit a separate issue, but uses in normal test classes themselves should be (edit) either in this patch or in that patch, depending on which makes more sense. But not separately.
Comment #6
plachThe attached patch above is a duplicate of #2078057: Remove references to global $user in Content Translation module so moving back to active.
Comment #7
joelpittet@xjm I'm not to sure on the approach to do them all at once. I know what you are trying to do but these are deceivingly tricky.
A lot of tests don't work upon conversion and doesn't seem to be an API for setting the current_user.
But here's an attempt to see what testbot says.
Didn't convert them where they needed current_user set and some tests.
Didn't convert session.inc, bootstrap.inc, AuthenticationManager, AuthenticationEnhancer, TestBase, WebTestBase, user module and a few tests.
Comment #9
xjm@joelpittet Yep, it'll take a bit more work in this issue, but overall it will be less overhead. Also, if we try to remove all the "easier" stuff here, we'll do a better job of surfacing specific bugs or API insufficiencies that can be spun off as separate issues about a specific topic rather than a specific file.
Comment #10
joelpittet@xjm ok, just wanted to make sure you're looped in to what's happening. Here is the same patch split in half to try to narrow down what is causing the failed install.
Comment #12
joelpittetpart 2 split in 2.
Comment #15
joelpittetOk think it's entity controller
Comment #18
joelpittetguessed wrong i guess
Comment #21
joelpittetok both
Comment #23
joelpittethmm needs narrowing further
Comment #25
joelpittetcookie!
Comment #28
joelpittetcookie and entityaccesscontroller removed...
Comment #30
joelpittetFine, all of patch https://drupal.org/files/issues/2163203-7-global-user-part2-2-2.patch removed.
Comment #33
joelpittethmm must have buggered that patch.
Comment #34
joelpittetOk this should get rid of the password reset errors.
Comment #36
joelpittetOk green! That leaves the following out:
global $user:
$GLOBALS['user']
Most of which are needing a way to set the current user(which may need a container?).
Comment #37
joelpittetPushing the envelope a bit, a few more added from user.module that I think can be safely added.
Comment #38
joelpittetComment #39
joelpittetOk here's a patch for each of rest split by file. I made up a wild guess on how to set the current user...
\Drupal::getContainer()->set('current_user', drupal_anonymous_user());
This is an attempt to weed out any other low hanging fruit from the rest of them.
Comment #60
joelpittetDid a little test and seems to show promise for this way of setting the user in tests at least:
Debug tests:
Results:
Comment #61
joelpittetRolled in some of the ones I think are safe.
Comment #62
joelpittetThese are the remaining files that didn't get patched (see remaining.txt) for interdiff between #38 and #61:
Comment #63
joelpittetRe-roll.
Comment #64
webchickThis is going to break everything everywhere, so tagging and will try to fit this in the week after beta.
Comment #65
valthebaldcontent_translation module does not contain any mention neither of 'global $user', nor $GLOBALS['user']. Wrong title?
Comment #66
joelpittet@valthebald the title isn't wrong, @xjm repurposed this issue in #6 Just needs a new issue summary too.
Comment #67
joelpittetComment #68
joelpittetRe-rolled.
Comment #69
joelpittetComment #70
joelpittetRe-roll
Comment #72
aspilicious CreditAttribution: aspilicious commentedComment #73
alexpott2163203-global-user-69_0.patch no longer applies.
Comment #74
xjmgrr.
Comment #75
xjmComment #76
joelpittetback to rtbc with re-roll.
Comment #77
alexpott2163203-global-user-76.patch no longer applies.
Comment #78
joelpittet@alexpott let me know if you want another re-roll and when you plan to commit this, if ever. I'll work on other things in the meanwhile. Ping me on IRC.
Comment #79
saki007sterComment #80
saki007sterre-rolled
Comment #81
saki007sterComment #82
saki007sterComment #83
ianthomas_uk#2107533: Remove {menu_router} removes the user_is_* functions.
Comment #84
ianthomas_uk#2107533: Remove {menu_router} has been committed so this will need a reroll.
Comment #85
longwaveRerolled.
Comment #86
ianthomas_ukThis is a good reroll of #76 (which was RTBC), except:
global $conf has been removed from HEAD
again
There is still global $user in:
\Drupal\Core\Form\FormBuilder
\Drupal\system\Tests\Common
\Drupal\system\Tests\Datetime
\Drupal\system\Tests\Entity
\Drupal\user\Tests\Views
And $GLOBALS['user'] in:
\Drupal\Core\Cron
\Drupal\history\Tests\Views
Some of these may warrant their own issues or be classsed as bootstrap/authentication.
Comment #87
longwaveFixed points in #86.
The remaining globals were tested separately in #39, not sure it's worth trying to remove more in this patch or in a followup, if there will be some left over anyway.
Comment #88
ianthomas_ukOK, let's leave those for now and check again once bootstrap and authentication have been done. The reroll is good.
Comment #89
alexpottCommitted 7abce70 and pushed to 8.x. Thanks!
Comment #90
joelpittetSo happy to see this one getting in! Going to open another for the remaining from #62 and others that have sneaked in since.