Better solutions for MEMORY issues regarding #331

This commit is contained in:
the-djmaze 2022-04-21 10:29:56 +02:00
parent fd28741cb8
commit c682e49090
2 changed files with 9 additions and 5 deletions

View file

@ -38,8 +38,12 @@ class TempFile
*/
public static function CreateStream(string $sHash, string &$sFileName = '')
{
$sFileName = self::STREAM_NAME.'://'.$sHash;
return fopen($sFileName, 'r+b');
return \fopen(self::STREAM_NAME.'://'.$sHash, 'r+b');
}
public function stream_cast(int $cast_as) /*: resource*/
{
return $this->rStream;
}
public function stream_open(string $sPath) : bool
@ -61,7 +65,7 @@ class TempFile
}
else
{
$this->rSream = \fopen('php://memory', 'r+b');
$this->rSream = \fopen('php://temp', 'r+b');
self::$aStreams[$sHashName] = $this->rSream;
$bResult = true;

View file

@ -1288,7 +1288,7 @@ trait Messages
if ($sFingerprint) {
$GPG = $this->GnuPG();
$oBody = $oMessage->GetRootPart();
$fp = \fopen('php://memory', 'r+b');
$fp = \fopen('php://temp', 'r+b');
$resource = $oBody->ToStream();
$oBody->Body = null;
$oBody->SubParts->Clear();
@ -1326,7 +1326,7 @@ trait Messages
if ($aFingerprints) {
$GPG = $this->GnuPG();
$oBody = $oMessage->GetRootPart();
$fp = \fopen('php://memory', 'r+b');
$fp = \fopen('php://temp', 'r+b');
$resource = $oBody->ToStream();
\stream_copy_to_stream($resource, $fp);
foreach ($aFingerprints as $sFingerprint) {