--- Begin Message ---
Package: php4
Version: 4:4.3.3-4
Severity: important
When trying to dump an array structure to a format suitable for
generating XML (there aren't any PHP modules for generating XML that I
could find, only for parsing XML), I found that php was crashing after I
had extended the array a bit.
I use array_walk() recursively, to a max depth of about 6.
Any self-respecting programming language should be able to handle that
:-) Below is a script that contains the core of what I was doing, and
that shows the crash. Note that that script is more suited to running
with the php4-cgi php4 executable (which also shows the problem).
I found some vague references that php4 doesn't support recursion,
however I can't find any evidence of this in the manual. If it indeed
doesn't support recursion, perhaps that should be told explicitly in the
array_walk() manual entry. The online annotated manual page actually has
plentiful user examples of recursion...
Paul Slootman
-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux wurtel 2.6.5-rc2 #1 Sat Mar 20 14:10:58 CET 2004 i686
Locale: LANG=C, LC_CTYPE=C
Versions of packages php4 depends on:
ii apache-common 1.3.29.0.1-3 Support files for all Apache webse
ii debconf 1.4.22 Debian configuration management sy
ii libbz2-1.0 1.0.2-1 A high-quality block-sorting file
ii libc6 2.3.2.ds1-11 GNU C Library: Shared libraries an
ii libdb4.1 4.1.25-10 Berkeley v4.1 Database Libraries [
ii libexpat1 1.95.6-6 XML parsing C library - runtime li
ii libmm13 1.3.0-1 Shared memory library - runtime
ii libpam0g 0.76-14.1 Pluggable Authentication Modules l
ii libpcre3 4.5-1.1 Perl 5 Compatible Regular Expressi
ii mime-support 3.23-1 MIME files 'mime.types' & 'mailcap
ii zlib1g 1:1.2.1-4 compression library - runtime
<?php
$order = array(
"DocID" => "1",
"DocDate" => date("d.m.y"),
"ReSubmissionDate" => "",
"DocTyp" => "Stapelauftrag",
"CustID" => "00000",
"CustomerAddress" => array(
array(
"Name1" => 'name1',
"Name2" => 'name2',
"Name3" => "",
"City" => 'city',
"Street" => 'street',
"Postal" => 'postcode',
"IATA" => "90",
"Country" => "Deutschland",
"ShortName" => 'short',
"ContactKey" => "",
"EMail" => '[EMAIL PROTECTED]',
)
),
"Text1" => "",
"Text2" => "",
"Wildcard1" => "",
"Wildcard2" => "",
"Dispatch" => "Paketdienst",
"Weight" => "0,0",
"BillingCustID" => "4300200000",
"ExtDocNr" => "00000000003",
"AnalysisLock" => "",
"PrintFlag" => "",
"FormType" => "0",
"Curr" => "EUR",
"ExChangeRate" => "1,0000",
"WIRRate" => "0",
"OneTimeCustomer" => array(
array(
"BankCode" => "",
"BankAccount" => ""
)
),
"Language" => "0",
"PriceGroup" => "1",
"PrFlag" => "0",
"SalesTaxKey" => "1",
"ProceedKey" => "0",
"CustDiscountGroup" => "0",
"Discount" => array(
array(
"FinDisc1" => "0,00",
"Disc1Base" => "145,72",
"Disc1Value" => "0,00",
"FinDisc2" => "0,00",
"Disc2Base" => "145,72",
"Disc2Value" => "0,00",
"FinDisc3" => "0,00",
"Disc3Base" => "145,72",
"Disc3Value" => "0,00",
"ValueSummary" => "0,00"
)
),
"Contact" => array(
array(
"Repr" => "999",
"Region" => "99",
"Commission" => "0,00",
"Agent" => "000000"
)
),
"Booking" => array(
array(
"CostUnit" => "0000000000",
"CostCentre" => "0000000000",
"AccountingArea"=> "01"
)
),
"InvoiceCycleKey" => "0",
"AnalysisKey" => "",
"OrderNumber" => "",
"OrderDate" => "",
"OrderCode" => "",
"DocItems" => array(
"DocItem" => array(
"PosType" => "1",
"ItemRef" => "ÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚ1002",
"CRef" => "",
"Desc1" => "Präsentation Niederlande per",
"Desc2" => "",
"ArticleGroup" => "102",
"PosTypeVersion" => "E",
"Delivery" => array(
array(
"DelWeek" => "",
"DelDay" => "",
"DelTime" => ""
)
),
"PricePu" => "145,72",
"PriceUnit" => "0",
"PriceCalculation" => "0",
"ItemVal" => "145,72",
"InputKey" => "0",
"AveragePurchasePrice" => "0",
"Tax" => array(
array(
"TaxCode" => "00",
"TaxBra" => "000",
"TaxBraAccess" => "0",
"TaxSumIndex" => "0"
)
),
"DiscountArticle" => array(
array(
"DiscPC" => "0,00",
"DiscKey" => "1"
)
),
"ProceedKeyArticle" => "01",
"ActionKey" => "00",
"ContactCommissionArticle"=> "0,00",
"QuantDependantPriceKey"=> "",
"Quant" => "1",
"QuantUnit" => "",
"Meas" => array(
array(
"Count" => "1",
"Length" => "0,000",
"Width" => "0,000",
"Height" => "0,000"
)
),
"DecimalPlace" => "0",
"MultiplierQuant" => "1,000000",
"DifferingQuantUnit" => "",
"DecimalPlaceConversion"=> "0",
"WeightArticle" => array(
array(
"Amount" => "0",
"Unit" => "0"
)
),
"Wreath" => "0,000",
"Stock" => "1",
"CostUnitArticle" => "",
"SerialNbKey" => "0",
"TextComplementKey" => "0",
"PartsListPrintKey" => "",
"Prod" => "0000000000"
)
),
"Payment" => array(
"PaymentKey" => "0",
"ReminderKey" => "00",
"PayTerms" => array(
array(
"PayTerm" => "1",
"PayDays" => "000",
"CashDiscDays1" => "000",
"CashDiscDays2" => "000",
"CashDiscPer1" => "0,00",
"CashDiscPer2" => "0,00"
),
array(
"PayTerm" => "2",
"PayDays" => "000",
"CashDiscDays1" => "000",
"CashDiscDays2" => "000",
"CashDiscPer1" => "0,00",
"CashDiscPer2" => "0,00"
)
)
),
"NetAmountByTurnOverTax" => array(
array(
"TurnOverTaxFree" => "145,72",
"TurnOverTax1" => "0,00",
"TurnOverTax2" => "0,00",
"TurnOverTax3" => "0,00",
"TurnOverTax4" => "0,00",
"TurnOverTax5" => "0,00",
"TurnOverTax6" => "0,00",
"TurnOverTax7" => "0,00",
"TurnOverTax8" => "0,00"
),
),
"GrossAmount" => "145,72",
"ProceedAmount" => "145,72",
"NetAmountByPayTerm2" => array(
array(
"Sum0" => "0,00",
"Sum1" => "0,00",
"Sum2" => "0,00",
"Sum3" => "0,00",
"Sum4" => "0,00",
"Sum5" => "0,00",
"Sum6" => "0,00",
"Sum7" => "0,00",
"Sum8" => "0,00"
),
),
"TaxCodes" => array(
array(
"TaxCode1" => "0",
"TaxCode2" => "0",
"TaxCode3" => "0",
"TaxCode4" => "0",
"TaxCode5" => "0",
"TaxCode6" => "0",
"TaxCode7" => "0",
"TaxCode8" => "0"
)
)
);
$docs = array(
array(
"Version" => "1.0",
"ProducerName" => "xxxxxxxx",
"ProductName" => "Classic Line",
"xmlns" =>
"x-schema:CL310_DezABFSchema.XML"
),
"Company" => array(
array(
"MandateNumber" => "111",
"MandateName" => "xxx xxxxxxx-xxxxx xxxxxxx",
"MandateCurr" => "EUR"
),
),
"Doc" => $order
);
dump2xml($docs);
function dump2xml($array) {
// output of this goes through 2xml
array_walk(&$array, "gen_xml", "/Docs/");
}
function gen_xml($val, $key, $prefix)
{
global $xml_fd;
print "gen_xml(prefix=$prefix)\n";
if (is_array($val)) {
if (preg_match('/^\d+$/', $key)) {
if ($key == 1) {
print substr($prefix, 0, $x-1) . "\n";
}
array_walk(&$val, "gen_xml", "$prefix@");
}
else {
array_walk(&$val, "gen_xml", "$prefix$key/");
}
}
else {
if (strlen($val) > 0)
print "$prefix$key=$val\n";
else
print "$prefix$key\n";
}
print "gen_xml(prefix=$prefix) end\n";
}
?>
--- End Message ---