Bug #15898 [Opn->Bgs]: MARC_Record toRaw()

From: Date: Fri, 13 Feb 2009 20:49:35 +0000
Subject: Bug #15898 [Opn->Bgs]: MARC_Record toRaw()
References: 1  Groups: php.pear.bugs 
Request: Send a blank email to pear-bugs+get-15@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=15898&edit=1 ID: 15898 Updated by: mschraeder@btsb.com Reported By: mschraeder at btsb dot com Summary: MARC_Record toRaw() -Status: Open +Status: Bogus Type: Bug Package: File_MARC Operating System: Ubuntu PHP Version: 5.2.4 Roadmap Versions: New Comment: <div id="changeset"> <span class="removed">-Status: Open</span> <span class="added">+Status: Bogus</span> </div> Welp. Turns out I'm an idiot and it was a bug in my own code afterall. Previous Comments: ------------------------------------------------------------------------ [2009-02-13 19:46:13] frozensolid Upon further testing, var_dump simply does not do anything, but it does not throw the error. I must not have refreshed my log before attempting to var_dump. ------------------------------------------------------------------------ [2009-02-13 18:06:30] frozensolid Description: ------------ I'm writing a script to allow a customer to customize their MARC records before downloading them. For almost all cases it seems to work fine, but in certain cases the toRaw() function goes into an infinite loop or causes a major memory leak causing a fatal error in the script. I've also tried simply var_dumping the MARC record variable, which also causes the crash. Test script: --------------- include_once('File/MARC.php'); $_POST['strTag0'] = '895'; $_POST['strSubfield0'] = 'a'; $_POST['strContents0'] = 'Some Dude'; $_POST['strTag1'] = ''; $_POST['strSubfield1'] = 'b'; $_POST['strContents1'] = 'Some Chick'; $_POST['strTag2'] = '895'; $_POST['strSubfield2'] = 'c'; $_POST['strContents2'] = 'Your Mom'; $stringRecord = '00823pam 2200205 a 4500001002000000003000800020008004100028020002300069020002600092020002500118020002800143040002600171050002400197082001400221100002200235245011400257260003100371300002100402520019400423 04020364 120476 IlJaBTS050615s2005 nyu c 000 1 eng  a0375831436 (Trade) a9780375831430 (Trade) a0375931430 (lib. ed) a9780375931437 (lib. ed) aDLCcIlJaBTSdIlJaBTS00aPZ7.B51197bPe 200500a[Fic]2221 aBirdsall, Jeanne.14aThe Penderwicks :ba summer tale of four sisters, two rabbits, and a very interesting boy /cJeanne Birdsall. aNew York :bKnopf,cc2005. a262 p. ;c21 cm. aWhile vacationing with their widowed father in the Berkshire Mountains, four sisters, ages four through twelve, share adventures with a local boy, much to the dismay of his snobbish mother.'; $MARCfile = new File_MARC($stringRecord, File_MARC::SOURCE_STRING); $MARCrecord = $MARCfile->next(); $i = 0; while (isset($_POST['strTag'.($i)])) { $subfields[] = new File_MARC_Subfield($_POST['strSubfield'.$i], str_replace("''", "'", $_POST['strContents'.$i])); $newFieldTag = $_POST['strTag'.$i]; while (isset($_POST['strTag'.($i+1)]) && $_POST['strTag'.($i+1)] == '') { $i++; $subfields[] = new File_MARC_Subfield($_POST['strSubfield'.$i], str_replace("''", "'", $_POST['strContents'.$i])); } $newField = new File_MARC_Data_Field($newFieldTag, $subfields); $MARCrecord->appendField($newField); $i++; } echo $MARCrecord->toRaw(); Expected result: ---------------- The raw MARC record with 2 new "895" tags added, one of which has two sub fields. Actual result: -------------- [13-Feb-2009 12:04:41] PHP Fatal error: Allowed memory size of 786432000 bytes exhausted (tried to allocate 16 bytes) in /usr/share/php/File/MARC/Subfield.php on line 208 ------------------------------------------------------------------------ -- Edit this bug report at http://pear.php.net/bugs/bug.php?id=15898&edit=1

« previous php.pear.bugs (#15) next »