Thread: Octal to hex transition - WTF

Octal to hex transition - WTF

From
Craig Ringer
Date:
Hi all

I just found out that PHP 5.3's PostgreSQL PDO driver (as used by
Drupal) is broken by the Postgresql 8.0 transition from octal to hex
encoding for bytea. It passes the raw hex through to the app, including
the leading x , causing PHP's unserialize() function to choke.

I'm using Drupal with Apache and PostgreSQL on Windows (sigh) because
I'm writing up a step-by-step hand-holding guide for someone who needs
to do some testing against our Drupal database.

Drupal doesn't check that bytea_output is set to 'escape' as a
workaround or do a sanity test to detect this fault, so the results are
... interesting:

Notice: unserialize(): Error at offset 0 of 27 bytes in
variable_initialize() (line 749 of C:\Program Files\Apache Software
Foundation\Apache2.2\htdocs\drupal-7.0\includes\bootstrap.inc).

If anybody else lands up whacking their head against this for a while: just

   ALTER DATABASE drupal SET bytea_output = 'escape'

to have your sanity restored.

The amount of breakage being seen in drivers really makes me wonder if
the the octal->hex transition should've been done with an opt-in from
drivers during negotiation or an explicit SET, rather than just making
it globally default. But, hey, hindsight.

--
Craig Ringer

Tech-related writing at http://soapyfrogs.blogspot.com/