Needed fix for Drupal 11

Created on 22 February 2025, about 2 months ago

Problem/Motivation

system_retrieve_file() has been removed in Drupal 11

Steps to reproduce

Try to create a key in D11

message: 'Error: Call to undefined function Drupal\key_jwks\Plugin\KeyProvider\system_retrieve_file() in Drupal\key_jwks\Plugin\KeyProvider\JwksKeyProvider->retrieveUncachedJwks() (line 378 of /web/lieb10/web/modules/custom/key_jwks/src/Plugin/KeyProvider/JwksKeyProvider.php).'

Proposed resolution

See https://www.drupal.org/node/3223362 β†’

Remaining tasks

I may attempt to fix this and submit a patch. Not promising anything though.

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States lieb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @lieb
  • πŸ‡ΊπŸ‡ΈUnited States lieb

    This seems to work

     protected function retrieveUncachedJwks(string $url) {
        $local_path = $this->generateLocalCachePath($url);
    
        $data = (string) \Drupal::httpClient()->get($url)->getBody();
        dpm($data);
        $file =  \Drupal::service('file.repository')->writeData($data, $local_path, FileSystemInterface::EXISTS_REPLACE);
    
        return $file->getFileUri();
    

    /** @noinspection PhpUnnecessaryLocalVariableInspection
    $saved_path =
    system_retrieve_file(
    $url,
    $local_path,
    FALSE,
    FileSystemInterface::EXISTS_REPLACE
    );

    return $saved_path;
    */

    }

Production build 0.71.5 2024