Forum How do I...?

false on success

lhalaa
Hi,

I'm having a weird status after generating a pdf. The log shows
Thu Oct 2 02:16:59 2008: ---- begin
Thu Oct 2 02:16:59 2008: finished: success
Thu Oct 2 02:16:59 2008: ---- end

and the pdf was successfully generated.

On prince.php, the comment says, 'Returns true if a PDF file was generated successfully' on convert_string_to_file. How come I get false on success?.. I have this checking on my code that when the return value of convert_string_to_file is true it will email the pdf as an attachment. What's wrong with my code? How come it returns false? Any thoughts?

Thanks,
Lhalaa
mikeday
If you look inside convert_internal_string_to_file, you will find that it is reading log messages from Prince and checking that the final status is successful:
$result = $this->readMessages($pipes[2], $msgs);
...
return ($result == 'success');

If it is returning false unexpectedly, perhaps you could try printing the value of the $result variable and seeing if something strange is being returned?
lhalaa
Hi, thanks for the quick reply. The value of the variable $result before "return ($result == 'success');" is an empty string. What should be the return value of $result before "return ($result == 'success');"?

THanks
mikeday
Well, ideally it should be equal to 'success' :)

The fact that it is the empty string is troubling, as it should be either 'success' or 'failure'. There are only two ways that readMessages can return, either by running out of messages to read when feof($pipe) returns true, or by reading a "fin" message and returning the resulting status. If you like, you could check which of these is happening.
lhalaa
Hi again :)

I've tried printing the value of $msgbody and here's the result:
config warning: no elements found. Check configuration.
config warning: adding /var/cache/fontconfig
config warning: adding ~/.fontconfig
config error: out of memoryfin|success

so, what do I do next? :D
mikeday
Okay, looks like the Fontconfig warning messages are cluttering up the stderr stream and confusing the PHP wrapper. A solution for this would be to install the RHEL4 RPM package, which should remove the Fontconfig warnings. Alternatively, if you want to keep the current package you could do some grep trickiness in the /usr/bin/prince shell script to filter out the Fontconfig warnings, or you could modify the PHP wrapper to ignore them. Installing the RPM is probably easiest, but I'll see if we can do something about the PHP wrapper. :)
lhalaa
Hi, sorry bout that, I really don't have any idea with linux. When I Installed the rpm, I'm still getting the same error, but when I changed my prince exePath from '/usr/local/bin/prince' to just 'prince', it worked perfectly. :D thanks for the help.