Skip to content

Commit 78eb5f9

Browse files
committed
Make decryption return a value.
1 parent 2dc3e1b commit 78eb5f9

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/EncryptionBehavior.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ protected function modifyGetterWithDecryption(&$script, $columnPhpName) {
127127
protected function decryptVariable($variableName) {
128128
return <<<EOT
129129
// Decrypt the variable, per \UWDOEM\Encryption\EncryptionBehavior.
130-
$variableName = \UWDOEM\Encryption\Cipher::getInstance()->decryptStream($variableName);
130+
\$fieldValue = $variableName;
131+
if (is_resource(\$fieldValue) && get_resource_type(\$fieldValue) === "stream") {
132+
\$fieldValue = \UWDOEM\Encryption\Cipher::getInstance()->decryptStream(\$fieldValue);
133+
}
134+
return \$fieldValue;
131135
EOT;
132136
}
133137

tests/BehaviorTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ public function setVarBinaryColumn1($v)
2828
public function getVarBinaryColumn1()
2929
{
3030
// Decrypt the variable, per \UWDOEM\Encryption\EncryptionBehavior.
31-
$this->test_column = \UWDOEM\Encryption\Cipher::getInstance()->decryptStream($this->test_column);
31+
$fieldValue = $this->test_column;
32+
if (is_resource($fieldValue) && get_resource_type($fieldValue) === "stream") {
33+
$fieldValue = \UWDOEM\Encryption\Cipher::getInstance()->decryptStream($fieldValue);
34+
}
35+
return $fieldValue;
3236
}
3337
3438
public function setVarBinaryColumn1($v)

0 commit comments

Comments
 (0)