Skip to content
Snippets Groups Projects

[#3513856]: Make UserSession::name protected

2 unresolved threads

Closes #3513856

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
215 */
216 public function __get($name): mixed {
217 if ($name === 'name') {
218 @trigger_error("Getting the name property is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use \Drupal\Core\Session\UserSession::getAccountName() instead. See https://www.drupal.org/node/3513856", E_USER_DEPRECATED);
219 return $this->getAccountName();
220 }
221 return $this->$name ?? NULL;
222 }
223
224 /**
225 * Implements magic __isset() method.
226 */
227 public function __isset($name): bool {
228 if ($name === 'name') {
229 @trigger_error("Checking for the name property is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use \Drupal\Core\Session\UserSession::getAccountName() instead. See https://www.drupal.org/node/3513856", E_USER_DEPRECATED);
230 return $this->getAccountName();
  • danielveza added 1 commit

    added 1 commit

    • 56763021 - Fix incorrect return on __isset

    Compare with previous version

  • 83 84
    85 /**
    86 * Tests the name property deprecation.
    87 *
    88 * @covers ::__get
    89 * @covers ::__isset
    90 */
    91 #[IgnoreDeprecations]
    92 public function testNamePropertyDeprecation(): void {
    93 $user = new UserSession([
    94 'name' => 'test',
    95 ]);
    96 $this->expectDeprecation('Getting the name property is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use \Drupal\Core\Session\UserSession::getAccountName() instead. See https://www.drupal.org/node/3513856');
    97 self::assertEquals($user->name, $user->getAccountName());
    98 $this->expectDeprecation('Checking for the name property is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Use \Drupal\Core\Session\UserSession::getAccountName() instead. See https://www.drupal.org/node/3513856');
    99 $this->assertTrue(isset($user->name));
  • danielveza added 1 commit

    added 1 commit

    • 3167a009 - Replace ::assertTrue instances with static calls

    Compare with previous version

  • Please register or sign in to reply
    Loading