Cory Collier
Web Developer and System Administrator in Orlando, FL
RSS
  • About
  • The Story
  • The Work
  • The Contact
  • The Photos
    • Profile Pictures
    • Jan 2, 2011
    • Jan 14, 2011
    • Jan 20, 2011
    • More Crossfit Photos
    • Dec 30, 2010
    • SWAT Team Round Up
    • Mobile Uploads
    • Crossfit Pictures
    • Oct 23, 2010
    • Oct 15, 2010
    • TweetDeck for iPhone Photos
    • Jersey Shore Party
    • The Start (Cory)
    • Babies’ First Mom’s Day
    • Zoey’s 7th Birthday Party
    • 31st Birthday Party
    • Apr 23, 2010
    • Kids, Being Awesome
    • Babies
    • untitled event
    • Babies’ First Santa
    • Honeymoon
    • JP’s 2005 Halloween Party
    • Cory’s Graduation Party
    • Old Stuff
    • Jim & Tamara’s Wedding
    • Taylor’s 30th Birthday Party
    • SXSW 2009
    • Crossfit Workouts
    • Stuff
    • DC Vacation 2007
    • Wedding
    • Photos of Me
The End What Is My Wife Doing?

Red Hat vs PDO vs PCRE vs Zend Lucene Search

By admin On Oct 16 2008 · 1 Comment · In tech

Recently while working at my new job at Hydra Studio, my buddy Rob and I came across an issue that was killing us: 

“Invalid parameter number: no parameters were bound”

 When people used our search feature on our site, a few specific search terms would result in un-caught exceptions. Of course, this ONLY happened on the client’s server. Nothing like saying a project is solid, only to find out there’s something ‘special’ about the production environment.

The first thing we did, was to list out what was unique about the client’s server. The client was using a Media Temple box running CentOS 5.2. For the un-initiated, CentOS is the free version of Red Hat Enterprise Server. We run Macs in the office, and our staging server is a Mac too. Other than the OS, the normal ‘LAMP’ stuff pretty much matched verbatim. 

So, we started digging into the differences between the compiled versions of PHP between the development and production environments, and one thing popped out at us:

PCRE

The version that’s supported on Red Hat / CentOS is 6.6. That’s horrible. 6.6 came out nearly 3 years ago, and the version the client was running had no support for unicode at all. A little research, and we found out that Zend Search Lucene (what we built the search functionality on top of) requires unicode for the way it stores search indexes.

With that, we figured we were done. The client had a limitation on their server, they needed to address it, and the problem would fix itself when they did. Not quite so fast …

I was testing some of the searching on my iMac, when the same issue happened on my own computer. Disaster! Could it be that something in our own code was the culprit? What half-reproducible error was causing this? 

After hours of searching for an answer on the googlez, I came across some help on the Zend Issue Tracker. It turns out, that PDO was failing when it was trying to prepare a statement, when that statement contained a question mark. When I switched my SQL adapter to Mysqli, the problem was solved. Both the production and the development environments were bug free after the change.

It turns out, that our search indexes would return fields that either contained question marks, because they actually existed in the document (as was the case locally), or because the document had encoding errors when the search index was built (as was the case on the production servers). The ORM we used would grab the documents, and grab relevant data from the database by querying with the fields stored in the index.

The SQL that was being prepared, would then look something like this:

‘SELECT id FROM folks WHERE first_name LIKE ‘Jo?hnny’

The question marks would be interpreted by PDO as variable markers, which rightfully didn’t exist.

So, the real solution wound up being a little bit of a mix between the client’s problem, and our own. Granted, we needed to catch question marks being stored in db before they got there. That improves the longevity of our own code. However, the search functionality will still return results that may have question marks in them, thus causing the same issue. That issue is resolved by using Mysqli, but that feels more like a hack, than a solution.

Anyways, I spent a long time trying to search the answer to this and found nothing except the one mention in the issue tracker. For those of you using Zend Lucence Search on Red Hat / CentOS servers. Make sure you use Mysql if you’re using the Zend ORM to populate models based on results returned from the index. 

Oh yeah, and make sure you filter your input too, Mr. Bobby Tables…..

Tagged with: centos • debug • linux • lucene • pcre • pdo • php • red hat • search • zend 
Share →
Tweet
  • Pingback: Unemployed | Cory Collier

  • Categories

    • opinion
    • personal
    • politics
    • review
    • tech
    • tutorial
    • Uncategorized
    • work
  • Archives

    • April 2012
    • March 2012
    • December 2011
    • August 2011
    • April 2011
    • January 2011
    • July 2010
    • December 2009
    • November 2009
    • October 2009
    • August 2009
    • July 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
    • September 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • April 2007
  • Calendar

    October 2008
    M T W T F S S
    « Sep   Nov »
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
  • Meta

    • Log in
    • Entries (RSS)
@rawdrigo wait, you're *STILL* not done??  — corycollier

Cory Collier

Pages

  • About
  • The Contact
  • The Photos
  • The Story
  • The Work

The Latest

  • Belief
    The season of lent is over. For this season, I gave up […]

More

© 2012 Cory Collier
PageLines by PageLines