Monday, July 28, 2008

php considered immature

so i'm writing this mailing sender in php. test driven design works btw. just need to get used to it. anyway, over a week i ran into 3 behaviors, that really made me scratc hmy head a bit:

1) i installed Pear::Mail, and skipped dependencies. "well", i thought, "it'll tell me if i'll need any". so i'm creating html emails, building whole test suite, code, class etc. everything works except one minor detail. when it should actually send email - it does nothing. silently exit, without sending. no errors, nothing. turns out - it needed Pear::Mail#net_smtp. took me some hours to figure out.

2) the plan was to spawn a process with proc_open(), send info to it through pipe and get an output from pipe. easy, right? but! what happens, if the process hangs? just poke it until predefined timeout occurs. yeah, not that easy. turns out proc_open() pipes can't be set to non-blocking, meaning if parent tries to read from process and process hangs - parent hangs as well. now i have to use shared memory or whatever, just because those pipes can't be set to non-blocking.

3) the script had 3 include files and was spawned by parent script. when parent was run from command line - all went ok. when parent was called from apache - it didn't do what expected. after some poking i figured out, that it didn't return from the second include. nope. just entered it, ran through it and exited, never returning to parent to include third script and, actually, do what's needed. this one really took some time. turned out - it was whitespace, after the ending tag "?>". how on earth would that be relevant? no idea. but it worked from webserver then, as well.

three different bad behaviors, over the course of a week. talk about language maturity.

1 comment:

Anonymous said...

And these people pick on .net? Meh.