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

View file

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