PDA

View Full Version : Bug in pg_escape_string


domdorn
12-11-2009, 05:22 PM
Since PHP 5.2 pg_escape_string has the optional first parameter connection
http://de.php.net/pg_escape_string

Quercus says it is 5.2, but does not provide a constructor for this, thus code that uses this (e.g. Pear::Auth / Pear::DB ) throws exceptions/fails.

Please add this constructor... it silly to pass the connection to a method that simply alters a string, but the php-dev gui's make errors all the time.

I think the following patch would solve the problem, applied in directory src/com/caucho/quercus/lib/db


domdorn@camelion ~/work/quercus/quercus/src/com/caucho/quercus/lib/db $ svn diff PostgresModule.java
Index: PostgresModule.java
================================================== =================
--- PostgresModule.java (revision 6409)
+++ PostgresModule.java (working copy)
@@ -904,7 +904,27 @@
}
}

+
/**
+ * Escape a string for insertion into a text field
+ */
+ @ReturnNullAsFalse
+ public static StringValue pg_escape_string(Env env,
+ @NotNull Postgres conn,
+ StringValue data)
+ {
+ try {
+ return conn.realEscapeString(data);
+
+ } catch (Exception ex) {
+ log.log(Level.FINE, ex.toString(), ex);
+ return null;
+ }
+ }
+
+
+
+ /**
* Sends a request to execute a prepared statement with given parameters,
* and waits for the result
*/



Thanks,
Dominik

nam
12-12-2009, 03:58 AM
I've added a bug report at:

http://bugs.caucho.com/view.php?id=3810