Forum


Replies: 1   Views: 2437
Replacevariablebytext generates fatal php error on one specific file
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by rstoeber  · 06-03-2018 - 01:38

We have been using phpdox successfully for about a year now with no problem. Our application allows users to upload .docx files containing variables/tags that get replaced with actual data from a database. Our users and testers have created the original .docx files using Google Docs, LibreOfiice, and various versions of Microsoft Word. Nobody ever had a problem until now.

Today we got a .docx file that will generate the error shown below. I personally use LibreOffice so I immediately opened the file using LibreOffice on my MacBook and started looking for typos or any strange formatting. I didn't see anything odd so I simply saved the file without making any changes. The new file worked perfectly.

I tested this three times now with the same result. The original file generates the error below. Opening the file in LibreOffice and not touching anything before saving it makes a file that works properly.

The phpdocx code isn't very complicated. All we do is this:

$docx->replaceVariableByText($accountvars);

$docx->replaceVariableByText($jobvars);

$docx->replaceTableVariable($lineitems);

$docx->createDocx($name);

Can anyone tell us what the error message below really means? Any idea what could be wrong with the original file? We hope to find a way to identify the "bad" file and give the user a graceful error message.

 

[Mon Mar 05 16:59:20.740583 2018] [:error] [pid 15847] [client 73.131.235.228:56919] PHP Fatal error:  Uncaught Error: Call to a member function getElementsByTagName() on boolean in /var/www/wgaccounts/phpdocx/classes/AutoLoader.inc(62) : eval()'d code:91\nStack trace:\n#0 /var/www/wgaccounts/phpdocx/classes/CreateDocx.inc(2830): CreateProperties->CreateProperties(Array, false)\n#1 /var/www/wgaccounts/phpdocx/classes/CreateDocx.inc(3530) : eval()'d code(64): CreateDocx->addProperties(Array)\n#2 /var/www/wgaccounts/phpdocx/classes/CreateDocx.inc(3530): eval()\n#3 /var/www/wgaccounts/generate-estimate-doc.html(370): CreateDocx->createDocx('/mnt/WGstorage1...')\n#4 {main}\n  thrown in /var/www/wgaccounts/phpdocx/classes/AutoLoader.inc(62) : eval()'d code on line 91,