Problem/Motivation

SitePrivateKeyFileKeyProviderDecorator::getKeyValue() calls dirname($this->fileSystem->realpath($path)). realpath() returns FALSE when the private key file is missing, so dirname(false) throws a TypeError on PHP 8. Any page running easy_encryption_requirements() (e.g. /admin/config) then fatals.

TypeError: dirname(): Argument #1 ($path) must be of type string, false given (line 67 of SitePrivateKeyFileKeyProviderDecorator.php)

A second TypeError follows: parent::getKeyValue() can return NULL against the : string return type.

Steps to reproduce

  1. Have an easy_encrypted key whose private key file is missing on this environment.
  2. Visit /admin/config.
  3. WSOD / TypeError.

Not a duplicate of #3575553

#3575553 (fixed, 1.0.0-rc6, in 1.0.3) fixed key generation: writePrivateKeyToFile() now creates the directory. This is the read path — getKeyValue() still calls dirname(realpath()) unguarded in 1.0.3.

Proposed resolution

Guard realpath() !== FALSE before dirname(), and return ?? '' from the parent delegations. MR to follow.

AI usage

AI-Generated: Yes (Used Claude Code to draft the issue summary and the proposed fix; reviewed and verified by the contributor.)

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rajab natshah created an issue. See original summary.

rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

rajab natshah’s picture

Issue summary: View changes

rajab natshah’s picture

Status: Active » Needs review
rajab natshah’s picture

Issue summary: View changes

mxr576 made their first commit to this issue’s fork.

mxr576’s picture

  • mxr576 committed 745c75e6 on 1.0.x authored by rajab natshah
    fix: #3605529 getKeyValue() fatals with TypeError when the private key...
mxr576’s picture

Status: Needs review » Fixed

Thanks for finding this and also providing a fix. I have made minor optimizations on the code before I merged it, please double check if 1.0.x-dev has the proper fix.

I'll release a tagged version later this week.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

mxr576’s picture

Everything looks okay with the merged change? I assume it does so a tagged release could go out today.

Status: Fixed » Closed (fixed)

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