Hi dear all!
It's been 3 month since I'm using MODx Revo 2, and my project is really near it's launch. I was tweaking all small details and suddenly came accross a problem, which I did not expect (or even think of, actually). The problem is - Low memory error in mod.parser class.
Here's the description:
There's an external service that produces files (.pdf), to which I make a soap-call from a snippet. I have to do it from modx environment, sinse I use some user-fields to make a soap-call.
After I got the file, I need to return it to the user as a downloadable file (usually about 1.5Mb).
Here's the snippet:
<?php
$invoice_no = 'Invoice';
if (isset($invoiceid)) $invoice_id = $invoiceid; else
$invoice_id = $_REQUEST['id'];
$client = new SoapClient("someservice/?wsdl", array("trace"=>true));
try {
$fd = $client->GetInvoicePdf(array(id => $invoice_id));
$invoicepdf = $fd->GetInvoicePdfResult;
}
catch (SoapFault $soapFault) {
var_dump($soapFault);
echo "Request :
", htmlentities($client->__getLastRequest()), "
";
echo "Response :
", htmlentities($client->__getLastResponse()), "
";
}
header("Content-Disposition: atachment; filename=invoice_".$invoice_no.".txt");
header("Content-Type: application/octet-stream");
header("Content-Length: ".strlen($invoicepdf));
header("Pragma: no-cache");
header("Expires: 0");/**/
print($invoicepdf);
Everything goes alright until I try to return the .pdf (by print()) I got as a resource - I immediately get an error in
modparser.class.php on line 150:
$matches[$matchCount][1]= substr($content, ($openPos +strlen($prefix)), $innerTagLength);
Any ideas why it's happening? Maybe there's a 'right' approach to this kind of tasks?
I'll greatly appreciate your help, thanks!
PS: there's no problems in the soap-call, it's working alright. The same exact code, on the same server run outside of modx environment works perfectly and returns the requested pdf.
[ed. note: afterdark last edited this post 14 years, 5 months ago.]