Mailing List Archive

Substitution of colon by tokens during db insert
Hi Nigel,

On Mon Jul 19, 2010 at 14:26:31 +0100, Nigel wrote:
> Hi!
>
> I'm still having problems PUTting calendar files to my hosted solution.
>
> For background information I'm using 'dave' and 'cadaver'. Both work fine when
> I PUT files to my local server, but both are experiencing the same issue when
> I attempt to PUT files to my remote hosted server.
>
> The .ics files are being mangled during the write process into my Postgres db.
> So, the file should start like:
>
> CALSCALE:GREGORIAN
> METHOD:PUBLISH
> PRODID:Data::ICal 0.15
> VERSION:2.0
> X-WR-CALNAME:Barrow
> BEGIN:VEVENT
> CATEGORIES:http://www.badzilla.co.uk\x5c;SPORT\x5c;FOOTBALL\x5c;Barrow
>
> But is actually being saved in caldav_data / caldav_data
> BEGIN$1
> CALSCALE$2
> METHOD$3
> PRODID$4::ICal 0.15
> VERSION$5.0
> X-WR-CALNAME$6
> BEGIN$7
> CATEGORIES$8://www.badzilla.co.uk\;SPORT\;FOOTBALL\;Barrow
>
> So, the colon characters are being replaced by some sort of $ token.
>
> I've put extensive traces in the code and can't figure what's causing it.
> Just before the data is written to Postgres, in AwlQuery.php function
> Execute(), I have placed the trace:
>
> if ( isset($c->expand_pdo_parameters) && $c->expand_pdo_parameters ) {
> if ( isset($this->bound_parameters) ) {
> error_log("AwlQuery. bound_parameters exist");
> $this->bound_querystring = $this->connection->ReplaceParameters($this-
> >querystring,$this->bound_parameters);
> //printf(
> "\n=============================================================== OQ\n%s\n",
> $this->querystring);
> error_log("Final query is {$this->bound_querystring}"); // TRACE HERE
>
> This provides the output:
> Final query is INSERT INTO caldav_data ( user_no, dav_name, dav_etag,
> caldav_data, caldav_type, logged_user, created, modified, collection_id,
> weak_etag )
> VALUES( 1001, '/Football/AFCWimbledon/Barrow.ics', '72d2aa993d0ba362aa9a39e61a47dc44', E'BEGIN:VCALENDAR
> CALSCALE:GREGORIAN
> METHOD:PUBLISH
> PRODID:Data::ICal 0.15
> VERSION:2.0
> X-WR-CALNAME:Barrow
> BEGIN:VEVENT
>
>
> So everthing looks fine at that point. Sometime after that, maybe in
> PDO or in Postrgres, the colons are wiped and replaced by the strange
> dollar-number tokens.
>
> Any ideas?
>

I ran into exact the same behaviour a couple of weeks ago. Andrew
actually figured out, that it was caused by the combination of an old
PHP version, the new awl-libraries (which came with my update to
davical-0.9.9) and the way variables are handeled in the old PHP Data
Object extension. So probably your version of PHP is too old, too.

The plan was to workaround this for older php-versions within the
awl-library directly, but the special handling of the colon character
was missing.

For me the solution was to simply pull a newer version of
AwlDBDialect.php from his git-repository[1] and replace the original file
which came with libawl-php 0.43 with it.

HTH.

Greetings,
Michael

[1] http://repo.or.cz/w/awl.git/blob/2c75ab0c6c0141db98836c335d5965eed9ec5273:/inc/AwlDBDialect.php