Bird and the Bee

Posted by curt on August 24th, 2005

Every afternoon I take a short walk across campus to get away from my desk, un-crook my back from the I've-been-in-a-chair-all-day position, find some caffeine (usually a Frappuccino), and call home to see how my wife is doing with our 1-year-old. Yesterday's walk was not the norm.

A sparrow landed right in front of me as I was walking, and it held in its mouth a live, buzzing, bumblebee. The bird proceeded to drop the bee on the ground and then peck it to death. Cool. It was like the Discovery channel live! Unfortunately, I did not have my camera with me, so I've created this drawing for your benefit:

Bird and the Bee

PL/Ruby and PL/PHP in PostgreSQL

Posted by curt on August 23rd, 2005

The ability to write procedural language (PL) in Ruby and PHP for PostgreSQL is awesome. I wish Oracle had something similar (and no, I'm not talking about Java).

passing ORACLE_HOME to Apache environment for PHP oci8 module

Posted by curt on August 9th, 2005

A couple of weeks ago I was installing a development environment at work on CentOS with Apache 2, PHP, and the oci8 module. All configured, make'd, and installed, I was up and running with Apache, PHP, and the Oracle Client tools (sqlplus, etc.) in short order. Everything worked except the oci8 php library functions–they couldn't find my Oracle instances to connect.

I had covered all of the bases:

  • I could connect with sqlplus to my instance, so the Oracle client worked
  • I had set the ORACLE_HOME with SetEnv in Apache's configuration file and in bash's system profile
  • phpinfo() showed the oci8 module as installed and the ORACLE_HOME environment variable as set

This problem had me stumped a good part of an afternoon until I attempted to start Apache directly with apachectl instead of through the 'service' command used in CentOS. Suddenly, it worked!

A quick shuffle through the service script and I found that it was restricting the environment before calling the service like so:

env -i LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}"

Hmm. So, only LANG, PATH, and TERM are passed into any service environment: ORACLE_HOME is left out in the cold. And, even though I set it in the httpd.conf file, this is apparently too late for it to make a difference in the php oci8 module. A quick fix in the service script adds the requisite ORACLE_HOME:

env -i ORACLE_HOME=$ORACLE_HOME LANG=$LANG PATH=$PATH TERM=$TERM "${SERVICEDIR}/${SERVICE}"

The line above occurs a few times, so add to each occurance. Voila! It works.

I'm content with this solution for now, but I don't particularly like having to change the service script, so is there any other way to do this?

Update:This is apparently a common issue: Debian mailing list comment, Gentoo bug, which is fixed with a white list of environment variables in a separate file. I couldn't find a similar RedHat/CentOS bug. And, the SetEnv in the httpd.conf file is only effective for CGI PHP, which does not work for me because I'm using mod_php

back to the future in PHP

Posted by curt on August 8th, 2005

We're using PHP version 4.x in production at work, and I often find myself needing a function that has been implemented in PHP 5. A good example is the array_walk_recursive() function. I needed this in my framework library to recursively walk through an input array with a callback function to strip values of potentially harmful input. The recursive ability was key because the input array could be arbitrarily large, containing several nested arrays.

Now, I could have implemented my own function to do just this, but when we do move to PHP 5 in production, I'd want to recode to use the standard library function. To the rescue comes the PHP_Compat PEAR package, full of functions and constants to help bridge the gap between different PHP versions.

Thanks to Aidan Lister (the lead developer) and others who contributed to this package. It has saved me much coding, and I'm grateful!

And another month flies by

Posted by curt on August 8th, 2005

It's been a while since I've posted, but I've been pretty busy on all fronts. Here's a quick update:

  • Took the family to Chicago to see my sister and her husband. We went to the Lincoln Park Zoo–which little Abby enjoyed. It was good to see my sister and catch up with what they're up to. As far as big cities go, Chicago is nice, but I don't think I'd like to live there.
  • Still learning and hacking around with Ruby. I wrote a script to look at some of my Apache logs and do reverse DNS lookups. Turns out there's a bug in Ruby's resolve library using Resolve::DNS.getresources if a DNS lookup fails. A quick bug fix solved my problems, though.
  • Work has been super busy: rolled some warehouse views out to a selected few; responded to state auditor data requests with millions of records (fun!); convinced Apache on CentOS to pay attention to the ORACLE_HOME environment variable for the PHP oci8 module (I'll document this in a later blog entry); further work on my PHP application framework to create a multiple-authentication scheme depending on the resources requested; and on, and on…
  • I led worship again yesterday. It went well.
  • My parents have been to China and back since my last post. This was my mother's first (and possibly her last) trip to China. I went to China with my father several years ago, and it's an eye-opening experience: the world is a lot larger than you'd think.
  • Crystal and I have been doing a little bit of nesting in preparation for the new baby girl coming soon. I shuffled some furniture and Abby's toys around to make some room for the bassinet in the living room. Crystal and Abby got out all of the tiny baby clothes and washed them. Was Abby ever really that small?

Copyright © 2007 csummers.org. All rights reserved.