r99562 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99561‎ | r99562 | r99563 >
Date:20:49, 11 October 2011
Author:mah
Status:reverted (Comments)
Tags:
Comment:
Avoid warnings from PG about improper escaping.
See http://www.postgresql.org/docs/8.1/static/release-8-1.html
Modified paths:
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -766,8 +766,8 @@
767767 $q = <<<SQL
768768 SELECT 1 FROM pg_class, pg_namespace, pg_trigger
769769 WHERE relnamespace=pg_namespace.oid AND relkind='r'
770 - AND tgrelid=pg_class.oid
771 - AND nspname=%s AND relname=%s AND tgname=%s
 770+ AND tgrelid=pg_class.oid
 771+ AND nspname=%s AND relname=%s AND tgname=%s
772772 SQL;
773773 $res = $this->query(
774774 sprintf(
@@ -878,7 +878,11 @@
879879 } elseif ( is_bool( $s ) ) {
880880 return intval( $s );
881881 } elseif ( $s instanceof Blob ) {
882 - return "'" . $s->fetch( $s ) . "'";
 882+ $ret = "'" . $s->fetch( $s ) . "'";
 883+ if ( $this->numeric_version >= 8.1 ) {
 884+ $ret = "E$ret";
 885+ }
 886+ return $ret;
883887 }
884888 return "'" . pg_escape_string( $this->mConn, $s ) . "'";
885889 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r100162revert r99562 and set standard_conforming_strings “on” by defaultmah21:09, 18 October 2011

Comments

#Comment by OverlordQ (talk | contribs)   20:16, 17 October 2011

This breaks Math and probably other stuff that uses BYTEA fields.


Running test [https://bugzilla.wikimedia.org/show_bug.cgi?id=1887 BUG 1887], part 2: A <math> with a thumbnail- math enabled... PHP Warning:  pg_query(): Query failed: ERROR:  invalid byte sequence for encoding "UTF8": 0xfa in /var/www/thedarkcitadel.com/w/includes/db/DatabasePostgres.php on line 253


Warning: pg_query(): Query failed: ERROR:  invalid byte sequence for encoding "UTF8": 0xfa in /var/www/thedarkcitadel.com/w/includes/db/DatabasePostgres.php on line 253
A database error has occurred.  Did you forget to run maintenance/update.php after upgrading?  See: [http://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script http://www.mediawiki.org/wiki/Manual:Upgrading#Run_the_update_script]
Query: SELECT  math_outputhash,math_html_conservativeness,math_html,math_mathml  FROM "parsertest_math"  WHERE math_inputhash = E'\xfa50b8b616463173474302ca3e63586b'  LIMIT 1  

Function: MathRenderer::_recall

Error: 1 ERROR:  invalid byte sequence for encoding "UTF8": 0xfa

#Comment by MarkAHershberger (talk | contribs)   03:51, 18 October 2011

I don't get this error with Pg 8.4

#Comment by OverlordQ (talk | contribs)   06:12, 18 October 2011

It breaks with standard_conforming_strings enabled which is by default in 9.1+

Status & tagging log