Skip to content

Commit 2826945

Browse files
committed
Filter non-scalar env values to prevent PHP 8.2 proc_open warnings (#39)
1 parent 5e7ede3 commit 2826945

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Crypt/GPG/Engine.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,9 @@ private function _openSubprocess()
14521452
$rb = (version_compare(PHP_VERSION, '5.2.6') < 0) ? 'r' : 'rb';
14531453
$wb = (version_compare(PHP_VERSION, '5.2.6') < 0) ? 'w' : 'wb';
14541454

1455-
$env = $_ENV;
1455+
// Get environment variables. Exclude non-scalar values to prevent from a warning in proc_open().
1456+
// Possibly related to https://bugs.php.net/bug.php?id=75712, which was fixed in PHP 8.2.17.
1457+
$env = array_filter($_ENV, 'is_scalar');
14561458

14571459
// Newer versions of GnuPG return localized results. Crypt_GPG only
14581460
// works with English, so set the locale to 'C' for the subprocess.
@@ -1546,9 +1548,11 @@ private function _openSubprocess()
15461548
}
15471549
}
15481550

1549-
$this->_debug('GPG-AGENT-INFO: ' . $this->_agentInfo);
1551+
if (is_string($this->_agentInfo)) {
1552+
$this->_debug('GPG-AGENT-INFO: ' . $this->_agentInfo);
15501553

1551-
$env['GPG_AGENT_INFO'] = $this->_agentInfo;
1554+
$env['GPG_AGENT_INFO'] = $this->_agentInfo;
1555+
}
15521556

15531557
// gpg-agent daemon is started, we can close the launching process
15541558
$this->_closeAgentLaunchProcess();

0 commit comments

Comments
 (0)