Problem/Motivation

After including simple_oauth, phpunit tests started giving this warning:
Passing a third argument to "Symfony\Component\HttpFoundation\HeaderBag::get()" is deprecated since Symfony 4.4, use method "all()" instead

The only instance where a third parameter is passed is in this method, which is invoked on all requests as part of the simple_oauth Authentication Provider:

  /**
   * {@inheritdoc}
   */
  public function isOauth2Request(Request $request) {
    // Check the header. See: http://tools.ietf.org/html/rfc6750#section-2.1
    // We have to perform also an exact match, as if no token is provided then
    // the LWS might be stripped, but we still have to detect this as OAuth2
    // authentication. See: https://www.ietf.org/rfc/rfc2616.txt
    $auth_header = trim($request->headers->get('Authorization', '', TRUE));
    return (strpos($auth_header, 'Bearer ') !== FALSE) || ($auth_header === 'Bearer');
  }

Steps to reproduce

It looks like this would be a problem in both the 4.x and 5.x branches installed in Drupal 9 with Symfony HTTP Foundation ^4.4

Example of the failing test: https://github.com/paul121/farmOS/runs/1199433286?check_suite_focus=true...

farmOS phpunit config (inherits from Drupal config): https://github.com/farmOS/farmOS/blob/2.x/docker/dev/Dockerfile#L57

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

paul121 created an issue. See original summary.

paul121’s picture

paul121’s picture

Title: Passing a third argument to header->get() is deprecated » Passing a third argument to $request->headers->get() is deprecated
paul121’s picture

Status: Active » Needs review
bradjones1’s picture

Status: Needs review » Fixed

Fixed this in the course of getting CI set back up. https://git.drupalcode.org/project/simple_oauth/-/commit/c992eb8bcc7c14d...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.