We need to replace the REQUEST_TIME which is deprecated with the core service.

Comments

nkoporec created an issue. See original summary.

nkoporec’s picture

Assigned: nkoporec » Unassigned
Status: Active » Needs review
StatusFileSize
new2.72 KB
lomasr’s picture

StatusFileSize
new153.45 KB

Applied the patch to worked cleanly for me. After applying the patch, I enabled the module no error showed up.

lomasr’s picture

Status: Needs review » Reviewed & tested by the community
ajits’s picture

Status: Reviewed & tested by the community » Needs work

Thank you for reporting and the patch! There are some issues around dependency injection which needs to be addressed. Adding below:

  1. +++ b/src/AutologoutManager.php
    @@ -120,7 +120,7 @@ class AutologoutManager implements AutologoutManagerInterface {
    +    $time_passed = isset($_SESSION['autologout_last']) ? \Drupal::time()->getRequestTime() - $_SESSION['autologout_last'] : 0;
    

    Use of \Drupal:: should be avoided in places where the dependencies could be injected.

  2. +++ b/src/Controller/AutologoutController.php
    @@ -53,7 +53,7 @@ class AutologoutController extends ControllerBase {
    +    $_SESSION['autologout_last'] = \Drupal::time()->getRequestTime();;
    

    Should be injected here as well.

  3. +++ b/src/EventSubscriber/AutologoutSubscriber.php
    @@ -51,7 +51,7 @@ class AutologoutSubscriber implements EventSubscriberInterface {
    +    $now = \Drupal::time()->getRequestTime();
    

    And here.

ajits’s picture

Adding related issue for reference.

i-trokhanenko’s picture

Status: Needs work » Needs review
StatusFileSize
new6.83 KB

Used dependency injection. Please review!

bcizej’s picture

Status: Needs review » Reviewed & tested by the community

Tested, works fine thanks.

bcizej’s picture

Status: Reviewed & tested by the community » Closed (duplicate)
Related issues: +#3087011: Drupal 9 Deprecated Code Report for Automated Logout module

Solved in a ticket for D9.