Hoopla!

now with extra whiz-bang!

Hoopla!

Automatically checking for php parse errors

July 27, 2006 · 0 comments

I’ve been running into a problem on one of my multi-developer sites where we’ve been unable to break the habit of occasionally allowing parse errors to show up on one of our php sites. We mean well, we try to avoid it, but sometimes a quick fix is necessary and we don’t always have time to do testing (it should be noted that we don’t have a testing harness of any kind for this site).

Just last weekend I was horrified to find that I’d left a parse error in a small, seldom-visited part of our site for several days. No users encountered it but it prevented some automated tasks from working as they’re supposed to.

It’s become clear that we need more than just to try harder – we need technology to watch our backs. Do accomplish this I’ve developed a bash script that takes directories as arguments and has php parse the contents of every php script in that folder’s structure.

The Code: -
#!/bin/bash

check_dir() {
  for file in $*/*.php
   do
    if [ -d $file ]; then
      echo "going into $file" 
      check_dir $file
    else
      if [ "`php -l $file`" = "No syntax errors detected in $file" ]; then
        echo "valid in $file" 
      else
        echo "$file invalid" 
      fi
    fi
  done
}

for dir in $*
 do
  check_dir $dir
done

It’s very simple – but it’s all that’s required to get started. From here I’m going to replace the echo’ed output with tasks. Specifically, a php file will be run when files are found to be invalid and both an email and an SMS will be sent to the developer’s phones.

We’re setting this script to run every 5 minutes, hopefully no weekends will pass from now on without being error- (at least parse error-) free.

→ 0 comments Tags:

uninitialized constant Admin::GeneralController

April 10, 2006 · 0 comments

I just updated my typo to revision 1004 and, while almost all of my site is accessible, going to /admin barfs out a 500 error.

From my log:
1
2
3
4
5
6
7
8
9
10
11
12
13
NameError (uninitialized constant Admin::GeneralController):
    /vendor/rails/activerecord/lib///activesupport/lib/active_support/dependencies.rb:100:in `const_missing'
    generated/routing/recognition.rb:9:in `recognize_path'
    /vendor/rails/actionpack/lib/action_controller/routing.rb:477:in `recognize!'
    /vendor/rails/railties/lib/dispatcher.rb:38:in `dispatch'
    /vendor/rails/railties/lib/fcgi_handler.rb:150:in `process_request'
    /vendor/rails/railties/lib/fcgi_handler.rb:54:in `process!'
    /vendor/rails/railties/lib/fcgi_handler.rb:53:in `each_cgi'
    /usr/lib/ruby/1.8/fcgi.rb:597:in `each'
    /usr/lib/ruby/1.8/fcgi.rb:597:in `each_cgi'
    /vendor/rails/railties/lib/fcgi_handler.rb:53:in `process!'
    /vendor/rails/railties/lib/fcgi_handler.rb:23:in `process!'
    dispatch.fcgi:34

Going straight to /admin/content/new can get me to where I can post – so this might just be a typo somewhere.

→ 0 comments Tags: