PHP

Writing an intelligent hook_nodeapi function in Drupal

For Drupal module developers, the hook_nodeapi function affords a lot of flexibility for interacting with nodes at various operation.  If you just start pasting or writing code, you’ll quickly end up with a giant, messy switch statement.  But there is a simpel way to keep your code nicely organized.  First, lets take a look at

Writing an intelligent hook_nodeapi function in Drupal Read More »

Troubleshooting connection problems with memcached

I was noticing today many apache segfaults on this server, and pretty high traffic loads at times. I haven’t pinpointed the exact cause of high traffic, there are a couple candidates, but the apache segfaults seem to accompanied by the following PHP errors: [13-Aug-2008 13:55:27] PHP Notice: MemcachePool::get() [memcachepool.get]: Server 127.0.0.1 (tcp 11211, udp 0)

Troubleshooting connection problems with memcached Read More »

Don’t abuse PHP’s header function for redirects

PHP’s Header function can come in quite handy when you’re building your next greate web application.  Its powerful, but as a result, its tempting to misuse it to do even the simplest things, like permanent redirects.  Usually, its done like this: // redirect /publications (this page) to real page (/documents)Header("Location: /documents/"); One line of code,

Don’t abuse PHP’s header function for redirects Read More »